Atlas JSON RPC
默認塊參數
以下方法有一個額外的默認塊參數:
當發出對以太坊狀態起作用的請求時,最後一個默認塊參數決定了塊的高度。
defaultBlock 參數可以使用以下選項:
HEX String
- 整數塊號String "earliest"
代表最早/創世區塊String "latest"
- 最新開采的區塊String "pending"
- 用於待定狀態/交易
web3
web3_clientVersion
返回當前客戶端版本。
參數
none
返回
String
- The current client version.
示例
web3_sha3
返回 Keccak-256 (not the standardized SHA3-256) of the given data.
參數
DATA
- the data to convert into a SHA3 hash.
示例 參數
返回
DATA
- The SHA3 result of the given string.
示例
net
net_version
Returns the current network id.
參數
none
返回
String
- The current network id.
"22776"
: Mainnet"212"
: Testnet"213"
: Devnet
示例
net_listening
Returns true
if client is actively listening for network connections.
參數
none
返回
Boolean
- true
when listening, otherwise false
.
示例
net_peerCount
Returns number of peers currently connected to the client.
參數
none
返回
QUANTITY
- integer of the number of connected peers.
示例
eth
eth_gasPrice
Returns the current price per gas in wei.
參數
none
返回
QUANTITY
- integer of the current gas price in wei.
示例
eth_maxPriorityFeePerGas
Returns a fee per gas that is an estimate of how much you can pay as a priority fee, or "tip", to get a transaction included in the current block.
參數
none
返回
QUANTITY
- the estimated priority fee per gas.
示例
eth_syncing
Returns an object with data about the sync status or false
.
參數
none
返回
Object|Boolean
, An object with sync status data or FALSE
, when not syncing:
startingBlock
:QUANTITY
- The block at which the import started (will only be reset, after the sync reached his head)currentBlock
:QUANTITY
- The current block, same as eth_blockNumberhighestBlock
:QUANTITY
- The estimated highest blockpulledStates
:String
-already complete stateknownStates
:String
-already know state
startingBlock: QUANTITY - The block at which the import started (will only be reset, after the sync reached his head) currentBlock: QUANTITY - The current block, same as eth_blockNumber highestBlock: QUANTITY - The estimated highest block
示例
eth_accounts
Returns a list of addresses owned by client.
參數
none
返回
Array of DATA
, 20 Bytes - addresses owned by the client.
示例
eth_blockNumber
Returns the number of most recent block.
參數
none
返回
QUANTITY
- integer of the current block number the client is on.
示例
eth_getBalance
Returns the balance of the account of given address.
參數
DATA, 20 Bytes - address to check for balance. QUANTITY|TAG - integer block number, or the string "latest", "earliest" or "pending", see the default block parameter.
返回
QUANTITY
- integer of the current block number the client is on.
示例
eth_getBlockByNumber
Returns information about a block by block number.
參數
QUANTITY|TAG
- integer of a block number, or the string "earliest", "latest" or "pending", as in the default block parameter. Boolean
- If true it returns the full transaction objects, if false only the hashes of the transactions.
返回
Object
- A block object, or null when no block was found: - number
: QUANTITY - the block number. null when its pending block. - hash
: DATA, 32 Bytes - hash of the block. null when its pending block. - parentHash
: DATA, 32 Bytes - hash of the parent block. - nonce
: DATA, 8 Bytes - hash of the generated proof-of-work. null when its pending block. - logsBloom
: DATA, 256 Bytes - the bloom filter for the logs of the block. null when its pending block. - transactionsRoot
: DATA, 32 Bytes - the root of the transaction trie of the block. - stateRoot
: DATA, 32 Bytes - the root of the final state trie of the block. - receiptsRoot
: DATA, 32 Bytes - the root of the receipts trie of the block. - miner
: DATA, 20 Bytes - the address of the beneficiary to whom the mining rewards were given. - totalDifficulty
: QUANTITY - integer of the total difficulty of the chain until this block. - extraData
: DATA - the “extra data” field of this block. - size
: QUANTITY - integer the size of this block in bytes. - gasLimit
: QUANTITY - the maximum gas allowed in this block. - gasUsed
: QUANTITY - the total used gas by all transactions in this block. - timestamp
: QUANTITY - the unix timestamp for when the block was collated. - transactions
: Array - Array of transaction objects, or 32 Bytes transaction hashes depending on the last given parameter. - baseFeePerGas
: QUANTITY - The base fee is the bare minimum you will be charged to send a transaction on the network.
示例
eth_getBlockByHash
Returns information about a block by block hash.
參數
DATA
, 32 Bytes - Hash of a block. Boolean
- If true it returns the full transaction objects, if false only the hashes of the transactions.
返回
示例
Result See eth_getBlockByNumber
eth_getCode
Returns code at a given address.
參數
DATA
, 20 Bytes - address.QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter.
返回
DATA
- the code from the given address.
示例
eth_getStorageAt
Returns the value from a storage position at a given address.
參數
DATA
, 20 Bytes - address of the storage.QUANTITY
- integer of the position in the storage.QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter
返回
DATA
- the value at this storage position.
示例
Calculating the correct position depends on the storage to retrieve. Consider the following contract deployed at 0x295a70b2de5e3953354a6a8344e616ed314d7251
by address 0x391694e7e0b0cce554cb130d723a9d27458f9298
.
Retrieving the value of pos0 is straight forward:
Retrieving an element of the map is harder. The position of an element in the map is calculated with:
This means to retrieve the storage on pos1["0x391694e7e0b0cce554cb130d723a9d27458f9298"] we need to calculate the position with:
The geth console which comes with the web3 library can be used to make the calculation:
Now to fetch the storage:
eth_call
Executes a new message call immediately without creating a transaction on the block chain.
參數
Object
- The transaction call object
from
:DATA
, 20 Bytes - (optional) The address the transaction is sent from.to
:DATA
, 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 gasPrice used for each paid gasmaxFeePerGas
:QUANTITY
- It's just the sum of baseFeePerGas and maxPriorityFeePerGas: maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas.maxPriorityFeePerGas
:QUANTITY
- When you submit a transaction you will also provide a "tip" to the miner. This is the maxPriorityFeePerGas field. fork.value
:QUANTITY
- (optional) Integer of the value sent with this transactionnonce
:QUANTITY
- the number of transactions made by the sender prior to this one.data
:DATA
- (optional) Hash of the method signature and encoded 參數input
:DATA
- (optional) We accept "data" and "input" for backwards-compatibility reasons. "input" is the newer name and should be preferred by clients.
QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter
返回
DATA
- the return value of executed contract.
示例
eth_estimateGas
Generates and returns an estimate of how much gas is necessary to allow the transaction to complete. The transaction will not be added to the blockchain. Note that the estimate may be significantly more than the amount of gas actually used by the transaction, for a variety of reasons including EVM mechanics and node performance.
參數
See eth_call 參數, expect that all properties are optional. If no gas limit is specified geth uses the block gas limit from the pending block as an upper bound. As a result the returned estimate might not be enough to executed the call/transaction when the amount of gas is higher than the pending block gas limit.
返回
QUANTITY
- the amount of gas used.
示例
eth_getBlockTransactionCountByNumber
Returns the number of transactions in a block matching the given block number.
參數
QUANTITY|TAG
- integer of a block number, or the string"earliest"
,"latest"
or"pending"
, as in the default block parameter.
返回
QUANTITY
- integer of the number of transactions in this block.
示例
eth_getBlockTransactionCountByHash
Returns the number of transactions in a block from a block matching the given block hash.
參數
DATA
, 32 Bytes - hash of a block.
返回
QUANTITY
- integer of the number of transactions in this block.
示例
eth_getTransactionByHash
Returns the information about a transaction requested by transaction hash.
參數
DATA
, 32 Bytes - hash of a transaction
返回
Object
- A transaction object, or null
when no transaction was found:
blockHash
:DATA
, 32 Bytes - hash of the block where this transaction was in.null
when its pending.blockNumber
:QUANTITY
- block number where this transaction was in.null
when its pending.from
:DATA
, 20 Bytes - address of the sender.gas
:QUANTITY
- gas provided by the sender.gasPrice
:QUANTITY
- gas price provided by the sender in Wei.maxFeePerGas
:QUANTITY
- It's just the sum of baseFeePerGas and maxPriorityFeePerGas: maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas.maxPriorityFeePerGas
:QUANTITY
- When you submit a transaction you will also provide a "tip" to the miner. This is the maxPriorityFeePerGas field. fork.hash
:DATA
, 32 Bytes - hash of the transaction.input
:DATA
- the data send along with the transaction.nonce
:QUANTITY
- the number of transactions made by the sender prior to this one.to
:DATA
, 20 Bytes - address of the receiver.null
when its a contract creation transaction.transactionIndex
:QUANTITY
- integer of the transaction's index position in the block.null
when its pending.value
:QUANTITY
- value transferred in Wei.accessList
:chainId
:v
:QUANTITY
- ECDSA recovery idr
:DATA
, 32 Bytes - ECDSA signature rs
:DATA
, 32 Bytes - ECDSA signature spayer
:DATA
, 20 Bytes - address of the payer.fee
:QUANTITY
- transaction fee in Wei.pv
:QUANTITY
- ECDSA recovery idpr
:DATA
, 32 Bytes - ECDSA signature prps
:DATA
, 32 Bytes - ECDSA signature ps
示例
eth_getTransactionByBlockNumberAndIndex
Returns information about a transaction by block number and transaction index position.
參數
QUANTITY|TAG
- a block number, or the string"earliest"
,"latest"
or"pending"
, as in the default block parameter.QUANTITY
- the transaction index position.
返回
示例
Result see eth_getTransactionByHash
eth_getTransactionByBlockHashAndIndex
Returns information about a transaction by block hash and transaction index position.
參數
DATA
, 32 Bytes - hash of a block.QUANTITY
- integer of the transaction index position.
返回
示例
Result see eth_getTransactionByHash
eth_getTransactionCount
Returns the number of transactions sent from an address.
參數
DATA
, 20 Bytes - address.QUANTITY|TAG
- integer block number, or the string"latest"
,"earliest"
or"pending"
, see the default block parameter
返回
QUANTITY
- integer of the number of transactions send from this address.
示例
eth_getTransactionReceipt
Returns the receipt of a transaction by transaction hash.
Note That the receipt is not available for pending transactions.
參數
DATA
, 32 Bytes - hash of a transaction
示例 參數
返回
Object
- A transaction receipt object, or null
when no receipt was found:
It also returns either :
示例
eth_sendTransaction
Creates new message call transaction or a contract creation, if the data field contains code.
參數
Object
- The transaction objectfrom
:DATA
, 20 Bytes - (optional) The address the transaction is sent from.to
:DATA
, 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 gasPrice used for each paid gasmaxFeePerGas
:QUANTITY
- It's just the sum of baseFeePerGas and maxPriorityFeePerGas: maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas.maxPriorityFeePerGas
:QUANTITY
- When you submit a transaction you will also provide a "tip" to the miner. This is the maxPriorityFeePerGas field. fork.value
:QUANTITY
- (optional) Integer of the value sent with this transactionnonce
:QUANTITY
- the number of transactions made by the sender prior to this one.data
:DATA
- (optional) Hash of the method signature and encoded 參數input
:DATA
- (optional) We accept "data" and "input" for backwards-compatibility reasons. "input" is the newer name and should be preferred by clients.
示例 參數
返回
DATA
, 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.
示例
eth_sign
The sign method calculates an Ethereum specific signature with: sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))).
By adding a prefix to the message makes the calculated signature recognisable as an Ethereum specific signature. This prevents misuse where a malicious DApp can sign arbitrary data (e.g. transaction) and use the signature to impersonate the victim.
Note the address to sign with must be unlocked.
參數
account, message
DATA
, 20 Bytes - address.DATA
, N Bytes - message to sign.
返回
DATA
: Signature
示例
An 示例 how to use solidity ecrecover to verify the signature calculated with eth_sign
can be found here. The contract is deployed on the testnet Ropsten and Rinkeby.
eth_signTransaction
Signs a transaction that can be submitted to the network at a later time using with eth_sendRawTransaction.
參數
Object
- The transaction objectfrom
:DATA
, 20 Bytes - (optional) The address the transaction is sent from.to
:DATA
, 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 gasPrice used for each paid gasmaxFeePerGas
:QUANTITY
- It's just the sum of baseFeePerGas and maxPriorityFeePerGas: maxFeePerGas = baseFeePerGas + maxPriorityFeePerGas.maxPriorityFeePerGas
:QUANTITY
- When you submit a transaction you will also provide a "tip" to the miner. This is the maxPriorityFeePerGas field. fork.value
:QUANTITY
- (optional) Integer of the value sent with this transactionnonce
:QUANTITY
- the number of transactions made by the sender prior to this one.data
:DATA
- (optional) Hash of the method signature and encoded 參數input
:DATA
- (optional) We accept "data" and "input" for backwards-compatibility reasons. "input" is the newer name and should be preferred by clients.
返回
raw
, The signed transaction object.
Use eth_getTransactionReceipt to get the contract address, after the transaction was mined, when you created a contract.
示例
eth_sendRawTransaction
Creates new message call transaction or a contract creation for signed transactions.
參數
DATA
, The signed transaction data.
返回
DATA
, 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.
示例
eth_newFilter
Creates a filter object, based on filter options, to notify when the state changes (logs). To check if the state has changed, call eth_getFilterChanges.
A note on specifying topic filters:
Topics are order-dependent. A transaction with a log with topics [A, B] will be matched by the following topic filters:
[]
"anything"[A]
"A in first position (and anything after)"[null, B]
"anything in first position AND B in second position (and anything after)"[A, B]
"A in first position AND B in second position (and anything after)"[[A, B], [A, B]]
"(A OR B) in first position AND (A OR B) in second position (and anything after)"
參數
Object
- The filter options:
fromBlock
:QUANTITY|TAG
- (optional, default:"latest"
) Integer block number, or"latest"
for the last mined block or"pending"
,"earliest"
for not yet mined transactions.toBlock
:QUANTITY|TAG
- (optional, default:"latest"
) Integer block number, or"latest"
for the last mined block or"pending"
,"earliest"
for not yet mined transactions.address
:DATA|Array
, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.topics
:Array of DATA
, - (optional) Array of 32 BytesDATA
topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.
示例 參數
返回
QUANTITY
- A filter id.
示例
eth_newBlockFilter
Creates a filter in the node, to notify when a new block arrives. To check if the state has changed, call eth_getFilterChanges.
參數
None
返回
QUANTITY
- A filter id.
示例
eth_newPendingTransactionFilter
Creates a filter in the node, to notify when new pending transactions arrive. To check if the state has changed, call eth_getFilterChanges.
參數
None
返回
QUANTITY
- A filter id.
示例
eth_uninstallFilter
Uninstalls a filter with given id. Should always be called when watch is no longer needed. Additonally Filters timeout when they aren't requested with eth_getFilterChanges for a period of time.
參數
QUANTITY
- The filter id.
返回
Boolean
- true
if the filter was successfully uninstalled, otherwise false
.
示例
eth_getFilterChanges
Polling method for a filter, which returns an array of logs which occurred since last poll.
參數
QUANTITY
- the filter id.
示例 參數
返回
Array
- Array of log objects, or an empty array if nothing has changed since last poll.
For filters created with
eth_newBlockFilter
the return are block hashes (DATA
, 32 Bytes), e.g.["0x3454645634534..."]
.For filters created with
eth_newPendingTransactionFilter
the return are transaction hashes (DATA
, 32 Bytes), e.g.["0x6345343454645..."]
.For filters created with
eth_newFilter
logs are objects with following params:removed
:TAG
-true
when the log was removed, due to a chain reorganization.false
if its a valid log.logIndex
:QUANTITY
- integer of the log index position in the block.null
when its pending log.transactionIndex
:QUANTITY
- integer of the transactions index position log was created from.null
when its pending log.transactionHash
:DATA
, 32 Bytes - hash of the transactions this log was created from.null
when its pending log.blockHash
:DATA
, 32 Bytes - hash of the block where this log was in.null
when its pending.null
when its pending log.blockNumber
:QUANTITY
- the block number where this log was in.null
when its pending.null
when its pending log.address
:DATA
, 20 Bytes - address from which this log originated.data
:DATA
- contains the non-indexed arguments of the log.topics
:Array of DATA
- Array of 0 to 4 32 BytesDATA
of indexed log arguments. (In solidity: The first topic is the hash of the signature of the event (e.g.Deposit(address,bytes32,uint256)
), except you declared the event with theanonymous
specifier.)
示例
eth_getFilterLogs
Returns an array of all logs matching filter with given id.
參數
QUANTITY
- The filter id.
示例 參數
返回
示例
Result see eth_getFilterChanges
eth_getLogs
Returns an array of all logs matching a given filter object.
參數
Object
- The filter options:
fromBlock
:QUANTITY|TAG
- (optional, default:"latest"
) Integer block number, or"latest"
for the last mined block or"pending"
,"earliest"
for not yet mined transactions.toBlock
:QUANTITY|TAG
- (optional, default:"latest"
) Integer block number, or"latest"
for the last mined block or"pending"
,"earliest"
for not yet mined transactions.address
:DATA|Array
, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.topics
:Array of DATA
, - (optional) Array of 32 BytesDATA
topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.blockhash
:DATA
, 32 Bytes - (optional) With the addition of EIP-234 (Geth >= v1.8.13 or Parity >= v2.1.0),blockHash
is a new filter option which restricts the logs returned to the single block with the 32-byte hashblockHash
. UsingblockHash
is equivalent tofromBlock
=toBlock
= the block number with hashblockHash
. IfblockHash
is present in the filter criteria, then neitherfromBlock
nortoBlock
are allowed.
示例 參數
返回
示例
Result see eth_getFilterChanges
eth_getFilterLogs
Returns an array of all logs matching filter with given id.
參數
QUANTITY
- The filter id.
返回
示例
Result see eth_getFilterChanges
eth_getLogs
Returns an array of all logs matching a given filter object.
參數
Object
- The filter options:
fromBlock
:QUANTITY|TAG
- (optional, default:"latest"
) Integer block number, or"latest"
for the last mined block or"pending"
,"earliest"
for not yet mined transactions.toBlock
:QUANTITY|TAG
- (optional, default:"latest"
) Integer block number, or"latest"
for the last mined block or"pending"
,"earliest"
for not yet mined transactions.address
:DATA|Array
, 20 Bytes - (optional) Contract address or a list of addresses from which logs should originate.topics
:Array of DATA
, - (optional) Array of 32 BytesDATA
topics. Topics are order-dependent. Each topic can also be an array of DATA with "or" options.blockhash
:DATA
, 32 Bytes - (optional) With the addition of EIP-234 (Geth >= v1.8.13 or Parity >= v2.1.0),blockHash
is a new filter option which restricts the logs returned to the single block with the 32-byte hashblockHash
. UsingblockHash
is equivalent tofromBlock
=toBlock
= the block number with hashblockHash
. IfblockHash
is present in the filter criteria, then neitherfromBlock
nortoBlock
are allowed.
示例 參數
返回
示例
Result see eth_getFilterChanges
Last updated