This document provides information to developers who wish to work with StarkNet's node RPC API and are familiar with Ethereum's RPC API. The document focuses on existing APIs, specifically targeting distributed application developers.
As a general rule, the APIs are similar in naming, semantics and conventions. We generally follow the same methods used in Ethereum's node API and make changes where the technology requires it to maintain consistency.
Below you can find a summary of the changes, whether cross-cutting or method-specific. We also provide a mapping of methods.
We currently compare Ethereum 1.0 API, as defined here, and StarkNet's API.
Familiarity with Ethereum and StarkNet is assumed herein.
Some differences are more fundamental and manifest in different API methods.
Block and Transaction objects: Block and transaction objects have a somewhat different structure compared to Ethereum. These changes are mainly due to different network mechanics, e.g., no proof of work in StarkNet.
Block Tags: In some cases, the API refers to a block using relative tags that point to a block
in a specific position in the chain or state (latest, earliest, pending). Where applicable,
StarkNet allows referring only to the latest block, using the latest
tag.
Unless otherwise noted, the method names used are the same method names with a different prefix.
The eth
prefix is replaced with starknet
.
The fundamental data type in StarkNet is a field element. As a corollary, all resulting blocks and transactions' hashes are also field elements. When referring to a block/transaction type or an address, StarkNet uses a field element, not a 256-bit number.
The field element type in StarkNet is based on the field in the underlying Cairo VM.
In other words, a value x of a field element type is an integer in the range of 0≤x<P
. P
is currently defined as 2^251+17*2^192+1
We list below the methods in Ethereum's API and their corresponding StarkNet methods.
Ethereum Method | StarkNet Method | Differences From Ethereum |
---|---|---|
eth_blockNumber | starknet_blockNumber | Will return only the block number |
eth_chainId | starknet_chainId | |
eth_getBlockByNumber | starknet_getBlockByNumber |
|
eth_getBlockTransactionCountByHash | starknet_getBlockTransactionCountByHash |
|
eth_getBlockTransactionCountByNumber | starknet_getBlockTransactionCountByNumber |
|
eth_getTransactionByBlockHashAndIndex | starknet_getTransactionByBlockHashAndIndex | |
eth_getTransactionByBlockNumberAndIndex | starknet_getTransactionByBlockNumberAndIndex | |
eth_pendingTransactions | starknet_pendingTransactions |
|
eth_getBlockByHash | starknet_getBlockByHash |
|
eth_protocolVersion | starknet_protocolVersion | |
eth_syncing | starknet_syncing | |
eth_getStorageAt | starknet_getStorageAt |
|
eth_getTransactionByHash | starknet_getTransactionByHash |
|
eth_getTransactionReceipt | starknet_getTransactionReceipt |
|
eth_getCode | starknet_getCode |
|
eth_call | starknet_call |
|