EVM JSONRPC API
The default block parameter
The following methods have an optional extra defaultBlock
parameter:
When requests are made that act on the state of Ethereum, the last parameter determines the height of the block.
The following options are possible for the defaultBlock
parameter:
Quantity
/Integer
- an integer block number;String "earliest"
- for the earliest/genesis block;String "latest"
- for the latest mined block;
JSON-RPC methods
- eth_blockNumber
- eth_call
- eth_chainId
- eth_coinbase
- eth_estimateGas
- eth_getBalance
- eth_getBlockByNumber
- eth_getCode
- eth_getStorageAt
- eth_getTransactionByHash
- eth_getTransactionReceipt
JSON-RPC specific for EVM Bridge
JSON-RPC API Reference
eth_accounts
Returns a list of addresses owned by client.
Parameters
None
Returns
Array
- 20 Bytes - addresses owned by the client.
Example
Request
Response
eth_blockNumber
Returns the number of most recent block.
Parameters
None
Returns
Quantity
- integer of the current block number the client is on.
Example
Request
Response
eth_call
Executes a new message call immediately without creating a transaction on the block chain.
Parameters
Object
- The transaction call object.from
:Address
- (optional) 20 Bytes - The address the transaction is send from.to
:Address
- (optional when creating new contract) 20 Bytes - The address the transaction is directed to.gas
:Quantity
- (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.gasPrice
:Quantity
- (optional) Integer of the gas price used for each paid gas.value
:Quantity
- (optional) Integer of the value sent with this transaction.data
:Data
- (optional) 4 byte hash of the method signature followed by encoded parameters. For details see Ethereum Contract ABI.
Quantity
orTag
- (optional) Integer block number, or the string'latest'
,'earliest'
or'pending'
, see the default block parameter.
Returns
Data
- the return value of executed contract.
Example
Request
Response
eth_chainId
Returns the EIP155 chain ID used for transaction signing at the current best block. Null is returned if not available.
Parameters
None
Returns
Quantity
- EIP155 Chain ID, ornull
if not available.
Example
Request
Response
eth_estimateGas
Makes a call or transaction, which won't be added to the blockchain and returns the used gas, which can be used for estimating the used gas.
Parameters
Object
- Same as eth_call parameters, except that all properties are optional.from
:Address
- (optional) 20 Bytes - The address the transaction is send from.to
:Address
- (optional when creating new contract) 20 Bytes - The address the transaction is directed to.gas
:Quantity
- (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.gasPrice
:Quantity
- (optional) Integer of the gas price used for each paid gas.value
:Quantity
- (optional) Integer of the value sent with this transaction.data
:Data
- (optional) 4 byte hash of the method signature followed by encoded parameters. For details see Ethereum Contract ABI.
Quantity
orTag
- (optional) Integer block number, or the string'latest'
,'earliest'
or'pending'
, see the default block parameter.
Returns
Quantity
- The amount of gas used.
Example
Request
Response
eth_gasPrice
Returns the current price per gas in wei.
Parameters
None
Returns
Quantity
- integer of the current gas price in wei.
Example
Request
Response
eth_getBalance
Returns the balance of the account of given address.
Parameters
Address
- 20 Bytes - address to check for balance.Quantity
orTag
- (optional) integer block number, or the string'latest'
,'earliest'
or'pending'
, see the default block parameter.
Returns
Quantity
- integer of the current balance in wei.
Example
Request
Response
eth_getBlockByNumber
Returns information about a block by block number.
Parameters
Quantity
orTag
- integer of a block number, or the string'earliest'
,'latest'
or'pending'
, as in the default block parameter.Boolean
- Iftrue
it returns the full transaction objects, iffalse
only the hashes of the transactions.
Returns
Object
- A block object, ornull
when no block was found.number
:Quantity
- The block number.null
when its pending blockhash
:Hash
- 32 Bytes - hash of the block.null
when its pending blockparentHash
:Hash
- 32 Bytes - hash of the parent blockauthor
:Address
- 20 Bytes - the address of the author of the block (the beneficiary to whom the mining rewards were given)miner
:Address
- 20 Bytes - alias of 'author'gasLimit
:Quantity
- the maximum gas allowed in this blockgasUsed
:Quantity
- the total used gas by all transactions in this blocktimestamp
:Quantity
- the unix timestamp for when the block was collatedtransactions
:Array
- Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter
Example
Request
Response
eth_getBlockTransactionCountByHash
Returns the number of transactions in a block from a block matching the given block hash.
Parameters
Hash
- 32 Bytes - hash of a block.
Returns
Quantity
- integer of the number of transactions in this block.
Example
Request
Response
eth_getStorageAt
Returns the value from a storage position at a given address.
Parameters
Address
- 20 Bytes - address of the storage.Quantity
- integer of the position in the storage.Quantity
orTag
- (optional) integer block number, or the string'latest'
,'earliest'
or'pending'
, see the default block parameter.
Returns
Data
- the value at this storage position.
Example
Request
Response
eth_getTransactionByHash
Returns the information about a transaction requested by transaction hash.
Parameters
Hash
- 32 Bytes - hash of a transaction.
Returns
Object
- A transaction object, ornull
when no transaction was found:hash
:Hash
- 32 Bytes - hash of the transaction.nonce
:Quantity
- the number of transactions made by the sender prior to this one.blockHash
:Hash
- 32 Bytes - hash of the block where this transaction was in.null
when its pending.blockNumber
:Quantity
orTag
- block number where this transaction was in.null
when its pending.transactionIndex
:Quantity
- integer of the transactions index position in the block.null
when its pending.from
:Address
- 20 Bytes - address of the sender.to
:Address
- 20 Bytes - address of the receiver.null
when its a contract creation transaction.value
:Quantity
- value transferred in Wei.gasPrice
:Quantity
- gas price provided by the sender in Wei.gas
:Quantity
- gas provided by the sender.input
:Data
- the data send along with the transaction.v
:Quantity
- the standardised V field of the signature.standardV
:Quantity
- the standardised V field of the signature (0 or 1).r
:Quantity
- the R field of the signature.raw
:Data
- raw transaction datapublicKey
:Hash
- public key of the signer.chainId
:Quantity
- the chain id of the transaction, if any.creates
:Hash
- creates contract hashcondition
:Object
- (optional) conditional submission, Block number inblock
or timestamp intime
ornull
.
Example
Request
Response
eth_getTransactionCount
Returns the number of transactions sent from an address.
Parameters
Address
- 20 Bytes - address.Quantity
orTag
- (optional) integer block number, or the string'latest'
,'earliest'
or'pending'
, see the default block parameter.
Returns
Quantity
- integer of the number of transactions send from this address.
Example
Request
Response
eth_getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
Note That the receipt is available even for pending transactions.
Parameters
Hash
- hash of a transaction.
Returns
Object
- A transaction receipt object, ornull
when no receipt was found:blockHash
:Hash
- 32 Bytes - hash of the block where this transaction was in.blockNumber
:Quantity
orTag
- block number where this transaction was in.contractAddress
:Address
- 20 Bytes - The contract address created, if the transaction was a contract creation, otherwisenull
.cumulativeGasUsed
:Quantity
- The total amount of gas used when this transaction was executed in the block.from
:Address
- 20 Bytes - The address of the sender.to
:Address
- 20 Bytes - The address of the receiver. null when it’s a contract creation transaction.gasUsed
:Quantity
- The amount of gas used by this specific transaction alone.logs
:Array
- Array of log objects, which this transaction generated.logsBloom
:Hash
- 256 Bytes - A bloom filter of logs/events generated by contracts during transaction execution. Used to efficiently rule out transactions without expected logs.root
:Hash
- 32 Bytes - Merkle root of the state trie after the transaction has been executed (optional after Byzantium hard fork EIP609)status
:Quantity
-0x0
indicates transaction failure ,0x1
indicates transaction success. Set for blocks mined after Byzantium hard fork EIP609,null
before.transactionHash
:Hash
- 32 Bytes - hash of the transaction.transactionIndex
:Quantity
- Integer of the transactions index position in the block.
Example
Request
Response
eth_sendRawTransaction
Creates new message call transaction or a contract creation for signed transactions.
Note: eth_submitTransaction
is an alias of this method.
Parameters
Data
- The signed transaction data.
Returns
Hash
- 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available
Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.
Example
Request
Response
eth_sendTransaction
Creates new message call transaction or a contract creation, if the data field contains code.
Parameters
Object
- The transaction object.from
:Address
- 20 Bytes - The address the transaction is send from.to
:Address
- (optional) 20 Bytes - The address the transaction is directed to.gas
:Quantity
- (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.gasPrice
:Quantity
- (optional) Integer of the gas price used for each paid gas.value
:Quantity
- (optional) Integer of the value sent with this transaction.data
:Data
- (optional) 4 byte hash of the method signature followed by encoded parameters. For details see Ethereum Contract ABI.nonce
:Quantity
- (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.condition
:Object
- (optional) Conditional submission of the transaction. Can be either an integer block number{ block: 1 }
or UTC timestamp (in seconds){ time: 1491290692 }
ornull
.
Returns
Hash
- 32 Bytes - the transaction hash, or the zero hash if the transaction is not yet available.
Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.
Example
Request
Response
eth_sign
The sign method calculates an Ethereum specific signature with: sign(keccak256("Ethereum Signed Message:
" + len(message) + message)))
.
Parameters
Address
- 20 Bytes - address.Data
- Data which hash to sign.
Returns
Data
- Signed data.
Example
Request
Response
eth_signTransaction
Signs transactions without dispatching it to the network. It can be later submitted using eth_sendRawTransaction.
Parameters
Object
- Transaction object, see eth_sendTransaction.from
:Address
- 20 Bytes - The address the transaction is send from.to
:Address
- (optional) 20 Bytes - The address the transaction is directed to.gas
:Quantity
- (optional) Integer of the gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions.gasPrice
:Quantity
- (optional) Integer of the gas price used for each paid gas.value
:Quantity
- (optional) Integer of the value sent with this transaction.data
:Data
- (optional) 4 byte hash of the method signature followed by encoded parameters. For details see Ethereum Contract ABI.nonce
:Quantity
- (optional) Integer of a nonce. This allows to overwrite your own pending transactions that use the same nonce.condition
:Object
- (optional) Conditional submission of the transaction. Can be either an integer block number{ block: 1 }
or UTC timestamp (in seconds){ time: 1491290692 }
ornull
.
Returns
Object
- Signed transaction and it's details:raw
:Data
- The signed, RLP encoded transaction.tx
:Object
- Transaction object:hash
:Hash
- 32 Bytes - hash of the transaction.nonce
:Quantity
- the number of transactions made by the sender prior to this one.blockHash
:Hash
- 32 Bytes - hash of the block where this transaction was in.null
when its pending.blockNumber
:Quantity
orTag
- block number where this transaction was in.null
when its pending.transactionIndex
:Quantity
- integer of the transactions index position in the block.null
when its pending.from
:Address
- 20 Bytes - address of the sender.to
:Address
- 20 Bytes - address of the receiver.null
when its a contract creation transaction.value
:Quantity
- value transferred in Wei.gasPrice
:Quantity
- gas price provided by the sender in Wei.gas
:Quantity
- gas provided by the sender.input
:Data
- the data send along with the transaction.v
:Quantity
- the standardised V field of the signature.standard_v
:Quantity
- the standardised V field of the signature (0 or 1).r
:Quantity
- the R field of the signature.raw
:Data
- raw transaction datapublicKey
:Hash
- public key of the signer.chainId
:Quantity
- the chain id of the transaction, if any.creates
:Hash
- creates contract hashcondition
:Object
- (optional) conditional submission, Block number inblock
or timestamp intime
ornull
.
Example
Request
Response