# JSON-RPC

> Source: https://docs.blockvectra.com/de/api/json-rpc/

## Übersicht

Alle Anfragen werden in **Compute Units (CU)** erfasst und unterliegen Ratenlimits pro API-Schlüssel.

* **Endpunkt**: `POST /v1/{chain}/{api_key}` (Schlüssel im Pfad) oder `POST /v1/{chain}` (Schlüssel im Header). Für Robinhood Chain lautet `{chain}` `robinhood_mainnet`: `https://api.blockvectra.com/v1/robinhood_mainnet`. Derselbe [API-Schlüssel](https://docs.blockvectra.com/de/quickstart/#1-get-an-api-key) funktioniert auf jeder unterstützten Chain
* **Protokoll**: HTTP `POST`, Einzelaufruf oder Batch
* **Messung**: Die gesamten CU-Kosten einer Anfrage werden unmittelbar nach deren Eintreffen auf die Burst-Kapazität Ihres Schlüssels angerechnet. Jeder angenommene Aufruf, der eine Antwort erhält, wird mit dem veröffentlichten CU-Gewicht der Methode abgerechnet; die [Fehlerreferenz](https://docs.blockvectra.com/de/errors/) führt die Fälle auf, die nicht in Rechnung gestellt werden. Die Abrechnung erfolgt stündlich (abgerundet auf ganze Einheiten, der Restbetrag wird übertragen, Verrechnung ca. 15 Minuten nach Ende des Zeitraums)
* **Ethereum**: Eigene Methodenliste und ein durch `state_window_blocks` bestimmtes Statusfenster — siehe [Unterstützte Chains → Ethereum](https://docs.blockvectra.com/de/chains/#ethereum).

Vollständige Parameterschemata, Methodensignaturen und interaktive Anfragetests für alle Methoden finden Sie in der [Vollständigen Referenz](https://docs.blockvectra.com/de/api/json-rpc/reference/). Informationen zur Pfadversionierung, Abwärtskompatibilitätsregeln und SDK-Empfehlungen finden Sie unter [API-Versionierung und Kompatibilität](https://docs.blockvectra.com/de/api/versioning/).

Um einen API-Schlüssel zu erhalten und eine erste Anfrage zu senden, lesen Sie den [Schnellstart](https://docs.blockvectra.com/de/quickstart/); dieser behandelt auch die Schlüsselübergabe und Batch-Anfragen.

## Häufige Aufrufe

Ausführliche Beispiele für häufige Aufrufe.

### Logs abfragen (`eth_getLogs`)

Filtern Sie die Logs eines Vertrages über einen aktuellen Blockbereich — hier das ERC-20-Ereignis `Transfer` (Topic `0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef`). Siehe die Tabelle [CU-Abrechnungsregeln](#cu-metering-rules) unten für das aktuelle CU-Gewicht von `eth_getLogs`; ein Bereich, der größer als `max_logs_block_range` der Chain ist (aus `GET /v1/chains`), wird mit `-32602` abgelehnt.

**cURL**

```bash
export BLOCKVECTRA_API_KEY=rgw_your_api_key

curl -X POST "https://api.blockvectra.com/v1/robinhood_mainnet" \
  -H 'Content-Type: application/json' \
  -H "x-api-key: $BLOCKVECTRA_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "method": "eth_getLogs",
    "params": [{
      "fromBlock": "0x45a2409",
      "toBlock": "0x45a2609",
      "address": "0x1111111111111111111111111111111111111111",
      "topics": ["0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"]
    }],
    "id": 1
  }'
```


  **TypeScript**

```ts
// npx tsx example.mts
import { createPublicClient, http } from 'viem'

const apiKey = process.env.BLOCKVECTRA_API_KEY!
const client = createPublicClient({
  transport: http('https://api.blockvectra.com/v1/robinhood_mainnet', { fetchOptions: { headers: { 'x-api-key': apiKey } } }),
})

const TRANSFER_TOPIC = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef'
const latest = await client.getBlockNumber()

const logs = await client.getLogs({
  address: '0x1111111111111111111111111111111111111111',
  topics: [TRANSFER_TOPIC],
  fromBlock: latest > 100n ? latest - 100n : 0n,
  toBlock: latest,
})
console.log(logs.length)
```


  **Python**

```python
# uv run --with web3 python example.py
import os
from web3 import Web3

api_key = os.environ["BLOCKVECTRA_API_KEY"]
w3 = Web3(
    Web3.HTTPProvider(
        "https://api.blockvectra.com/v1/robinhood_mainnet",
        request_kwargs={"headers": {"Content-Type": "application/json", "x-api-key": api_key}},
    )
)

TRANSFER_TOPIC = "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef"
latest = w3.eth.block_number

logs = w3.eth.get_logs(
    {
        "address": "0x1111111111111111111111111111111111111111",
        "topics": [TRANSFER_TOPIC],
        "fromBlock": max(latest - 100, 0),
        "toBlock": latest,
    }
)
print(len(logs))
```


  **Go**

```go
// go mod init example && go get github.com/ethereum/go-ethereum && go mod tidy && go run .
package main

import (
	"context"
	"fmt"
	"log"
	"math/big"
	"os"

	"github.com/ethereum/go-ethereum"
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/ethclient"
	"github.com/ethereum/go-ethereum/rpc"
)

var transferTopic = common.HexToHash(
	"0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef",
)

func main() {
	apiKey := os.Getenv("BLOCKVECTRA_API_KEY")
	ctx := context.Background()

	rpcClient, err := rpc.DialOptions(ctx, "https://api.blockvectra.com/v1/robinhood_mainnet", rpc.WithHeader("x-api-key", apiKey))
	if err != nil {
		log.Fatal(err)
	}
	client := ethclient.NewClient(rpcClient)

	latest, err := client.BlockNumber(ctx)
	if err != nil {
		log.Fatal(err)
	}
	from := uint64(0)
	if latest > 100 {
		from = latest - 100
	}

	address := common.HexToAddress("0x1111111111111111111111111111111111111111")
	logs, err := client.FilterLogs(ctx, ethereum.FilterQuery{
		FromBlock: new(big.Int).SetUint64(from),
		ToBlock:   new(big.Int).SetUint64(latest),
		Addresses: []common.Address{address},
		Topics:    [][]common.Hash{{transferTopic}},
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(len(logs))
}
```


  **Rust**

Zu `Cargo.toml` hinzufügen:

```toml
[dependencies]
alloy = { version = "1", features = ["provider-http", "rpc-types"] }
tokio = { version = "1", features = ["full"] }
eyre = "0.6"
reqwest = { version = "0.13", default-features = false }
```

```rust
// cargo run
use alloy::primitives::{address, b256};
use alloy::providers::{Provider, ProviderBuilder};
use alloy::rpc::types::Filter;

const TRANSFER_TOPIC: alloy::primitives::B256 =
    b256!("ddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef");

#[tokio::main]
async fn main() -> eyre::Result<()> {
    let api_key = std::env::var("BLOCKVECTRA_API_KEY").unwrap_or_default();
    let rpc_url: reqwest::Url = "https://api.blockvectra.com/v1/robinhood_mainnet".parse()?;

    let mut headers = reqwest::header::HeaderMap::new();
    headers.insert("x-api-key", api_key.parse()?);
    let http_client = reqwest::Client::builder().default_headers(headers).build()?;

    let provider = ProviderBuilder::new().connect_reqwest(http_client, rpc_url);

    let latest = provider.get_block_number().await?;
    let from = latest.saturating_sub(100);

    let filter = Filter::new()
        .address(address!("1111111111111111111111111111111111111111"))
        .event_signature(TRANSFER_TOPIC)
        .from_block(from)
        .to_block(latest);

    let logs = provider.get_logs(&filter).await?;
    println!("{}", logs.len());

    Ok(())
}
```


### Eine Transaktion nachverfolgen (`debug_traceTransaction`)

Verfolgen Sie die internen Aufrufe einer Transaktion mit dem `callTracer`. Siehe die Tabelle [CU-Abrechnungsregeln](#cu-metering-rules) unten für das aktuelle CU-Gewicht von `debug_traceTransaction`. Wie die anderen Status-Lese-Methoden wird sie abgelehnt, sobald der Zielblock außerhalb des aktuellen Statusfensters dieser Chain liegt (`-32011`). Die Fenstergröße entspricht `state_window_blocks` der Chain (aus `GET /v1/chains`). Auf Chains, die Traces bereitstellen, nutzen Sie die [Data API](https://docs.blockvectra.com/de/api/data/) für historische Traces.

**cURL**

```bash
export BLOCKVECTRA_API_KEY=rgw_your_api_key

curl -X POST "https://api.blockvectra.com/v1/robinhood_mainnet" \
  -H 'Content-Type: application/json' \
  -H "x-api-key: $BLOCKVECTRA_API_KEY" \
  -d '{
    "jsonrpc": "2.0",
    "method": "debug_traceTransaction",
    "params": ["0xYOUR_TRANSACTION_HASH", {"tracer": "callTracer"}],
    "id": 1
  }'
```


  **TypeScript**

```ts
// npx tsx example.mts
import { createPublicClient, http } from 'viem'

const apiKey = process.env.BLOCKVECTRA_API_KEY!
const client = createPublicClient({
  transport: http('https://api.blockvectra.com/v1/robinhood_mainnet', { fetchOptions: { headers: { 'x-api-key': apiKey } } }),
})

const txHash = '0xYOUR_TRANSACTION_HASH'
const trace = await client.request({
  method: 'debug_traceTransaction' as any,
  params: [txHash, { tracer: 'callTracer' }] as any,
})
console.log(trace)
```


  **Python**

```python
# uv run --with web3 python example.py
import os
from web3 import Web3

api_key = os.environ["BLOCKVECTRA_API_KEY"]
w3 = Web3(
    Web3.HTTPProvider(
        "https://api.blockvectra.com/v1/robinhood_mainnet",
        request_kwargs={"headers": {"Content-Type": "application/json", "x-api-key": api_key}},
    )
)

tx_hash = "0xYOUR_TRANSACTION_HASH"
trace = w3.manager.request_blocking(
    "debug_traceTransaction", [tx_hash, {"tracer": "callTracer"}]
)
print(trace)
```


  **Go**

```go
// go mod init example && go get github.com/ethereum/go-ethereum && go mod tidy && go run .
package main

import (
	"context"
	"encoding/json"
	"fmt"
	"log"
	"os"

	"github.com/ethereum/go-ethereum/rpc"
)

func main() {
	apiKey := os.Getenv("BLOCKVECTRA_API_KEY")
	ctx := context.Background()

	client, err := rpc.DialOptions(ctx, "https://api.blockvectra.com/v1/robinhood_mainnet", rpc.WithHeader("x-api-key", apiKey))
	if err != nil {
		log.Fatal(err)
	}

	txHash := "0xYOUR_TRANSACTION_HASH"
	var trace json.RawMessage
	err = client.CallContext(ctx, &trace, "debug_traceTransaction", txHash, map[string]string{
		"tracer": "callTracer",
	})
	if err != nil {
		log.Fatal(err)
	}
	fmt.Println(string(trace))
}
```


  **Rust**

Zu `Cargo.toml` hinzufügen:

```toml
[dependencies]
alloy = { version = "1", features = ["provider-http", "rpc-types"] }
tokio = { version = "1", features = ["full"] }
eyre = "0.6"
reqwest = { version = "0.13", default-features = false }
serde_json = "1"
```

```rust
// cargo run
use alloy::providers::{Provider, ProviderBuilder};
use serde_json::json;

#[tokio::main]
async fn main() -> eyre::Result<()> {
    let api_key = std::env::var("BLOCKVECTRA_API_KEY").unwrap_or_default();
    let rpc_url: reqwest::Url = "https://api.blockvectra.com/v1/robinhood_mainnet".parse()?;

    let mut headers = reqwest::header::HeaderMap::new();
    headers.insert("x-api-key", api_key.parse()?);
    let http_client = reqwest::Client::builder().default_headers(headers).build()?;

    let provider = ProviderBuilder::new().connect_reqwest(http_client, rpc_url);

    let tx_hash = "0xYOUR_TRANSACTION_HASH";
    let trace: serde_json::Value = provider
        .client()
        .request("debug_traceTransaction", (tx_hash, json!({ "tracer": "callTracer" })))
        .await?;
    println!("{trace}");

    Ok(())
}
```


## CU-Abrechnungsregeln

Compute-Unit-Gewichtung (CU) für jede JSON-RPC-Methode.

| Methode | Gewichtung (CU) |
| --- | --- |
| `eth_blockNumber` | 1 |
| `eth_chainId` | 1 |
| `eth_getBlockByNumber` | 5 |
| `eth_blobBaseFee` | 10 |
| `eth_feeHistory` | 10 |
| `eth_gasPrice` | 10 |
| `eth_getBalance` | 10 |
| `eth_getBlockByHash` | 10 |
| `eth_getBlockReceipts` | 10 |
| `eth_getBlockTransactionCountByHash` | 10 |
| `eth_getBlockTransactionCountByNumber` | 10 |
| `eth_getCode` | 10 |
| `eth_getHeaderByHash` | 10 |
| `eth_getHeaderByNumber` | 10 |
| `eth_getProof` | 10 |
| `eth_getRawTransactionByBlockHashAndIndex` | 10 |
| `eth_getRawTransactionByBlockNumberAndIndex` | 10 |
| `eth_getRawTransactionByHash` | 10 |
| `eth_getStorageAt` | 10 |
| `eth_getTransactionByBlockHashAndIndex` | 10 |
| `eth_getTransactionByBlockNumberAndIndex` | 10 |
| `eth_getTransactionByHash` | 10 |
| `eth_getTransactionCount` | 10 |
| `eth_getTransactionReceipt` | 10 |
| `eth_getUncleByBlockHashAndIndex` | 10 |
| `eth_getUncleByBlockNumberAndIndex` | 10 |
| `eth_getUncleCountByBlockHash` | 10 |
| `eth_getUncleCountByBlockNumber` | 10 |
| `eth_maxPriorityFeePerGas` | 10 |
| `eth_syncing` | 10 |
| `net_version` | 10 |
| `web3_clientVersion` | 10 |
| `web3_sha3` | 10 |
| `eth_call` | 15 |
| `eth_createAccessList` | 20 |
| `eth_estimateGas` | 20 |
| `eth_simulateV1` | 20 |
| `eth_getLogs` | 30 |
| `eth_sendRawTransaction` | 30 |
| `debug_traceBlockByHash` | 100 |
| `debug_traceBlockByNumber` | 100 |
| `debug_traceCall` | 100 |
| `debug_traceTransaction` | 100 |
| `trace_block` | 100 |
| `trace_call` | 100 |
| `trace_get` | 100 |
| `trace_replayTransaction` | 100 |
| `trace_transaction` | 100 |

## Methodenrichtlinie

Verfügbare Methoden variieren je nach Chain; die Liste jeder Chain ist unten dargestellt, und [Unterstützte Chains](https://docs.blockvectra.com/de/chains/) deckt den Rest ab. Nur Methoden, die einem erlaubten Namen oder Muster entsprechen, sind erreichbar; jede andere Methode gibt `-32601 method not available` zurück.

**Auf jeder der folgenden Chains zulässig:**

- `eth_blockNumber`
- `eth_call`
- `eth_chainId`
- `eth_estimateGas`
- `eth_feeHistory`
- `eth_gasPrice`
- `eth_getBalance`
- `eth_getBlockByHash`
- `eth_getBlockByNumber`
- `eth_getBlockReceipts`
- `eth_getBlockTransactionCountByHash`
- `eth_getBlockTransactionCountByNumber`
- `eth_getCode`
- `eth_getLogs`
- `eth_getStorageAt`
- `eth_getTransactionByBlockHashAndIndex`
- `eth_getTransactionByBlockNumberAndIndex`
- `eth_getTransactionByHash`
- `eth_getTransactionCount`
- `eth_getTransactionReceipt`
- `eth_maxPriorityFeePerGas`
- `eth_syncing`
- `net_version`
- `web3_clientVersion`

### Arbitrum One

eth_getLogs maximaler Blockbereich: 1,000 Blöcke; Statusfenster: 6,000 Blöcke

**Ebenfalls zulässig:**

- `debug_traceBlockByHash`
- `debug_traceBlockByNumber`
- `debug_traceCall`
- `debug_traceTransaction`
- `eth_blobBaseFee`
- `eth_createAccessList`
- `eth_getHeaderByHash`
- `eth_getHeaderByNumber`
- `eth_getProof`
- `eth_getRawTransactionByBlockHashAndIndex`
- `eth_getRawTransactionByBlockNumberAndIndex`
- `eth_getRawTransactionByHash`
- `eth_getUncleByBlockHashAndIndex`
- `eth_getUncleByBlockNumberAndIndex`
- `eth_getUncleCountByBlockHash`
- `eth_getUncleCountByBlockNumber`
- `eth_sendRawTransaction`
- `eth_simulateV1`
- `web3_sha3`

### Base

eth_getLogs maximaler Blockbereich: 1,000 Blöcke; Statusfenster: 10,000 Blöcke

**Ebenfalls zulässig:**

- `eth_blobBaseFee`
- `eth_createAccessList`
- `eth_getProof`
- `eth_simulateV1`
- `eth_getRawTransactionByHash`
- `eth_getRawTransactionByBlockHashAndIndex`
- `eth_getRawTransactionByBlockNumberAndIndex`
- `eth_getUncleCountByBlockNumber`
- `eth_getUncleCountByBlockHash`
- `eth_getUncleByBlockNumberAndIndex`
- `eth_getUncleByBlockHashAndIndex`
- `eth_getHeaderByNumber`
- `eth_getHeaderByHash`
- `eth_sendRawTransaction`
- `web3_sha3`

### BNB Smart Chain

eth_getLogs maximaler Blockbereich: 1,000 Blöcke; Statusfenster: 100 Blöcke

**Ebenfalls zulässig:**

- `eth_sendRawTransaction`

### Ethereum

eth_getLogs maximaler Blockbereich: 1,000 Blöcke; Statusfenster: 250,000 Blöcke

**Ebenfalls zulässig:**

- `debug_traceBlockByHash`
- `debug_traceBlockByNumber`
- `debug_traceCall`
- `debug_traceTransaction`
- `eth_blobBaseFee`
- `eth_createAccessList`
- `eth_getProof`
- `eth_sendRawTransaction`
- `trace_block`
- `trace_call`
- `trace_get`
- `trace_replayTransaction`
- `trace_transaction`
- `web3_sha3`

### Ethereum Sepolia

eth_getLogs maximaler Blockbereich: 1,000 Blöcke; Statusfenster: —

**Ebenfalls zulässig:**

- `eth_blobBaseFee`
- `eth_createAccessList`
- `eth_getProof`
- `eth_sendRawTransaction`
- `web3_sha3`

### HyperEVM

Das Senden von Transaktionen wird auf dieser Chain noch nicht unterstützt (`eth_sendRawTransaction` gibt `-32601` `method_not_allowed` zurück); Lesemethoden funktionieren normal.

eth_getLogs maximaler Blockbereich: 1,000 Blöcke; Statusfenster: —

### Polygon

eth_getLogs maximaler Blockbereich: 1,000 Blöcke; Statusfenster: 126 Blöcke

**Ebenfalls zulässig:**

- `debug_traceBlockByHash`
- `debug_traceBlockByNumber`
- `debug_traceCall`
- `debug_traceTransaction`
- `eth_blobBaseFee`
- `eth_createAccessList`
- `eth_getHeaderByHash`
- `eth_getHeaderByNumber`
- `eth_getProof`
- `eth_getRawTransactionByBlockHashAndIndex`
- `eth_getRawTransactionByBlockNumberAndIndex`
- `eth_getRawTransactionByHash`
- `eth_getUncleByBlockHashAndIndex`
- `eth_getUncleByBlockNumberAndIndex`
- `eth_getUncleCountByBlockHash`
- `eth_getUncleCountByBlockNumber`
- `eth_sendRawTransaction`
- `eth_simulateV1`
- `web3_sha3`

### Robinhood Chain

eth_getLogs maximaler Blockbereich: 1,000 Blöcke; Statusfenster: 900 Blöcke

**Ebenfalls zulässig:**

- `eth_blobBaseFee`
- `eth_createAccessList`
- `eth_getProof`
- `eth_simulateV1`
- `eth_getRawTransactionByHash`
- `eth_getRawTransactionByBlockHashAndIndex`
- `eth_getRawTransactionByBlockNumberAndIndex`
- `eth_getUncleCountByBlockNumber`
- `eth_getUncleCountByBlockHash`
- `eth_getUncleByBlockNumberAndIndex`
- `eth_getUncleByBlockHashAndIndex`
- `eth_getHeaderByNumber`
- `eth_getHeaderByHash`
- `eth_sendRawTransaction`
- `web3_sha3`
- `debug_traceTransaction`
- `debug_traceCall`
- `debug_traceBlockByNumber`
- `debug_traceBlockByHash`

### Robinhood Chain Testnet

eth_getLogs maximaler Blockbereich: 1,000 Blöcke; Statusfenster: 1,023 Blöcke

**Ebenfalls zulässig:**

- `debug_traceBlockByHash`
- `debug_traceBlockByNumber`
- `debug_traceCall`
- `debug_traceTransaction`
- `eth_blobBaseFee`
- `eth_createAccessList`
- `eth_getHeaderByHash`
- `eth_getHeaderByNumber`
- `eth_getProof`
- `eth_getRawTransactionByBlockHashAndIndex`
- `eth_getRawTransactionByBlockNumberAndIndex`
- `eth_getRawTransactionByHash`
- `eth_getUncleByBlockHashAndIndex`
- `eth_getUncleByBlockNumberAndIndex`
- `eth_getUncleCountByBlockHash`
- `eth_getUncleCountByBlockNumber`
- `eth_sendRawTransaction`
- `eth_simulateV1`
- `web3_sha3`

**Limits**:

* **Batch**: maximal 100 Aufrufe pro Anfrage; zudem durch den CU-Burst des API-Schlüssels begrenzt, siehe unten.
* **Request-Body**: maximal 2 MiB
* **CU-Burst**: Jeder API-Schlüssel verfügt über einen CU-Bucket (`cu_per_sec` Wiederauffüllung, `burst_cu` Kapazität — Standardwerte sind 400 CU/s und Burst 1,600 CU; pro API-Schlüssel in der Konsole in der Tabelle Keys aufgeführt). Eine einzelne Anfrage — einschließlich eines gesamten JSON-RPC-Batches —, deren gesamte CU die Burst-Kapazität des API-Schlüssels überschreitet, wird mit `-32022 request_exceeds_burst` (`request cost <N> CU exceeds burst capacity <M> CU`) abgelehnt; teilen Sie diese in kleinere Batches auf.

## Fehlercodes

Siehe die [Fehlerreferenz](https://docs.blockvectra.com/de/errors/) für alle Fehlercodes, ob sie abgerechnet werden und was zu tun ist.

## Vollständige OpenAPI-Referenz

Siehe die [Vollständige OpenAPI-Referenz](https://docs.blockvectra.com/de/api/json-rpc/reference/) für die vollständige maschinenlesbare Spezifikation mit allen Methodensignaturen, Anfrage- und Antwortschemata sowie interaktiv gerenderten Parameterdetails.
