> ## Documentation Index
> Fetch the complete documentation index at: https://docs.venice.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Crypto RPC for Agents

> Use Venice as both the model provider and the blockchain RPC layer for autonomous AI agents — one credential, 230+ models, 11 chains, no MetaMask.

Venice gives your agent both inference (230+ models) and blockchain access (10 EVM chains plus Starknet) through a single credential. Your agent can think, sign, and send transactions without juggling separate accounts for inference and RPC providers.

<CardGroup cols={2}>
  <Card title="One credential, two superpowers" icon="key">
    A single API key (or wallet) for both LLM inference and JSON-RPC calls.
  </Card>

  <Card title="11 chains supported" icon="link">
    Ethereum, Base, Arbitrum, Optimism, Polygon, Linea, Avalanche, BSC, Blast, zkSync Era, and Starknet (mainnet plus testnets).
  </Card>

  <Card title="Stake VVV for headless funding" icon="coins">
    Stake VVV on Base to earn daily DIEM, the only fully headless funding path for a minted API key. USD and crypto top-ups are also available through the dashboard.
  </Card>

  <Card title="Keyless auth via x402" icon="wallet">
    Agents can authenticate with a wallet signature and pay in USDC on Base or Solana.
  </Card>
</CardGroup>

## Why Venice for on-chain agents?

| Capability         | What your agent gets                                                                        |
| ------------------ | ------------------------------------------------------------------------------------------- |
| **Inference**      | 230+ text, image, video, audio, and embedding models through one OpenAI-compatible endpoint |
| **Crypto RPC**     | JSON-RPC 2.0 proxy to 10 EVM chains plus Starknet (mainnet and testnets)                    |
| **Authentication** | Standard API key or x402 wallet auth (no Venice account required)                           |
| **Funding**        | Autonomous: VVV staking for daily DIEM. Browser: USD or crypto top-ups via the dashboard    |
| **Batching**       | Up to 100 JSON-RPC calls per request, multi-chain in parallel                               |
| **Idempotency**    | Safe retries with `Idempotency-Key` header                                                  |

## Authentication

Pick the auth method that matches how your agent runs.

