简单总结 (Simple Summary)
该提案定义了 Ethereum Nodes
应实现的一组标准远程过程调用方法。
抽象 (Abstract)
由于不存在正式的 Ethereum RPC
规范, 第一代 Ethereum Clients
创建的节点暴露了不一致和不兼容的远程过程调用 (RPC) 方法。
该提案将此类规范标准化, 为开发人员提供可预测的 Ethereum RPC
接口,而无需了解底层节点如何实现。
规范 (Specification)
概念 (Concepts)
RFC-2119
本文档中的关键词“必须”、“不得”、“必需”、“应”、“不应”、“应该”、“不应”、“推荐”、“可以”和“可选” 按照 RFC-2119 (opens in a new tab) 中的描述进行解释。
JSON-RPC
与以太坊节点的通信是使用 JSON-RPC (opens in a new tab) 完成的,这是一种无状态、轻量级的 远程过程调用 (opens in a new tab) 使用 JSON 作为其数据格式的协议。
Ethereum RPC
方法必须使用 JSON-RPC 请求对象 (opens in a new tab) 调用并且必须使用 JSON-RPC 响应对象 (opens in a new tab)。
Error codes
如果以太坊 RPC 方法遇到错误,响应对象中包含的“错误”成员必须是一个包含“代码”成员和描述性“消息”成员的对象。 以下列表包含所有可能的错误代码和相关消息:
Code | Message | Meaning | Category |
---|---|---|---|
-32700 | Parse error | Invalid JSON | standard |
-32600 | Invalid request | JSON is not a valid request object | standard |
-32601 | Method not found | Method does not exist | standard |
-32602 | Invalid params | Invalid method parameters | standard |
-32603 | Internal error | Internal JSON-RPC error | standard |
-32000 | Invalid input | Missing or invalid parameters | non-standard |
-32001 | Resource not found | Requested resource not found | non-standard |
-32002 | Resource unavailable | Requested resource not available | non-standard |
-32003 | Transaction rejected | Transaction creation failed | non-standard |
-32004 | Method not supported | Method is not implemented | non-standard |
-32005 | Limit exceeded | Request exceeds defined limit | non-standard |
-32006 | JSON-RPC version not supported | Version of JSON-RPC protocol is not supported | non-standard |
Example error response:
{
"id": 1337
"jsonrpc": "2.0",
"error": {
"code": -32003,
"message": "Transaction rejected"
}
}
Value encoding
传递给以太坊 RPC 方法并从中返回的特定类型的值需要特殊编码:
Quantity
- A
Quantity
value MUST be hex-encoded. - A
Quantity
value MUST be "0x"-prefixed. - A
Quantity
value MUST be expressed using the fewest possible hex digits per byte. - A
Quantity
value MUST express zero as "0x0".
Examples Quantity
values:
Value | Valid | Reason |
---|---|---|
0x | invalid | empty not a valid quantity |
0x0 | valid | interpreted as a quantity of zero |
0x00 | invalid | leading zeroes not allowed |
0x41 | valid | interpreted as a quantity of 65 |
0x400 | valid | interpreted as a quantity of 1024 |
0x0400 | invalid | leading zeroes not allowed |
ff | invalid | values must be prefixed |
Block Identifier
The RPC methods below take a default block identifier as a parameter.
eth_getBalance
eth_getStorageAt
eth_getTransactionCount
eth_getCode
eth_call
eth_getProof
由于无法明确区分“Data”参数和“Quantity”参数,EIP-1898 提供了一种使用区块哈希或区块编号指定区块的格式。 块标识符是一个具有以下字段的 JSON 对象:
Property | Type | Description |
---|---|---|
[blockNumber] | {Quantity } | The block in the canonical chain with this number |
OR [blockHash] | {Data } | The block uniquely identified by this hash. The blockNumber and blockHash properties are mutually exclusive; exactly one of them must be set. |
requireCanonical | {boolean } | (optional) Whether or not to throw an error if the block is not in the canonical chain as described below. Only allowed in conjunction with the blockHash tag. Defaults to false . |
如果没有找到块,被调用者应该抛出一个 JSON-RPC 错误(推荐的错误代码是 -32001: Resource not found
。如果标签是 blockHash
并且 requireCanonical
是 true
,被调用者应该 如果该块不在规范链中,还会引发 JSON-RPC 错误(推荐的错误代码为“-32000:无效输入”,并且在任何情况下都应与未找到块的错误代码不同,以便调用者 可以区分情况)。
block-not-found 检查应该优先于 block-is-canonical 检查,这样如果没有找到块,被调用者会引发 block-not-found 而不是 block-not-canonical。
Data
- A
Data
value MUST be hex-encoded. - A
Data
value MUST be "0x"-prefixed. - A
Data
value MUST be expressed using two hex digits per byte.
Examples Data
values:
Value | Valid | Reason |
---|---|---|
0x | valid | interpreted as empty data |
0x0 | invalid | each byte must be represented using two hex digits |
0x00 | valid | interpreted as a single zero byte |
0x41 | true | interpreted as a data value of 65 |
0x004200 | true | interpreted as a data value of 16896 |
0xf0f0f | false | bytes require two hex digits |
004200 | false | values must be prefixed |
Proposing changes
新的以太坊 RPC 方法和对现有方法的更改必须通过传统的 EIP 流程提出。 这允许围绕新方法实现和提议的方法修改达成社区共识。 RPC 方法提案必须在添加到此提案和此处定义的官方以太坊 RPC 规范之前达到“草案”状态。
Methods
web3_clientVersion
Description
返回当前客户端的版本
Parameters
(none)
Returns
{string
} - client version
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "web3_clientVersion",
"params": [],
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "Mist/v0.9.3/darwin/go1.4.1"
}
web3_sha3
Description
Hashes data using the Keccak-256 algorithm
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | data to hash |
Returns
{Data
} - Keccak-256 hash of the given data
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "web3_sha3",
"params": ["0x68656c6c6f20776f726c64"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0xc94770007dda54cF92009BFF0dE90c06F603a09f"
}
net_listening
Description
确定此客户端是否正在侦听新的网络连接
Parameters
(none)
Returns
{boolean
} - true
if listening is active or false
if listening is not active
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "net_listening",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": true
}
net_peerCount
Description
返回当前连接到此客户端的对等点数
Parameters
(none)
Returns
{Quantity
} - number of connected peers
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "net_peerCount",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x2"
}
net_version
Description
返回与当前网络关联的链 ID
Parameters
(none)
Returns
{string
} - chain ID associated with the current network
Common chain IDs:
"1"
- Ethereum mainnet"3"
- Ropsten testnet"4"
- Rinkeby testnet"42"
- Kovan testnet
Note: See EIP-155 for a complete list of possible chain IDs.
Example
# Request
curl -X POST --data '{
"id": 1337
"jsonrpc": "2.0",
"method": "net_version",
"params": [],
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "3"
}
eth_accounts
Description
Returns a list of addresses owned by this client
Parameters
(none)
Returns
{Data[]
} - array of addresses
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_accounts",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": ["0xc94770007dda54cF92009BFF0dE90c06F603a09f"]
}
eth_blockNumber
Description
返回此客户端看到的最新块的编号
Parameters
(none)
Returns
{Quantity
} - number of the latest block
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0xc94"
}
eth_call
Description
立即执行新的消息调用而不向网络提交交易
Parameters
# | Type | Description |
---|---|---|
1 | {object } | @property {Data } [from] - transaction sender@property { Data } to - transaction recipient or null if deploying a contract@property { Quantity } [gas] - gas provided for transaction execution@property { Quantity } [gasPrice] - price in wei of each gas used@property { Quantity } [value] - value in wei sent with this transaction@property { Data } [data] - contract code or a hashed method call with encoded args |
2 | {Quantity |string |Block Identifier } | block number, or one of "latest" , "earliest" or "pending" , or a block identifier as described in Block Identifier |
Returns
{Data
} - return value of executed contract
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"gas": "0x76c0",
"gasPrice": "0x9184e72a000",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"value": "0x9184e72a"
}]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x"
}
eth_coinbase
Description
Returns the coinbase address for this client
Parameters
(none)
Returns
{Data
} - coinbase address
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_coinbase",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0xc94770007dda54cF92009BFF0dE90c06F603a09f"
}
eth_estimateGas
Description
Estimates the gas necessary to complete a transaction without submitting it to the network
Note: The resulting gas estimation may be significantly more than the amount of gas actually used by the transaction. This is due to a variety of reasons including EVM mechanics and node performance.
Parameters
# | Type | Description |
---|---|---|
1 | {object } | @property {Data } [from] - transaction sender@property { Data } [to] - transaction recipient@property { Quantity } [gas] - gas provided for transaction execution@property { Quantity } [gasPrice] - price in wei of each gas used@property { Quantity } [value] - value in wei sent with this transaction@property { Data } [data] - contract code or a hashed method call with encoded args |
2 | {Quantity |string } | block number, or one of "latest" , "earliest" or "pending" |
Returns
{Quantity
} - amount of gas required by transaction
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_estimateGas",
"params": [{
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"gas": "0x76c0",
"gasPrice": "0x9184e72a000",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"value": "0x9184e72a"
}]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x5208"
}
eth_gasPrice
Description
Returns the current price of gas expressed in wei
Parameters
(none)
Returns
{Quantity
} - current gas price in wei
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_gasPrice",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x09184e72a000"
}
eth_getBalance
Description
Returns the balance of an address in wei
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | address to query for balance |
2 | {Quantity |string |Block Identifier } | block number, or one of "latest" , "earliest" or "pending" , or a block identifier as described in Block Identifier |
Returns
{Quantity
} - balance of the provided account in wei
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x0234c8a3397aab58"
}
eth_getBlockByHash
Description
Returns information about a block specified by hash
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | hash of a block |
2 | {boolean } | true will pull full transaction objects, false will pull transaction hashes |
Returns
{null|object
} - null
if no block is found, otherwise a block object with the following members:
- {
Data
}extraData
- "extra data" field of this block - {
Data
}hash
- block hash ornull
if pending - {
Data
}logsBloom
- logs bloom filter ornull
if pending - {
Data
}miner
- address that received this block's mining rewards - {
Data
}nonce
- proof-of-work hash ornull
if pending - {
Data
}parentHash
- parent block hash - {
Data
}receiptsRoot
-root of the this block's receipts trie - {
Data
}sha3Uncles
- SHA3 of the uncles data in this block - {
Data
}stateRoot
- root of this block's final state trie - {
Data
}transactionsRoot
- root of this block's transaction trie - {
Quantity
}difficulty
- difficulty for this block - {
Quantity
}gasLimit
- maximum gas allowed in this block - {
Quantity
}gasUsed
- total used gas by all transactions in this block - {
Quantity
}number
- block number ornull
if pending - {
Quantity
}size
- size of this block in bytes - {
Quantity
}timestamp
- unix timestamp of when this block was collated - {
Quantity
}totalDifficulty
- total difficulty of the chain until this block - {
Array<Transaction>
}transactions
- list of transaction objects or hashes - {
Array<Transaction>
}uncles
- list of uncle hashes
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getBlockByHash",
"params":["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": {
"difficulty": "0x027f07",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x9f759",
"gasUsed": "0x9f759",
"hash": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"miner": "0x4e65fda2159562a496f9f3522f89122a3088497a",
"nonce": "0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
"number": "0x1b4",
"parentHash": "0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x027f07",
"stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff",
"timestamp": "0x54e34e8e"
"totalDifficulty": "0x027f07",
"transactions": []
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles": ["0x1606e5...", "0xd5145a9..."]
}
}
eth_getBlockByNumber
Description
Returns information about a block specified by number
Parameters
# | Type | Description |
---|---|---|
1 | {Quantity |string } | block number, or one of "latest" , "earliest" or "pending" |
2 | {boolean } | true will pull full transaction objects, false will pull transaction hashes |
Returns
{null|object
} - null
if no block is found, otherwise a block object with the following members:
- {
Data
}extraData
- "extra data" field of this block - {
Data
}hash
- block hash ornull
if pending - {
Data
}logsBloom
- logs bloom filter ornull
if pending - {
Data
}miner
- address that received this block's mining rewards - {
Data
}nonce
- proof-of-work hash ornull
if pending - {
Data
}parentHash
- parent block hash - {
Data
}receiptsRoot
-root of the this block's receipts trie - {
Data
}sha3Uncles
- SHA3 of the uncles data in this block - {
Data
}stateRoot
- root of this block's final state trie - {
Data
}transactionsRoot
- root of this block's transaction trie - {
Quantity
}difficulty
- difficulty for this block - {
Quantity
}gasLimit
- maximum gas allowed in this block - {
Quantity
}gasUsed
- total used gas by all transactions in this block - {
Quantity
}number
- block number ornull
if pending - {
Quantity
}size
- size of this block in bytes - {
Quantity
}timestamp
- unix timestamp of when this block was collated - {
Quantity
}totalDifficulty
- total difficulty of the chain until this block - {
Array<Transaction>
}transactions
- list of transaction objects or hashes - {
Array<Transaction>
}uncles
- list of uncle hashes
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getBlockByNumber",
"params":["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", true]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": {
"difficulty": "0x027f07",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x9f759",
"gasUsed": "0x9f759",
"hash": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"miner": "0x4e65fda2159562a496f9f3522f89122a3088497a",
"nonce": "0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
"number": "0x1b4",
"parentHash": "0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x027f07",
"stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff",
"timestamp": "0x54e34e8e"
"totalDifficulty": "0x027f07",
"transactions": []
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles": ["0x1606e5...", "0xd5145a9..."]
}
}
eth_getBlockTransactionCountByHash
Description
Returns the number of transactions in a block specified by block hash
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | hash of a block |
Returns
{Quantity
} - number of transactions in the specified block
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByHash",
"params": ["0xc94770007dda54cF92009BFF0dE90c06F603a09f"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0xc"
}
eth_getBlockTransactionCountByNumber
Description
Returns the number of transactions in a block specified by block number
Parameters
# | Type | Description |
---|---|---|
1 | {Quantity |string } | block number, or one of "latest" , "earliest" or "pending" |
Returns
{Quantity
} - number of transactions in the specified block
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getBlockTransactionCountByNumber",
"params": ["0xe8"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0xa"
}
eth_getCode
Description
Returns the contract code stored at a given address
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | address to query for code |
2 | {Quantity |string |Block Identifier } | block number, or one of "latest" , "earliest" or "pending" , or a block identifier as described in Block Identifier |
Returns
{Data
} - code from the specified address
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getCode",
"params": ["0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b", "0x2"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x600160008035811a818181146012578301005b601b6001356025565b8060005260206000f25b600060078202905091905056"
}
eth_getFilterChanges
Description
Returns a list of all logs based on filter ID since the last log retrieval
Parameters
# | Type | Description |
---|---|---|
1 | {Quantity } | ID of the filter |
Returns
{Array<Log>
} - array of log objects with the following members:
- {
Data
}address
- address from which this log originated - {
Data
}blockHash
- hash of block containing this log ornull
if pending - {
Data
}data
- contains the non-indexed arguments of the log - {
Data
}transactionHash
- hash of the transaction that created this log ornull
if pending - {
Quantity
}blockNumber
- number of block containing this log ornull
if pending - {
Quantity
}logIndex
- index of this log within its block ornull
if pending - {
Quantity
}transactionIndex
- index of the transaction that created this log ornull
if pending - {
Data[]
}topics
- list of order-dependent topics - {
boolean
}removed
-true
if this filter has been destroyed and is invalid
Note: The return value of eth_getFilterChanges
when retrieving logs from eth_newBlockFilter
and eth_newPendingTransactionFilter
filters will be an array of hashes, not an array of Log objects.
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getFilterChanges",
"params": ["0x16"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": [{
"address": "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d",
"blockHash": "0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d",
"blockNumber":"0x1b4",
"data":"0x0000000000000000000000000000000000000000000000000000000000000000",
"logIndex": "0x1",
"topics": [],
"transactionHash": "0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf",
"transactionIndex": "0x0"
}]
}
eth_getFilterLogs
Description
Returns a list of all logs based on filter ID
Parameters
# | Type | Description |
---|---|---|
1 | {Quantity } | ID of the filter |
Returns
{Array<Log>
} - array of log objects with the following members:
- {
Data
} address - address from which this log originated - {
Data
} blockHash - hash of block containing this log ornull
if pending - {
Data
} data - contains the non-indexed arguments of the log - {
Data
} transactionHash - hash of the transaction that created this log ornull
if pending - {
Quantity
} blockNumber - number of block containing this log ornull
if pending - {
Quantity
} logIndex - index of this log within its block ornull
if pending - {
Quantity
} transactionIndex - index of the transaction that created this log ornull
if pending - {
Array<Data>
} topics - list of order-dependent topics - {
boolean
} removed -true
if this filter has been destroyed and is invalid
Note: The return value of eth_getFilterLogs
when retrieving logs from eth_newBlockFilter
and eth_newPendingTransactionFilter
filters will be an array of hashes, not an array of Log objects.
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getFilterLogs",
"params": ["0x16"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": [{
"address": "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d",
"blockHash": "0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d",
"blockNumber":"0x1b4",
"data":"0x0000000000000000000000000000000000000000000000000000000000000000",
"logIndex": "0x1",
"topics": [],
"transactionHash": "0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf",
"transactionIndex": "0x0"
}]
}
eth_getLogs
Description
Returns a list of all logs based on a filter object
Parameters
# | Type | Description |
---|---|---|
1 | {object } | @property {Quantity |string } [fromBlock] - block number, or one of "latest" , "earliest" or "pending" @property { Quantity |string } [toBlock] - block number, or one of "latest" , "earliest" or "pending" @property { Data |Data[] } [address] - contract address or a list of addresses from which logs should originate@property { Data[] } [topics] - list of order-dependent topics@property { Data } [blockhash] - restrict logs to a block by hash |
Note: If blockhash
is passed, neither fromBlock
nor toBlock
are allowed or respected.
Returns
{Array<Log>
} - array of log objects with the following members:
- {
Data
}address
- address from which this log originated - {
Data
}blockHash
- hash of block containing this log ornull
if pending - {
Data
}data
- contains the non-indexed arguments of the log - {
Data
}transactionHash
- hash of the transaction that created this log ornull
if pending - {
Quantity
}blockNumber
- number of block containing this log ornull
if pending - {
Quantity
}logIndex
- index of this log within its block ornull
if pending - {
Quantity
}transactionIndex
- index of the transaction that created this log ornull
if pending - {
Data
}topics
- list of order-dependent topics - {
boolean
}removed
-true
if this filter has been destroyed and is invalid
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getLogs",
"params": [{
"topics":["0x000000000000000000000000a94f5374fce5edbc8e2a8697c15331677e6ebf0b"]
}]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": [{
"address": "0x16c5785ac562ff41e2dcfdf829c5a142f1fccd7d",
"blockHash": "0x8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcfdf829c5a142f1fccd7d",
"blockNumber":"0x1b4",
"data":"0x0000000000000000000000000000000000000000000000000000000000000000",
"logIndex": "0x1",
"topics": [],
"transactionHash": "0xdf829c5a142f1fccd7d8216c5785ac562ff41e2dcfdf5785ac562ff41e2dcf",
"transactionIndex": "0x0"
}]
}
eth_getStorageAt
Description
Returns the value from a storage position at an address
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | address of stored data |
2 | {Quantity } | index into stored data |
3 | {Quantity |string |Block Identifier } | block number, or one of "latest" , "earliest" or "pending" , or a block identifier as described in Block Identifier |
Returns
{Data
} - value stored at the given address and data index
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getStorageAt",
"params": ["0x295a70b2de5e3953354a6a8344e616ed314d7251", "0x0", "latest"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x00000000000000000000000000000000000000000000000000000000000004d2"
}
eth_getTransactionByBlockHashAndIndex
Description
Returns information about a transaction specified by block hash and transaction index
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | hash of a block |
2 | {Quantity } | index of a transaction in the specified block |
Returns
{null|object
} - null
if no transaction is found, otherwise a transaction object with the following members:
- {
Data
}r
- ECDSA signature r - {
Data
}s
- ECDSA signature s - {
Data
}blockHash
- hash of block containing this transaction ornull
if pending - {
Data
}from
- transaction sender - {
Data
}hash
- hash of this transaction - {
Data
}input
- contract code or a hashed method call - {
Data
}to
- transaction recipient ornull
if deploying a contract - {
Quantity
}v
- ECDSA recovery ID - {
Quantity
}blockNumber
- number of block containing this transaction ornull
if pending - {
Quantity
}gas
- gas provided for transaction execution - {
Quantity
}gasPrice
- price in wei of each gas used - {
Quantity
}nonce
- unique number identifying this transaction - {
Quantity
}transactionIndex
- index of this transaction in the block ornull
if pending - {
Quantity
}value
- value in wei sent with this transaction
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getTransactionByBlockHashAndIndex",
"params":["0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331", "0x0"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": {
"blockHash": "0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2",
"blockNumber": "0x5daf3b",
"from": "0xa7d9ddbe1f17865597fbd27ec712455208b6b76d",
"gas": "0xc350",
"gasPrice": "0x4a817c800",
"hash": "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b",
"input": "0x68656c6c6f21",
"nonce": "0x15",
"r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
"s": "0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c",
"to": "0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb",
"transactionIndex": "0x41",
"v": "0x25",
"value": "0xf3dbb76162000"
}
}
eth_getTransactionByBlockNumberAndIndex
Description
Returns information about a transaction specified by block number and transaction index
Parameters
# | Type | Description |
---|---|---|
1 | {Quantity |string } | block number, or one of "latest" , "earliest" or "pending" |
2 | {Quantity } | index of a transaction in the specified block |
Returns
{null|object
} - null
if no transaction is found, otherwise a transaction object with the following members:
- {
Data
}r
- ECDSA signature r - {
Data
}s
- ECDSA signature s - {
Data
}blockHash
- hash of block containing this transaction ornull
if pending - {
Data
}from
- transaction sender - {
Data
}hash
- hash of this transaction - {
Data
}input
- contract code or a hashed method call - {
Data
}to
- transaction recipient ornull
if deploying a contract - {
Quantity
}v
- ECDSA recovery ID - {
Quantity
}blockNumber
- number of block containing this transaction ornull
if pending - {
Quantity
}gas
- gas provided for transaction execution - {
Quantity
}gasPrice
- price in wei of each gas used - {
Quantity
}nonce
- unique number identifying this transaction - {
Quantity
}transactionIndex
- index of this transaction in the block ornull
if pending - {
Quantity
}value
- value in wei sent with this transaction
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getTransactionByBlockNumberAndIndex",
"params":["0x29c", "0x0"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": {
"blockHash": "0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2",
"blockNumber": "0x5daf3b",
"from": "0xa7d9ddbe1f17865597fbd27ec712455208b6b76d",
"gas": "0xc350",
"gasPrice": "0x4a817c800",
"hash": "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b",
"input": "0x68656c6c6f21",
"nonce": "0x15",
"r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
"s": "0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c",
"to": "0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb",
"transactionIndex": "0x41",
"v": "0x25",
"value": "0xf3dbb76162000"
}
}
eth_getTransactionByHash
Description
Returns information about a transaction specified by hash
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | hash of a transaction |
Returns
{null|object
} - null
if no transaction is found, otherwise a transaction object with the following members:
- {
Data
}r
- ECDSA signature r - {
Data
}s
- ECDSA signature s - {
Data
}blockHash
- hash of block containing this transaction ornull
if pending - {
Data
}from
- transaction sender - {
Data
}hash
- hash of this transaction - {
Data
}input
- contract code or a hashed method call - {
Data
}to
- transaction recipient ornull
if deploying a contract - {
Quantity
}v
- ECDSA recovery ID - {
Quantity
}blockNumber
- number of block containing this transaction ornull
if pending - {
Quantity
}gas
- gas provided for transaction execution - {
Quantity
}gasPrice
- price in wei of each gas used - {
Quantity
}nonce
- unique number identifying this transaction - {
Quantity
}transactionIndex
- index of this transaction in the block ornull
if pending - {
Quantity
}value
- value in wei sent with this transaction
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getTransactionByHash",
"params": ["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": {
"blockHash": "0x1d59ff54b1eb26b013ce3cb5fc9dab3705b415a67127a003c3e61eb445bb8df2",
"blockNumber": "0x5daf3b",
"from": "0xa7d9ddbe1f17865597fbd27ec712455208b6b76d",
"gas": "0xc350",
"gasPrice": "0x4a817c800",
"hash": "0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b",
"input": "0x68656c6c6f21",
"nonce": "0x15",
"r": "0x1b5e176d927f8e9ab405058b2d2457392da3e20f328b16ddabcebc33eaac5fea",
"s": "0x4ba69724e8f69de52f0125ad8b3c5c2cef33019bac3249e2c0a2192766d1721c",
"to": "0xf02c1c8e6114b1dbe8937a39260b5b0a374432bb",
"transactionIndex": "0x41",
"v": "0x25",
"value": "0xf3dbb76162000"
}
}
eth_getTransactionCount
Description
Returns the number of transactions sent from an address
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | address to query for sent transactions |
2 | {Quantity |string |Block Identifier } | block number, or one of "latest" , "earliest" or "pending" , or a block identifier as described in Block Identifier |
Returns
{Quantity
} - number of transactions sent from the specified address
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getTransactionCount",
"params": ["0xc94770007dda54cF92009BFF0dE90c06F603a09f", "latest"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x1"
}
eth_getTransactionReceipt
Description
Returns the receipt of a transaction specified by hash
Note: Transaction receipts are unavailable for pending transactions.
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | hash of a transaction |
Returns
{null|object
} - null
if no transaction is found, otherwise a transaction receipt object with the following members:
- {
Data
}blockHash
- hash of block containing this transaction - {
Data
}contractAddress
- address of new contract ornull
if no contract was created - {
Data
}from
- transaction sender - {
Data
}logsBloom
- logs bloom filter - {
Data
}to
- transaction recipient ornull
if deploying a contract - {
Data
}transactionHash
- hash of this transaction - {
Quantity
}blockNumber
- number of block containing this transaction - {
Quantity
}cumulativeGasUsed
- gas used by this and all preceding transactions in this block - {
Quantity
}gasUsed
- gas used by this transaction - {
Quantity
}status
-1
if this transaction was successful or0
if it failed - {
Quantity
}transactionIndex
- index of this transaction in the block - {
Array<Log>
}logs
- list of log objects generated by this transaction
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getTransactionReceipt",
"params": ["0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": {
"blockHash": '0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b',
"blockNumber": '0xb',
"contractAddress": '0xb60e8dd61c5d32be8058bb8eb970870f07233155',
"cumulativeGasUsed": '0x33bc',
"gasUsed": '0x4dc',
"logs": [],
"logsBloom": "0x00...0",
"status": "0x1",
"transactionHash": '0xb903239f8543d04b5dc1ba6579132b143087c68db1b2168786408fcbce568238',
"transactionIndex": '0x1'
}
}
eth_getUncleByBlockHashAndIndex
Description
Returns information about an uncle specified by block hash and uncle index position
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | hash of a block |
2 | {Quantity } | index of uncle |
Returns
{null|object
} - null
if no block or uncle is found, otherwise an uncle object with the following members:
- {
Data
}extraData
- "extra data" field of this block - {
Data
}hash
- block hash ornull
if pending - {
Data
}logsBloom
- logs bloom filter ornull
if pending - {
Data
}miner
- address that received this block's mining rewards - {
Data
}nonce
- proof-of-work hash ornull
if pending - {
Data
}parentHash
- parent block hash - {
Data
}receiptsRoot
-root of the this block's receipts trie - {
Data
}sha3Uncles
- SHA3 of the uncles data in this block - {
Data
}stateRoot
- root of this block's final state trie - {
Data
}transactionsRoot
- root of this block's transaction trie - {
Quantity
}difficulty
- difficulty for this block - {
Quantity
}gasLimit
- maximum gas allowed in this block - {
Quantity
}gasUsed
- total used gas by all transactions in this block - {
Quantity
}number
- block number ornull
if pending - {
Quantity
}size
- size of this block in bytes - {
Quantity
}timestamp
- unix timestamp of when this block was collated - {
Quantity
}totalDifficulty
- total difficulty of the chain until this block - {
Array<Transaction>
}uncles
- list of uncle hashes
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getUncleByBlockHashAndIndex",
"params": ["0xc6ef2fc5426d6ad6fd9e2a26abeab0aa2411b7ab17f30a99d3cb96aed1d1055b", "0x0"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": {
"difficulty": "0x027f07",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x9f759",
"gasUsed": "0x9f759",
"hash": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"miner": "0x4e65fda2159562a496f9f3522f89122a3088497a",
"nonce": "0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
"number": "0x1b4",
"parentHash": "0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x027f07",
"stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff",
"timestamp": "0x54e34e8e"
"totalDifficulty": "0x027f07",
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles": []
}
}
eth_getUncleByBlockNumberAndIndex
Description
Returns information about an uncle specified by block number and uncle index position
Parameters
# | Type | Description |
---|---|---|
1 | {Quantity |string } | block number, or one of "latest" , "earliest" or "pending" |
2 | {Quantity } | index of uncle |
Returns
{null|object
} - null
if no block or uncle is found, otherwise an uncle object with the following members:
- {
Data
}extraData
- "extra data" field of this block - {
Data
}hash
- block hash ornull
if pending - {
Data
}logsBloom
- logs bloom filter ornull
if pending - {
Data
}miner
- address that received this block's mining rewards - {
Data
}nonce
- proof-of-work hash ornull
if pending - {
Data
}parentHash
- parent block hash - {
Data
}receiptsRoot
-root of the this block's receipts trie - {
Data
}sha3Uncles
- SHA3 of the uncles data in this block - {
Data
}stateRoot
- root of this block's final state trie - {
Data
}transactionsRoot
- root of this block's transaction trie - {
Quantity
}difficulty
- difficulty for this block - {
Quantity
}gasLimit
- maximum gas allowed in this block - {
Quantity
}gasUsed
- total used gas by all transactions in this block - {
Quantity
}number
- block number ornull
if pending - {
Quantity
}size
- size of this block in bytes - {
Quantity
}timestamp
- unix timestamp of when this block was collated - {
Quantity
}totalDifficulty
- total difficulty of the chain until this block - {
Array<Transaction>
}uncles
- list of uncle hashes
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getUncleByBlockNumberAndIndex",
"params": ["0x29c", "0x0"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": {
"difficulty": "0x027f07",
"extraData": "0x0000000000000000000000000000000000000000000000000000000000000000",
"gasLimit": "0x9f759",
"gasUsed": "0x9f759",
"hash": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"logsBloom": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331",
"miner": "0x4e65fda2159562a496f9f3522f89122a3088497a",
"nonce": "0xe04d296d2460cfb8472af2c5fd05b5a214109c25688d3704aed5484f9a7792f2",
"number": "0x1b4",
"parentHash": "0x9646252be9520f6e71339a8df9c55e4d7619deeb018d2a3f2d21fc165dde5eb5",
"sha3Uncles": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
"size": "0x027f07",
"stateRoot": "0xd5855eb08b3387c0af375e9cdb6acfc05eb8f519e419b874b6ff2ffda7ed1dff",
"timestamp": "0x54e34e8e"
"totalDifficulty": "0x027f07",
"transactionsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"uncles": []
}
}
eth_getUncleCountByBlockHash
Description
Returns the number of uncles in a block specified by block hash
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | hash of a block |
Returns
{Quantity
} - number of uncles in the specified block
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getUncleCountByBlockHash",
"params": ["0xc94770007dda54cF92009BFF0dE90c06F603a09f"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0xc"
}
eth_getUncleCountByBlockNumber
Description
Returns the number of uncles in a block specified by block number
Parameters
# | Type | Description |
---|---|---|
1 | {Quantity |string } | block number, or one of "latest" , "earliest" or "pending" |
Returns
{Quantity
} - number of uncles in the specified block
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getUncleCountByBlockNumber",
"params": ["0xe8"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x1"
}
eth_getWork
Description
Returns a list containing relevant information for proof-of-work
Parameters
none
Returns
{Data[]
} - array with the following items:
- {
Data
} - current block header pow-hash - {
Data
} - seed hash used for the DAG - {
Data
} - boundary condition ("target"), 2^256 / difficulty
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_getWork",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": [
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"0x5EED00000000000000000000000000005EED0000000000000000000000000000",
"0xd1ff1c01710000000000000000000000d1ff1c01710000000000000000000000"
]
}
eth_hashrate
Description
Returns the number of hashes-per-second this node is mining at
Parameters
(none)
Returns
{Quantity
} - number of hashes-per-second
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_hashrate",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x38a"
}
eth_mining
Description
Determines if this client is mining new blocks
Parameters
(none)
Returns
{boolean
} - true
if this client is mining or false
if it is not mining
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_mining",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": true
}
eth_newBlockFilter
Description
Creates a filter to listen for new blocks that can be used with eth_getFilterChanges
Parameters
none
Returns
{Quantity
} - ID of the newly-created filter that can be used with eth_getFilterChanges
Example
# Request
curl -X POST --data '{
"id": 1337
"jsonrpc": "2.0",
"method": "eth_newBlockFilter",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x1"
}
eth_newFilter
Description
Creates a filter to listen for specific state changes that can then be used with eth_getFilterChanges
Parameters
# | Type | Description |
---|---|---|
1 | {object } | @property {Quantity |string } [fromBlock] - block number, or one of "latest" , "earliest" or "pending" @property { Quantity |string } [toBlock] - block number, or one of "latest" , "earliest" or "pending" @property { Data |Data[] } [address] - contract address or a list of addresses from which logs should originate@property { Data[] } [topics] - list of order-dependent topics |
Note: 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)"
Returns
{Quantity
} - ID of the newly-created filter that can be used with eth_getFilterChanges
Example
# Request
curl -X POST --data '{
"id": 1337
"jsonrpc": "2.0",
"method": "eth_newFilter",
"params": [{
"topics": ["0x0000000000000000000000000000000000000000000000000000000012341234"]
}]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x1"
}
eth_newPendingTransactionFilter
Description
Creates a filter to listen for new pending transactions that can be used with eth_getFilterChanges
Parameters
none
Returns
{Quantity
} - ID of the newly-created filter that can be used with eth_getFilterChanges
Example
# Request
curl -X POST --data '{
"id": 1337
"jsonrpc": "2.0",
"method": "eth_newPendingTransactionFilter",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x1"
}
eth_protocolVersion
Description
Returns the current Ethereum protocol version
Parameters
(none)
Returns
{string
} - current Ethereum protocol version
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_protocolVersion",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "54"
}
eth_sendRawTransaction
Description
Sends and already-signed transaction to the network
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | signed transaction data |
Returns
{Data
} - transaction hash, or the zero hash if the transaction is not yet available
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_sendRawTransaction",
"params": ["0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}
eth_sendTransaction
Description
创建、签署并向网络发送新交易
Parameters
# | Type | Description |
---|---|---|
1 | {object } | @property {Data } from - transaction sender@property { Data } [to] - transaction recipient@property { Quantity } [gas="0x15f90"] - gas provided for transaction execution@property { Quantity } [gasPrice] - price in wei of each gas used@property { Quantity } [value] - value in wei sent with this transaction@property { Data } [data] - contract code or a hashed method call with encoded args@property { Quantity } [nonce] - unique number identifying this transaction |
Returns
{Data
} - transaction hash, or the zero hash if the transaction is not yet available
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_sendTransaction",
"params": [{
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"gas": "0x76c0",
"gasPrice": "0x9184e72a000",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"value": "0x9184e72a"
}]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0xe670ec64341771606e55d6b4ca35a1a6b75ee3d5145a99d05921026d1527331"
}
eth_sign
Description
以 keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))
的形式计算以太坊特定的签名
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | address to use for signing |
2 | {Data } | data to sign |
Returns
{Data
} - signature hash of the provided data
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_sign",
"params": ["0x9b2055d370f73ec7d8a03e965129118dc8f5bf83", "0xdeadbeaf"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"
}
eth_signTransaction
Description
使用 eth_sendRawTransaction
签署可以在稍后提交到网络的交易
Parameters
# | Type | Description |
---|---|---|
1 | {object } | @property {Data } from - transaction sender@property { Data } [to] - transaction recipient@property { Quantity } [gas="0x15f90"] - gas provided for transaction execution@property { Quantity } [gasPrice] - price in wei of each gas used@property { Quantity } [value] - value in wei sent with this transaction@property { Data } [data] - contract code or a hashed method call with encoded args@property { Quantity } [nonce] - unique number identifying this transaction |
Returns
{Data
} - signature hash of the transaction object
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_signTransaction",
"params": [{
"data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675",
"from": "0xb60e8dd61c5d32be8058bb8eb970870f07233155",
"gas": "0x76c0",
"gasPrice": "0x9184e72a000",
"to": "0xd46e8dd67c5d32be8058bb8eb970870f07244567",
"value": "0x9184e72a"
}]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0xa3f20717a250c2b0b729b7e5becbff67fdaef7e0699da4de7ca5895b02a170a12d887fd3b17bfdce3481f10bea41f45ba9f709d39ce8325427b57afcfc994cee1b"
}
eth_signTypedData
Description
以 keccak256("\x19Ethereum Signed Message:\n" + len(message) + message))
的形式计算以太坊特定的签名
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | address to use for signing |
2 | {Data } | message to sign containing type information, a domain separator, and data |
**注意:**客户端开发人员应参考 EIP-712 以了解有关 编码和签名数据 的完整语义。 Dapp 开发者应参考 EIP-712 RPC 方法输入参数 的预期结构。
Returns
{Data
} - signature hash of the provided message
Example
# Request
curl -X POST --data '{
"id": 1337
"jsonrpc": "2.0",
"method": "eth_signTypedData",
"params": ["0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826", {
"types": {
"EIP712Domain": [{
"name": "name",
"type": "string"
}, {
"name": "version",
"type": "string"
}, {
"name": "chainId",
"type": "uint256"
}, {
"name": "verifyingContract",
"type": "address"
}],
"Person": [{
"name": "name",
"type": "string"
}, {
"name": "wallet",
"type": "address"
}],
"Mail": [{
"name": "from",
"type": "Person"
}, {
"name": "to",
"type": "Person"
}, {
"name": "contents",
"type": "string"
}]
},
"primaryType": "Mail",
"domain": {
"name": "Ether Mail",
"version": "1",
"chainId": 1,
"verifyingContract": "0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"
},
"message": {
"from": {
"name": "Cow",
"wallet": "0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826"
},
"to": {
"name": "Bob",
"wallet": "0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"
},
"contents": "Hello, Bob!"
}
}]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": "0x4355c47d63924e8a72e509b65029052eb6c299d53a04e167c5775fd466751c9d07299936d304c153f6443dfa05f40ff007d72911b6f72307f996231605b915621c"
}
eth_submitHashrate
Description
Submit a mining hashrate
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | hash rate |
2 | {Data } | random ID identifying this node |
Returns
{boolean
} - true
if submitting went through successfully, false
otherwise
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_submitHashrate",
"params": [
"0x0000000000000000000000000000000000000000000000000000000000500000",
"0x59daa26581d0acd1fce254fb7e85952f4c09d0915afd33d3886cd914bc7d283c"
]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": true
}
eth_submitWork
Description
Submit a proof-of-work solution
Parameters
# | Type | Description |
---|---|---|
1 | {Data } | nonce found |
2 | {Data } | header's pow-hash |
3 | {Data } | mix digest |
Returns
{boolean
} - true
if the provided solution is valid, false
otherwise
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_submitWork",
"params": [
"0x0000000000000001",
"0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef",
"0xD1GE5700000000000000000000000000D1GE5700000000000000000000000000"
]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": true
}
eth_syncing
Description
Returns information about the status of this client's network synchronization
Parameters
(none)
Returns
boolean|object - false
if this client is not syncing with the network, otherwise an object with the following members:
- {
Quantity
}currentBlock
- number of the most-recent block synced - {
Quantity
}highestBlock
- number of latest block on the network - {
Quantity
}startingBlock
- block number at which syncing started
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_syncing",
"params": []
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": {
"currentBlock": '0x386',
"highestBlock": '0x454',
"startingBlock": '0x384'
}
}
eth_uninstallFilter
Description
根据过滤器 ID 销毁过滤器
**注意:**只有在不再需要过滤器及其通知时才应调用它。 如果在一段时间内未使用“eth_getFilterChanges”检索过滤器的通知,这也会在过滤器上自动调用。
Parameters
# | Type | Description |
---|---|---|
1 | {Quantity } | ID of the filter to destroy |
Returns
{boolean
} - true
if the filter is found and successfully destroyed or false
if it is not
Example
# Request
curl -X POST --data '{
"id": 1337,
"jsonrpc": "2.0",
"method": "eth_uninstallFilter",
"params": ["0xb"]
}' <url>
# Response
{
"id": 1337,
"jsonrpc": "2.0",
"result": true
}
理由 (Rationale)
以太坊作为企业级应用程序平台的有效性在很大程度上取决于其提供可靠且可预测的开发人员体验的能力。 当前一代以太坊客户端创建的节点公开具有不同方法签名的 RPC 端点; 这迫使应用程序解决方法不一致的问题,以保持与各种以太坊 RPC 实现的兼容性。
以太坊客户端开发者和下游 dapp 开发者都缺乏正式的以太坊 RPC 规范。 该提案以一种可通过传统 EIP 流程进行版本控制和修改的方式对此类规范进行了标准化。
向后兼容性 (Backwards compatibility)
该提案要求任何公开的 RPC 接口都遵守该规范,从而影响以太坊客户端开发人员。 该提案要求应用程序中当前使用的任何 RPC 调用都根据该规范进行,从而影响 dapp 开发人员。
执行 (Implementation)
当前一代的以太坊客户端包括几个试图公开此 RPC 规范的实现:
Client Name | Language | Homepage |
---|---|---|
Geth | Go | geth.ethereum.org (opens in a new tab) |
Parity | Rust | parity.io/ethereum (opens in a new tab) |
Aleth | C++ | cpp-ethereum.org (opens in a new tab) |
版权所有 (Copyright)
通过 CC0 (opens in a new tab) 放弃版权和相关权利。