JSON-RPC API
The JSON-RPC interface allows you to query Starknet data, send transactions, and perform contract calls without going through a formal transaction on-chain. Pathfinder currently supports multiple API versions and a distinct set of custom extensions.
Supported Versions
- Starknet v0.6.0
Accessible at the/rpc/v0_6
endpoint. - Starknet v0.7.0
Accessible at the/rpc/v0_7
endpoint. - Starknet v0.8.0-rc3
Accessible at the/rpc/v0_8
endpoint. - Pathfinder Extension
Exposed via/rpc/pathfinder/v0_1
.
The API served at the root path (/
for HTTP and /ws
for WebSocket) can be set via the --rpc.root-version
parameter (or RPC_ROOT_VERSION
environment variable).
API Endpoints and Usage
Below is a typical JSON-RPC request structure:
{
"jsonrpc": "2.0",
"method": "<method_name>",
"params": [...],
"id": 1
}
You’ll receive a response in a similar JSON-RPC 2.0 format containing result
or error
fields. For instance, to query the chain ID using v0.8:
curl -X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc":"2.0","method":"starknet_chainId","params":[],"id":1}' \
http://127.0.0.1:9545/rpc/v0_8
A successful response might look like this:
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x534e5f4d41494e"
}
Example: Calling a Contract Function
curl -X POST \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0",
"method":"starknet_call",
"params":[{
"request": {
"contract_address":"0x1234...",
"entry_point_selector":"0xabc...",
"calldata":[ "0x1", "0x2" ]
},
"block_id":"latest"
}],
"id":1
}' \
http://127.0.0.1:9545/rpc/v0_7
Pathfinder JSON Extensions
For advanced use cases like verifying storage proofs or generating special debug information, Pathfinder provides additional endpoints under:
/rpc/pathfinder/v0_1
The complete specification for these JSON-only extension methods can be found in the Pathfinder repository.