跳转到主要内容
POST
/
crypto
/
rpc
/
{network}
curl --request POST \
  --url https://api.venice.ai/api/v1/crypto/rpc/{network} \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "jsonrpc": "2.0",
  "method": "eth_chainId",
  "params": [],
  "id": 1
}
'
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x1"
}
将 JSON-RPC 2.0 请求(单个或批量)转发到受支持的区块链节点。同时支持 API 密钥和 x402 钱包身份验证。计费按额度计,并以您的 Venice 余额结算 —— 一份凭证、一张账单,覆盖下方所有链。

身份验证

此端点支持两种身份验证方法:
  • API 密钥:通过 Authorization: Bearer <key> 请求头进行标准 Bearer token 身份验证。
  • x402 钱包:使用 Base 或 Solana 钱包中的 USDC 额度按用量付费。无需 Venice 账户。设置请参阅 x402 指南
两种方法共享相同的速率限制和计费(Venice 额度)。

支持的网络

请参阅 GET /crypto/rpc/networks 查看实时、权威的列表。当前覆盖范围:
家族MainnetTestnets
Ethereumethereum-mainnetethereum-sepoliaethereum-holesky
Polygonpolygon-mainnetpolygon-amoy
Arbitrumarbitrum-mainnetarbitrum-sepolia
Optimismoptimism-mainnetoptimism-sepolia
Basebase-mainnetbase-sepolia
Linealinea-mainnetlinea-sepolia
Avalanche C-Chainavalanche-mainnetavalanche-fuji
BNB Smart Chainbsc-mainnetbsc-testnet
Blastblast-mainnetblast-sepolia
zkSync Erazksync-mainnetzksync-sepolia
Starknetstarknet-mainnetstarknet-sepolia

请求格式

单个请求

{
  "jsonrpc": "2.0",
  "method": "eth_chainId",
  "params": [],
  "id": 1
}

批量请求

最多 100 个 JSON-RPC 2.0 对象的数组。每个项目独立验证;如果任何方法不受支持,整个批次将被以 400 拒绝,所有不合规的方法名都会列在错误消息中。
[
  { "jsonrpc": "2.0", "method": "eth_chainId", "params": [], "id": 1 },
  { "jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 2 }
]

支持的方法和额度等级

方法被分为三个额度等级。每次调用消耗的额度 = baseCredits[chain] × methodTier
等级倍数示例方法
Standardeth_calleth_getBalanceeth_blockNumbereth_sendRawTransactioneth_getLogseth_getTransactionReceipteth_estimateGasnet_versionweb3_clientVersion、ERC-4337 bundler 方法(eth_sendUserOperationeth_estimateUserOperationGas 等)、链家族扩展(zks_*linea_*bor_*starknet_*
Advancedtrace_blocktrace_calltrace_transactiondebug_traceCalldebug_traceTransactiondebug_traceBlockByHashtxpool_inspecttxpool_statusarbtrace_*
Largetrace_replayBlockTransactionstrace_replayTransactiontxpool_contentarbtrace_replayTransactionarbtrace_replayBlockTransactions

每条链的基础额度

baseCredits
20Ethereum + 以上所有 EVM L2(Base、Optimism、Arbitrum、Polygon、Linea、Avalanche、BSC、Blast)以及 Starknet
30zkSync Era

费用示例

按 Venice 的 ~$6.25 × 10⁻⁷ 每额度计算:
调用额度USD 费用
Ethereum 上的 eth_call(20 × 1×)20$0.0000125
Ethereum 上的 trace_transaction(20 × 2×)40$0.0000250
Ethereum 上的 trace_replayTransaction(20 × 4×)80$0.0000500
zkSync 上的 eth_call(30 × 1×)30$0.0000188

不支持

  • 仅 WebSocket 方法eth_subscribeeth_unsubscribe)—— 此代理仅支持 HTTP。请改为轮询,或升级到直连的 WebSocket 提供商。
  • 有状态过滤器方法eth_newFiltereth_getFilterChangeseth_getFilterLogseth_uninstallFiltereth_newBlockFiltereth_newPendingTransactionFilter)—— 过滤器状态绑定到单一上游后端,在负载均衡的 HTTP 代理上会静默失效。请改用 eth_getLogs(无状态)。
  • 矿工 / 持有密钥方法eth_signeth_accountseth_miningeth_hashrateeth_getWorketh_submitWork)—— 托管的提供商端点不持有用户私钥,因此这些方法总是返回错误。请在客户端签名交易并通过 eth_sendRawTransaction 提交。
  • 未映射的方法 —— 任何未明确加入允许列表的方法都会返回 400。请联系支持以请求新增。

批量按项计费