| Method          | Best for                                         | How it works                                                                                                                                                             |
| --------------- | ------------------------------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **API key**     | Server-side agents, fixed deployments            | `Authorization: Bearer <key>` header. Get a key at [venice.ai/settings/api](https://venice.ai/settings/api).                                                             |
| **x402 wallet** | Autonomous, crypto-native, or short-lived agents | Wallet signs a Sign-In-With-X message, pays per request in USDC on Base or Solana. No Venice account needed. See the [x402 guide](/guides/integrations/x402-venice-api). |

Both methods share the same rate limits and billing in Venice credits.

<Tip>
  Truly autonomous agents can mint their own API key by staking VVV on Base. See [Autonomous Agent API Key Creation](/guides/getting-started/generating-api-key-agent).
</Tip>

## Crypto RPC quickstart

Send any JSON-RPC 2.0 method to `POST /crypto/rpc/{network}`.

```bash theme={"system"}
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
  }'
```

Response:

```json theme={"system"}
{ "jsonrpc": "2.0", "id": 1, "result": "0x1" }
```

Response headers include `X-Venice-RPC-Credits` (credits charged), `X-Venice-RPC-Cost-USD` (dollar cost), and `X-Request-ID` (correlation ID).

### Supported networks

| Family            | Mainnet             | Testnets                               |
| ----------------- | ------------------- | -------------------------------------- |
| Ethereum          | `ethereum-mainnet`  | `ethereum-sepolia`, `ethereum-holesky` |
| Base              | `base-mainnet`      | `base-sepolia`                         |
| Arbitrum          | `arbitrum-mainnet`  | `arbitrum-sepolia`                     |
| Optimism          | `optimism-mainnet`  | `optimism-sepolia`                     |
| Polygon           | `polygon-mainnet`   | `polygon-amoy`                         |
| Linea             | `linea-mainnet`     | `linea-sepolia`                        |
| Avalanche C-Chain | `avalanche-mainnet` | `avalanche-fuji`                       |
| BNB Smart Chain   | `bsc-mainnet`       | `bsc-testnet`                          |
| Blast             | `blast-mainnet`     | `blast-sepolia`                        |
| zkSync Era        | `zksync-mainnet`    | `zksync-sepolia`                       |
| Starknet          | `starknet-mainnet`  | `starknet-sepolia`                     |

Use [`GET /crypto/rpc/networks`](/api-reference/endpoint/crypto/networks) for the live, authoritative list.

### Method tiers

Methods are grouped into three credit tiers. Total cost = `baseCredits[chain] × methodTier`.

| Tier         | Multiplier | Examples                                                                                                                                 |
| ------------ | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
| **Standard** | 1x         | `eth_call`, `eth_getBalance`, `eth_blockNumber`, `eth_sendRawTransaction`, `eth_getLogs`, `eth_getTransactionReceipt`, `eth_estimateGas` |
| **Advanced** | 2x         | `trace_block`, `trace_call`, `trace_transaction`, `debug_traceCall`, `debug_traceTransaction`                                            |
| **Large**    | 4x         | `trace_replayBlockTransactions`, `trace_replayTransaction`, `txpool_content`                                                             |

Full list and pricing detail in the [Crypto RPC API reference](/api-reference/endpoint/crypto/rpc).

## Agent recipes

Common patterns for AI agents that need to read and write on-chain.

### Read a wallet's native balance

```bash theme={"system"}
curl https://api.venice.ai/api/v1/crypto/rpc/base-mainnet \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_getBalance",
    "params": ["0xYourWalletAddress", "latest"],
    "id": 1
  }'
```

### Read ERC-20 token balance

Call the `balanceOf(address)` selector with `eth_call`. The `data` field is the 4-byte selector (`0x70a08231`) followed by the wallet address left-padded to 32 bytes. Easiest to let a library encode it:

```typescript theme={"system"}
import { encodeFunctionData, parseAbi } from 'viem'

const data = encodeFunctionData({
  abi: parseAbi(['function balanceOf(address) view returns (uint256)']),
  args: ['0xWalletAddress'],
})

const response = await fetch('https://api.venice.ai/api/v1/crypto/rpc/base-mainnet', {
  method: 'POST',
  headers: {
    Authorization: `Bearer ${process.env.VENICE_API_KEY}`,
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    jsonrpc: '2.0',
    method: 'eth_call',
    params: [{ to: '0xacfE6019Ed1A7Dc6f7B508C02d1b04ec88cC21bf', data }, 'latest'],
    id: 1,
  }),
})
```

The contract address above is VVV on Base. Swap it for any ERC-20 contract.

### Send a signed transaction (full lifecycle)

Venice never holds your private keys. The agent gathers tx parameters via RPC reads, signs locally with a library like [viem](https://viem.sh) or [ethers](https://docs.ethers.org), then relays the raw hex through Venice.

<Steps>
  <Step title="Get the next nonce">
    ```bash theme={"system"}
    curl https://api.venice.ai/api/v1/crypto/rpc/base-mainnet \
      -H "Authorization: Bearer $VENICE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0xAgentWallet","pending"],"id":1}'
    ```

    Use `"pending"` so back-to-back sends don't collide.
  </Step>

  <Step title="Get gas price">
    ```bash theme={"system"}
    curl https://api.venice.ai/api/v1/crypto/rpc/base-mainnet \
      -H "Authorization: Bearer $VENICE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":1}'
    ```

    For EIP-1559 chains, prefer `eth_feeHistory` to compute `maxFeePerGas` and `maxPriorityFeePerGas`.
  </Step>

  <Step title="Estimate gas">
    ```bash theme={"system"}
    curl https://api.venice.ai/api/v1/crypto/rpc/base-mainnet \
      -H "Authorization: Bearer $VENICE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0xAgentWallet","to":"0xRecipient","value":"0x0","data":"0x..."}],"id":1}'
    ```
  </Step>

  <Step title="Sign locally">
    ```typescript theme={"system"}
    import { privateKeyToAccount } from 'viem/accounts'
    import { base } from 'viem/chains'

    const account = privateKeyToAccount(process.env.AGENT_PRIVATE_KEY)

    const signed = await account.signTransaction({
      chainId: base.id,
      nonce,                  // from step 1
      gas,                    // from step 3
      maxFeePerGas,           // from step 2 (fee history)
      maxPriorityFeePerGas,   // from step 2 (fee history)
      to: '0xRecipient',
      value: 0n,
      data: '0x...',
    })
    ```
  </Step>

  <Step title="Submit through Venice">
    ```bash theme={"system"}
    curl https://api.venice.ai/api/v1/crypto/rpc/base-mainnet \
      -H "Authorization: Bearer $VENICE_API_KEY" \
      -H "Idempotency-Key: agent-tx-<id>" \
      -H "Content-Type: application/json" \
      -d '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xSignedHex"],"id":1}'
    ```

    Always set `Idempotency-Key` on relays so a network blip can't double-broadcast.
  </Step>

  <Step title="Poll for receipt">
    ```bash theme={"system"}
    curl https://api.venice.ai/api/v1/crypto/rpc/base-mainnet \
      -H "Authorization: Bearer $VENICE_API_KEY" \
      -H "Content-Type: application/json" \
      -d '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xTxHash"],"id":1}'
    ```

    Poll every few seconds until `result` is non-null. Check `result.status` (`"0x1"` = success).
  </Step>
</Steps>

<Note>
  Every `eth_sendRawTransaction` call is logged server-side with the tx hash, network, request ID, and calling user ID. The signed payload itself is not retained. This audit trail exists so compromised keys used for illicit relays can be traced back to the responsible account.
</Note>

### Batch multiple calls (multi-chain portfolio check)

Send up to 100 JSON-RPC objects in one request. Each is validated and billed independently.

```bash theme={"system"}
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_blockNumber", "params": [], "id": 1 },
    { "jsonrpc": "2.0", "method": "eth_getBalance", "params": ["0xWallet", "latest"], "id": 2 },
    { "jsonrpc": "2.0", "method": "eth_gasPrice", "params": [], "id": 3 }
  ]'
```

For multi-chain reads (one call per chain), issue parallel requests to different `{network}` endpoints.

### Safe retries with idempotency

Set the `Idempotency-Key` header to any string matching `[A-Za-z0-9_-]{1,255}`. Venice caches the response for 24 hours keyed on `(user, key)`. Replays return the cached result with `Idempotent-Replayed: true` and charge nothing.

```bash theme={"system"}
curl https://api.venice.ai/api/v1/crypto/rpc/base-mainnet \
  -H "Authorization: Bearer $VENICE_API_KEY" \
  -H "Idempotency-Key: agent-tx-2026-04-21-001" \
  -H "Content-Type: application/json" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_sendRawTransaction",
    "params": ["0xSignedRawTxHex"],
    "id": 1
  }'
```

This is critical for transaction relays where a network blip could otherwise cause your agent to broadcast the same tx twice.

## Funding the agent's API key

Once the agent has a Venice API key, it needs spendable balance on the underlying account before paid endpoints will accept the key. There are two ways to put balance there:

| Path                                       | Autonomous?  | How it works                                                                                                                                                                                                                                                                                                                                                             |
| ------------------------------------------ | ------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| **DIEM from VVV staking**                  | Yes          | Stake VVV in the [Venice Staking Smart Contract](https://basescan.org/address/0x321b7ff75154472B18EDb199033fF4D116F340Ff#code) on Base. The wallet's daily DIEM allocation is proportional to its share of the staking pool. The account needs at least 0.1 DIEM accrued before any DIEM is spendable. DIEM refreshes at 00:00 UTC. To grow daily spend, stake more VVV. |
| **USD or crypto top-up via the dashboard** | No (browser) | Sign into [venice.ai](https://venice.ai) with the same wallet (Sign-In-With-Ethereum), then add credits in Settings, API. Both Stripe (card) and Coinbase (crypto) live behind that page and require a browser. Credits never expire.                                                                                                                                    |

For an agent that runs unattended, **DIEM via VVV staking is the only fully headless funding path for a minted API key today**. If the agent's daily spend exceeds its DIEM allocation, the realistic options are: stake more VVV, or have an operator sign in and top up in USD or crypto.

### Autonomous VVV staking and key generation

A truly autonomous agent can manage its own VVV wallet on Base, stake it, and mint its own Venice API key with no human in the loop. The full flow:

<Steps>
  <Step title="Acquire VVV and ETH for gas">
    Send VVV to the agent's wallet (or have the agent swap on [Aerodrome](https://aerodrome.finance) or [Uniswap](https://app.uniswap.org)), plus a small amount of ETH on Base for the two staking transactions.
  </Step>

  <Step title="Stake VVV">
    `approve` the staking contract on the VVV token, then `stake(amount)` on `0x321b7ff75154472B18EDb199033fF4D116F340Ff`. The wallet's sVVV balance updates atomically with the stake.
  </Step>

  <Step title="Mint an API key">
    `GET /api/v1/api_keys/generate_web3_key` returns a JWT that expires 15 minutes after issuance. Sign the raw token with the staking wallet, then `POST` the address, signature, and token back. Venice returns an API key bound to the user account derived from that wallet.
  </Step>
</Steps>

Minting only requires a non-zero sVVV balance, so 1 staked VVV is enough to receive a key. **Spending** with the key is a separate question, governed by the funding table above.

See [Autonomous Agent API Key Creation](/guides/getting-started/generating-api-key-agent) for the complete walkthrough with code and the full error reference.

## x402 wallet auth in 30 seconds

If your agent already has a Base or Solana wallet, skip the API key entirely. The [`venice-x402-client`](https://github.com/veniceai/x402-client) SDK handles Sign-In-With-X signing, top-ups, and balance tracking.

```bash theme={"system"}
npm install venice-x402-client
```

```typescript theme={"system"}
import { VeniceClient } from 'venice-x402-client'

const venice = new VeniceClient(process.env.WALLET_KEY)

await venice.topUp(10) // skip if the wallet already has balance

const response = await venice.chat({
  model: 'kimi-k2-6',
  messages: [{ role: 'user', content: 'What is the latest block on Base?' }]
})
```

The same wallet auth works against `/crypto/rpc/{network}` for blockchain reads and writes. Full protocol details in the [x402 guide](/guides/integrations/x402-venice-api).

## Pricing

Crypto RPC is billed in Venice credits. Each response includes `X-Venice-RPC-Credits` (credits charged) and `X-Venice-RPC-Cost-USD` (dollar cost) so your agent can track spend per request.

### Base credits per chain

| Base credits | Chains                                                                              |
| ------------ | ----------------------------------------------------------------------------------- |
| **20**       | Ethereum, Base, Optimism, Arbitrum, Polygon, Linea, Avalanche, BSC, Blast, Starknet |
| **30**       | zkSync Era                                                                          |

### Cost examples

Observed pricing for standard, advanced, and large method tiers:

| Call                                            | Credits | USD cost      |
| ----------------------------------------------- | ------- | ------------- |
| `eth_call` on Ethereum (20 × 1x)                | 20      | \~\$0.0000140 |
| `trace_transaction` on Ethereum (20 × 2x)       | 40      | \~\$0.0000280 |
| `trace_replayTransaction` on Ethereum (20 × 4x) | 80      | \~\$0.0000560 |
| `eth_call` on zkSync (30 × 1x)                  | 30      | \~\$0.0000210 |

Always trust the `X-Venice-RPC-Cost-USD` response header for the authoritative cost. Errored items in batch requests are billed at a flat 5 credits each.

### Rate limits

| Tier     | Requests per minute |
| -------- | ------------------- |
| Standard | 100                 |
| Staff    | 1,000               |

When exceeded, the endpoint returns `429` with standard `X-RateLimit-*` response headers.

## Error handling

Common HTTP responses your agent should handle:

| Status | Meaning                                                                                                                                    | What to do                                                                                                                                                                                                                               |
| ------ | ------------------------------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `400`  | Unsupported or unmapped JSON-RPC method, or malformed batch                                                                                | Verify the method against the [allowlist](/api-reference/endpoint/crypto/rpc). The error body names the offending method.                                                                                                                |
| `400`  | Replay of an `Idempotency-Key` with a different body                                                                                       | Use a fresh key for distinct requests.                                                                                                                                                                                                   |
| `402`  | No auth header at all (response body includes `authOptions` listing both supported auth paths), or out of credits with a valid auth header | If no auth: attach `Authorization: Bearer ...` or the x402 `X-Sign-In-With-X` header. If out of credits: with a Bearer key, fund the account (DIEM, USD, or dashboard top-up); with x402 auth, call `POST /api/v1/x402/top-up` directly. |
| `429`  | Rate limit hit (100 req/min standard, 1,000 req/min staff)                                                                                 | Honor `X-RateLimit-Reset` and back off. Batch up to 100 calls per request to amortize the limit.                                                                                                                                         |
| `5xx`  | Upstream RPC node hiccup                                                                                                                   | Retry with the same `Idempotency-Key` to avoid double-charging.                                                                                                                                                                          |

Per-item batch errors (e.g. invalid params on one of N calls) come back inside a `200 OK` response with a JSON-RPC `error` field on the offending item. Those items are billed at a flat 5 credits each.

## Not supported

These categories of methods are intentionally rejected:

* **WebSocket-only** (`eth_subscribe`, `eth_unsubscribe`): the proxy is HTTP-only. Poll instead.
* **Stateful filters** (`eth_newFilter`, `eth_getFilterChanges`, etc.): filter state is pinned to a single backend and breaks on a load-balanced proxy. Use `eth_getLogs` instead.
* **Key-holding methods** (`eth_sign`, `eth_accounts`, `eth_mining`): hosted providers don't hold user keys. Sign client-side and submit via `eth_sendRawTransaction`.
* **Unmapped methods**: anything not allowlisted returns `400`. Contact support to request additions.

## Resources

<CardGroup cols={2}>
  <Card title="Crypto RPC API Reference" icon="code" href="/api-reference/endpoint/crypto/rpc">
    Full method list, pricing, and response headers
  </Card>

  <Card title="Supported Networks" icon="link" href="/api-reference/endpoint/crypto/networks">
    Live list of supported network slugs
  </Card>

  <Card title="x402 Wallet Auth" icon="wallet" href="/guides/integrations/x402-venice-api">
    Authenticate and pay with a Base or Solana wallet
  </Card>

  <Card title="Autonomous Agent API Key" icon="robot" href="/guides/getting-started/generating-api-key-agent">
    Mint your own key by staking VVV
  </Card>

  <Card title="Postman Collection" icon="play" href="https://www.postman.com/veniceai/workspace/venice-ai-workspace/folder/38652128-2cf5a817-41cd-438b-ad37-5d07c3f13005?action=share&creator=48156591&active-environment=38652128-ef110f4e-d3e1-43b5-8029-4d6877e62041">
    27 ready-to-run Crypto RPC examples
  </Card>

  <Card title="Pricing" icon="coins" href="/overview/pricing">
    DIEM, credit pricing, and payment options
  </Card>
</CardGroup>
