Substrate and Custom JSON-RPC Methods
RPCs are exposed as a method on a specific module. This signifies that once available, you can invoke any RPC via api.rpc.<module>.<method>(...params[])
. This is also applicable for accessing Ethereum RPCs using the Polkadot.js API, in the format of polkadotApi.rpc.eth.*
.
Certain methods accessible via the Polkadot.js API interface are also available as JSON-RPC endpoints on Tangle Network nodes. This section offers some examples; you can request a list of exposed RPC endpoints by invoking api.rpc.rpc.methods()
or the rpc_methods
endpoint indicated below.
Supported Ethereum methods
- eth_protocolVersion (opens in a new tab) — returns
1
by default - eth_syncing (opens in a new tab) — returns an object with data about the sync status or
false
- eth_hashrate (opens in a new tab) — returns
"0x0"
by default - eth_coinbase (opens in a new tab) — returns the latest block author. Not necessarily a finalized block
- eth_mining (opens in a new tab) — returns
false
by default - eth_chainId (opens in a new tab) — returns the chain ID used for signing at the current block
- eth_gasPrice (opens in a new tab) — returns the base fee per unit of gas used. This is currently the minimum gas price for each network
- eth_accounts (opens in a new tab) — returns a list of addresses owned by the client
- eth_blockNumber (opens in a new tab) — returns the highest available block number
- eth_getBalance (opens in a new tab) — returns the balance of the given address
- eth_getStorageAt (opens in a new tab) — returns content of the storage at a given address
- eth_getBlockByHash (opens in a new tab) — returns information about the block of the given hash including
baseFeePerGas
on post-London blocks - eth_getBlockByNumber (opens in a new tab) — returns information about the block specified by block number including
baseFeePerGas
on post-London blocks - eth_getTransactionCount (opens in a new tab) — returns the number of transactions sent from the given address (nonce)
- eth_getBlockTransactionCountByHash (opens in a new tab) — returns the number of transactions in a block with a given block hash
- eth_getBlockTransactionCountByNumber (opens in a new tab) — returns the number of transactions in a block with a given block number
- eth_getUncleCountByBlockHash (opens in a new tab) — returns
"0x0"
by default - eth_getUncleCountByBlockNumber (opens in a new tab) — returns
"0x0"
by default - eth_getCode (opens in a new tab) — returns the code at given address at given block number
- eth_sendTransaction (opens in a new tab) — creates new message call transaction or a contract creation, if the data field contains code. Returns the transaction hash, or the zero hash if the transaction is not yet available
- eth_sendRawTransaction (opens in a new tab) — creates new message call transaction or a contract creation for signed transactions. Returns the transaction hash, or the zero hash if the transaction is not yet available
- eth_call (opens in a new tab) — executes a new message call immediately without creating a transaction on the block chain, returning the value of the executed call
- eth_estimateGas (opens in a new tab) — returns an estimate amount of how much gas is necessary for a given transaction to succeed. You can optionally specify a
gasPrice
ormaxFeePerGas
andmaxPriorityFeePerGas
- eth_feeHistory (opens in a new tab) — returns
baseFeePerGas
,gasUsedRatio
,oldestBlock
, andreward
for a specified range of up to 1024 blocks - eth_getTransactionByHash (opens in a new tab) — returns the information about a transaction with a given hash. EIP-1559 transactions have
maxPriorityFeePerGas
andmaxFeePerGas
fields - eth_getTransactionByBlockHashAndIndex (opens in a new tab) — returns information about a transaction at a given block hash, and a given index position. EIP-1559 transactions have
maxPriorityFeePerGas
andmaxFeePerGas
fields - eth_getTransactionByBlockNumberAndIndex (opens in a new tab) — returns information about a transaction at a given block number, and a given index position. EIP-1559 transactions have
maxPriorityFeePerGas
andmaxFeePerGas
fields - eth_getTransactionReceipt (opens in a new tab) — returns the transaction receipt of a given transaction hash. After London support was added in runtime 1200, a new field named
effectiveGasPrice
has been added to the receipt, specifying the gas price of the transaction - eth_getUncleByBlockHashAndIndex (opens in a new tab) — returns
null
by default - eth_getUncleByBlockNumberAndIndex (opens in a new tab) — returns
null
by default - eth_getLogs (opens in a new tab) — returns an array of all logs matching a given filter object
- eth_getWork (opens in a new tab) — returns
["0x0","0x0","0x0"]
by default
Unsupported Ethereum Methods
- eth_submitWork (opens in a new tab) —not supported.
- eth_submitHashRate (opens in a new tab) - not supported.
More information will be added to this page.
Polkadot.js API Utility Functions
The Polkadot.js API also incorporates numerous utility libraries for computing frequently used cryptographic primitives and hash functions. You can view the full list at https://www.npmjs.com/package/@polkadot/util-crypto/v/0.32.19 (opens in a new tab).