即使 HTTP 响应为 200,批量中的单个项目也可能带有 JSON-RPC error 字段返回(例如参数错误或目标链不支持的方法)。Venice 对这些项目按每个 5 额度计费,而不是完整的方法等级 —— 对正常的”探索 API”错误的小小宽容。
// Batch request:
[
  { "jsonrpc": "2.0", "method": "eth_chainId",   "params": [],         "id": 1 },
  { "jsonrpc": "2.0", "method": "eth_getBalance","params": ["bad"],    "id": 2 }
]

// Response (HTTP 200, X-Venice-RPC-Credits: 25):
[
  { "jsonrpc": "2.0", "id": 1, "result": "0x1" },
  { "jsonrpc": "2.0", "id": 2, "error": { "code": -32602, "message": "invalid params" } }
]
第一项(成功)计费 20 额度,第二项(RPC 级错误)计费 5,合计 = 25

速率限制

每个已认证调用方的每分钟请求上限:
等级请求/分钟
Standard100
Staff1,000
超过上限时,端点会以 429 返回,并附带 customMessage 和标准的 X-RateLimit-* 响应头。

幂等性

Idempotency-Key 请求头设置为任何匹配 [A-Za-z0-9_-]{1,255} 的字符串,可启用安全重试。响应以 (user, idempotency-key) 为键缓存 24 小时:
  • 使用相同的键和相同的请求体重放,将返回缓存的响应并附带 Idempotent-Replayed: true 响应头。不会请求上游,也不会扣除新的额度。
  • 使用相同的键但不同的请求体重放,将返回 400,以防止静默的状态损坏。请为不同请求选择新键。

响应头

请求头说明
X-Venice-RPC-Credits此请求扣除的额度。批量请求时,这是所有项目的总和。
X-Venice-RPC-Cost-USD精确到 8 位小数的美元费用。等于 X-Venice-RPC-Credits × 每额度价格
X-Request-ID32 字符的关联 ID。请在任何支持沟通中附带。
Idempotent-Replayed当响应来自幂等性缓存时存在,值为 "true"
X-RateLimit-Limit / X-RateLimit-Remaining / X-RateLimit-Reset仅在 429 响应中设置。

交易转发的取证日志

eth_sendRawTransaction 的每次调用都会在服务器端记录 tx hash(原始字节的 keccak256)、网络 slug、请求 ID 和调用方用户 ID。我们保留签名载荷本身 —— 该 hash 可从链上回执中恢复。该审计追踪的存在是为了在客户的 API 密钥被泄露并被用于通过我们的基础设施转发非法交易时,可将链上活动关联到负责账户。

示例

curl https://api.venice.ai/api/v1/crypto/rpc/ethereum-mainnet \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_chainId",
    "params": [],
    "id": 1
  }'
{ "jsonrpc": "2.0", "id": 1, "result": "0x1" }
响应头:X-Venice-RPC-Credits: 20X-Venice-RPC-Cost-USD: 0.00001250X-Request-ID: <nanoid>

Postman 集合

我们的公开工作区提供了一个可直接导入的 Postman 集合,包含 27 个示例请求(发现、standard/advanced/large 调用、多链、批量、幂等性、错误场景): Venice Crypto RPC — Postman 集合 将集合变量 apiKey 设置为您的 Venice API 密钥,即可立即开始发送请求。

授权

Authorization
string
header
必填

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

请求头

Idempotency-Key
string

Optional idempotency key for safe retries. Pattern: [A-Za-z0-9_-]{1,255}. Retrying within 24 hours with the same key + same body replays the cached response with Idempotent-Replayed: true. Same key + different body returns 400.

Pattern: ^[A-Za-z0-9_-]{1,255}$
示例:

"a1b2c3d4-e5f6-7890-abcd-ef1234567890"

路径参数

network
string
必填

Venice-side network slug. Call GET /api/v1/crypto/rpc/networks for the current list.

示例:

"ethereum-mainnet"

请求体

application/json
method
string
必填

JSON-RPC method name. See the "Supported methods" section of the endpoint description for the classification into 1×/2×/4× pricing tiers.

示例:

"eth_chainId"

jsonrpc
enum<string>
可用选项:
2.0
示例:

"2.0"

params
any[]

Method parameters. Shape depends on the method; see the upstream chain documentation.

示例:
[]
id

Caller-supplied request ID echoed back in the response. Required for batch request correlation.

示例:

1

响应

JSON-RPC response forwarded from the upstream node. Content-Type is forced to application/json regardless of upstream headers.

jsonrpc
string
示例:

"2.0"

id
result
any

Method-dependent result. Present on success.

error
object

JSON-RPC error object. Present on per-request failure (HTTP status is still 200 in that case).