Skip to main content

JSON-RPC API

Devnet also supports JSON-RPC API v0.3.0-rc1: specifications . It can be reached under /rpc. For an example:

Requests to rpc and devnet responses are automatically validated against JSON schema in runtime. In case of problems, this validations can be disabled by --disable-rpc-request-validation and --disable-rpc-response-validation run flags. If you encounter issues with validation, please report it on github.

POST /rpc
{
"jsonrpc": "2.0",
"method": "starknet_getBlockTransactionCount",
"params": {
"block_id": "latest"
},
"id": 0
}

Response:

{
"id": 0,
"jsonrpc": "2.0",
"result": 1
}

Trace API

Out of Starknet trace API RPC methods, only starknet_simulateTransaction (and starknet_simulateTransactions) is supported.

The official specification of starknet_simulateTransaction supports simulation_flags which can be SKIP_VALIDATE and SKIP_EXECUTE. At the moment, only SKIP_VALIDATE is supported. Dev info: SKIP_EXECUTE support is blocked by InternalInvokeFunctionForSimulate.create_for_simulate not supporting it. Return type FUNCTION_INVOCATION is modified according to suggestions by the Starkware team: code_address and call_type are replaced with class_hash.

starknet_getEvents

Disclaimer! JSON-RPC specifications are not completely in sync with those of gateway. While starknet_getEvents is supported for the pending block, the official schema does not allow the block hash and the block number in the response to be empty or anything other than a number. Since these values are undefined for the pending block and since they must be set to something, we decided to go with the compromise of setting them to zero-values.