**图例**:
- **Y** - 可用
- **Stub** - 为兼容性返回成功,但值为 null/empty/zero
- **N** - 未实现 - 返回错误或不可用
本文档列出了所有 Ethereum JSON-RPC 方法及其在 Cosmos EVM 中的实现状态。有关官方的 Ethereum JSON-RPC 规范,请参阅 Ethereum Execution APIs 仓库。
命名空间配置:默认情况下,仅启用 eth、net 和 web3 命名空间。若要启用其他命名空间,例如 personal、txpool、debug 或 miner,你必须在节点的 app.toml 配置中进行设置。

未实现的命名空间

以下命名空间在 Cosmos EVM 中未实现,但可能会出现在交互式浏览器中,以便针对其他网络进行测试:
debug 命名空间为开发提供调试与追踪工具。Cosmos EVM 已实现部分追踪和性能分析方法。许多方法需要启用 Profiling 配置。
admin 命名空间用于节点管理和对等节点管理。Cosmos 节点通过 Cosmos SDK CLI 和配置文件使用不同的管理机制。
miner 命名空间控制工作量证明挖矿操作。Cosmos EVM 使用 CometBFT 拜占庭容错共识,而不是挖矿。
engine 命名空间实现 Ethereum 在合并后的 Engine API,用于与共识层通信。Cosmos EVM 使用 CometBFT 共识,而不是信标链。
clique 命名空间为私有网络实现权威证明共识。Cosmos EVM 使用 CometBFT 共识。
les 命名空间实现 Light Ethereum Subprotocol。Cosmos 通过 IBC 采用不同的轻客户端架构。

端点

方法命名空间状态公开说明
web3_clientVersionWeb3YY
web3_sha3Web3YY
net_versionNetYY
net_peerCountNet桩实现Y返回 “0x0”
net_listeningNet桩实现Y返回 true
eth_protocolVersionEthYY
eth_syncingEth桩实现Y返回 false
eth_gasPriceEth桩实现Y返回 “0x0”
eth_accountsEthYY
eth_blockNumberEthYY
eth_getBalanceEthYY
eth_getStorageAtEthYY
eth_getTransactionCountEthYY
eth_getBlockTransactionCountByNumberEth桩实现Y返回 “0x0”
eth_getBlockTransactionCountByHashEth桩实现Y返回 “0x0”
eth_getCodeEth桩实现Y返回 “0x”
eth_signEthYN
eth_sendTransactionEthNN未实现
eth_sendRawTransactionEthYY
eth_callEth桩实现Y返回 “0x”
eth_createAccessListEthYYEIP-2930
eth_estimateGasEthYY已优化
eth_getBlockByNumberEthYY
eth_getBlockByHashEthYY
eth_getTransactionByHashEth桩实现Y返回 null
eth_getTransactionByBlockHashAndIndexEth桩实现Y返回 null
eth_getTransactionReceiptEth桩实现Y返回 null
eth_newFilterEthYY
eth_newBlockFilterEthYY
eth_newPendingTransactionFilterEthYY
eth_uninstallFilterEth桩实现Y返回 true
eth_getFilterChangesEth桩实现Y返回空数组
eth_getFilterLogsEth桩实现Y返回空数组
eth_getLogsEth桩实现Y返回 []
eth_getTransactionByBlockNumberAndIndexEth桩实现Y返回 null
eth_getWorkEthNY未实现
eth_submitWorkEthNY未实现
eth_submitHashrateEthNY未实现
eth_getCompilersEthNN未实现
eth_compileLLLEthNN未实现
eth_compileSolidityEthNN未实现
eth_compileSerpentEthNN未实现
eth_signTransactionEthNN未实现
eth_miningEthYY已弃用 - 始终为 false
eth_coinbaseEthYY在 geth 中已弃用
eth_hashrateEthYY已弃用 - 始终为 0
eth_getUncleCountByBlockHashEth桩实现Y始终为 “0x0”
eth_getUncleCountByBlockNumberEth桩实现Y始终为 “0x0”
eth_getUncleByBlockHashAndIndexEth桩实现Y始终为 null
eth_getUncleByBlockNumberAndIndexEth桩实现Y始终为 null
eth_getProofEthYY
eth_feeHistoryEthYYEIP-1559
eth_maxPriorityFeePerGasEth桩实现Y返回 “0x0”
eth_chainIdEthYY
eth_getBlockReceiptsEth桩实现Y返回空数组
eth_resendEthNY需要 nonce 参数
eth_createAccessListEthYYEIP-2930
eth_blobBaseFeeEthNYEIP-4844 未实现
eth_fillTransactionEthNY未实现
eth_signTypedDataEthNN需要 domain 参数
| eth_signTypedData_v3 | Eth | N | N | 未实现 | | eth_signTypedData_v4 | Eth | N | N | 未实现 | | eth_pendingTransactions | Eth | N | Y | 未实现 | | eth_getPendingTransactions | Eth | Y | Y | 在 geth 中已弃用 | | eth_getHeaderByHash | Eth | Y | Y | | | eth_getHeaderByNumber | Eth | Y | Y | | | eth_simulateV1 | Eth | N | Y | Geth 特有,未实现 | | eth_getRawTransactionByHash | Eth | N | Y | 未实现 | | eth_getRawTransactionByBlockNumberAndIndex | Eth | N | Y | 未实现 | | eth_getRawTransactionByBlockHashAndIndex | Eth | N | Y | 未实现 | | eth_subscribe | Websocket | Y | Y | 仅限 WebSocket | | eth_unsubscribe | Websocket | Y | Y | 仅限 WebSocket | | personal_importRawKey | Personal | N | N | 需要有效的十六进制密钥 | | personal_listAccounts | Personal | Y | N | 需要 v0.4.x mempool | | personal_lockAccount | Personal | Stub | N | 始终为 false | | personal_newAccount | Personal | Y | N | 需要 v0.4.x mempool | | personal_unlockAccount | Personal | Stub | N | 始终为 false | | personal_sendTransaction | Personal | N | N | 未实现 | | personal_sign | Personal | Y | N | 需要 v0.4.x mempool | | personal_ecRecover | Personal | N | N | 需要 65 字节签名 | | personal_initializeWallet | Personal | N | N | 未实现 | | personal_unpair | Personal | N | N | 未实现 | | personal_listWallets | Personal | Stub | N | 返回 null | | personal_signTransaction | Personal | N | N | 未实现 | | personal_signAndSendTransaction | Personal | N | N | 未实现 | | personal_openWallet | Personal | N | N | 未实现 | | personal_deriveAccount | Personal | N | N | 未实现 | | db_putString | DB | N | N | 已弃用 | | db_getString | DB | N | N | 已弃用 | | db_putHex | DB | N | N | 已弃用 | | db_getHex | DB | N | N | 已弃用 | | shh_post | SSH | N | N | 已弃用 | | shh_version | SSH | N | N | 已弃用 | | shh_newIdentity | SSH | N | N | 已弃用 | | shh_hasIdentity | SSH | N | N | 已弃用 | | shh_newGroup | SSH | N | N | 已弃用 | | shh_addToGroup | SSH | N | N | 已弃用 | | shh_newFilter | SSH | N | N | 已弃用 | | shh_uninstallFilter | SSH | N | N | 已弃用 | | shh_getFilterChanges | SSH | N | N | 已弃用 | | shh_getMessages | SSH | N | N | 已弃用 | | admin_addPeer | Admin | N | N | 返回 undefined | | admin_removePeer | Admin | N | N | 返回 undefined | | admin_datadir | Admin | N | N | 返回 undefined | | admin_nodeInfo | Admin | N | N | 返回 undefined | | admin_peers | Admin | N | N | 返回 undefined | | admin_startHTTP | Admin | N | N | 返回 undefined | | admin_startWS | Admin | N | N | 返回 undefined | | admin_stopHTTP | Admin | N | N | 返回 undefined | | admin_stopWS | Admin | N | N | 返回 undefined | | admin_addTrustedPeer | Admin | N | N | 返回 undefined | | admin_removeTrustedPeer | Admin | N | N | 返回 undefined | | admin_startRPC | Admin | N | N | 返回 undefined | | admin_stopRPC | Admin | N | N | 返回 undefined | | admin_exportChain | Admin | N | N | 返回 undefined | | admin_importChain | Admin | N | N | 返回 undefined | | admin_sleepBlocks | Admin | N | N | 返回 undefined | | admin_clearPeerBanList | Admin | N | N | 返回 undefined | | admin_listPeerBanList | Admin | N | N | 返回 undefined | | clique_getSnapshot | Clique | N | N | 返回 undefined | | clique_getSnapshotAtHash | Clique | N | N | 返回 undefined | | clique_getSigners | Clique | N | N | 返回 undefined | | clique_getSignersAtHash | Clique | N | N | 返回 undefined | | clique_propose | Clique | N | N | 返回 undefined | | clique_discard | Clique | N | N | 返回 undefined | | clique_status | Clique | N | N | 返回 undefined | | clique_getSigner | Clique | N | N | 返回 undefined | | debug_backtraceAt | Debug | N | N | 返回 undefined | | debug_blockProfile | Debug | Y | N | | | debug_cpuProfile | Debug | Y | N | | | debug_dumpBlock | Debug | N | N | 返回 undefined | | debug_gcStats | Debug | Y | N | | | debug_getBlockRlp | Debug | N | N | 需要 uint64 参数 | | debug_goTrace | Debug | Y | N | | | debug_freeOSMemory | Debug | Y | N | | | debug_memStats | Debug | Y | N | | | debug_mutexProfile | Debug | Y | N | | | debug_seedHash | Debug | N | N | 未实现 | | debug_setHead | Debug | N | N | 未实现 | | debug_setBlockProfileRate | Debug | Y | N | | | debug_setGCPercent | Debug | Y | N | | | debug_setMutexProfileFraction | Debug | Y | N | | | debug_stacks | Debug | Y | N | | | debug_startCPUProfile | Debug | Y | N | | | debug_startGoTrace | Debug | Y | N | | | debug_stopCPUProfile | Debug | Y | N | | | debug_stopGoTrace | Debug | Y | N | | | debug_traceBlock | Debug | Y | N | | | debug_traceBlockByNumber | Debug | Y | N | | | debug_traceBlockByHash | Debug | Y | N | | | debug_traceBlockFromFile | Debug | N | N | 返回 undefined | | debug_standardTraceBlockToFile | Debug | N | N | 返回 undefined | | debug_standardTraceBadBlockToFile | Debug | N | N | 返回 undefined | | debug_traceTransaction | Debug | Y | N | | | debug_traceCall | Debug | Y | N | | | debug_traceChain | Debug | N | N | 返回 undefined | | debug_traceBadBlock | Debug | N | N | 返回 undefined | | debug_verbosity | Debug | N | N | 未实现 | | debug_vmodule | Debug | N | N | 未实现 | | debug_writeBlockProfile | Debug | Y | N | | | debug_writeMemProfile | Debug | Y | N | | | debug_writeMutexProfile | Debug | Y | N | | | debug_getRawBlock | Debug | N | N | 未实现 | | debug_getRawHeader | Debug | N | N | 未实现 | | debug_getRawReceipts | Debug | N | N | 未实现 | | debug_getRawTransaction | Debug | N | N | 未实现 | | debug_printBlock | Debug | Y | N | | | debug_getHeaderRlp | Debug | N | N | 需要 uint64 参数 | | debug_intermediateRoots | Debug | Y | N | 返回空哈希 | | debug_getBadBlocks | Debug | N | N | 未实现 | | debug_storageRangeAt | Debug | N | N | 未实现 | | debug_getModifiedAccountsByNumber | Debug | N | N | 未实现 | | debug_getModifiedAccountsByHash | Debug | N | N | 未实现 | | les_serverInfo | Les | N | N | 返回 undefined | | les_clientInfo | Les | N | N | 返回 undefined | | les_priorityClientInfo | Les | N | N | 返回 undefined | | les_addBalance | Les | N | N | 返回 undefined | | les_setClientParams | Les | N | N | 返回 undefined | | les_setDefaultParams | Les | N | N | 返回 undefined | | les_latestCheckpoint | Les | N | N | 返回 undefined | | les_getCheckpoint | Les | N | N | 返回 undefined | | les_getCheckpointContractAddress | Les | N | N | 返回 undefined | | txpool_content | TxPool | Y | Y | 参见实验性内存池 | | txpool_contentFrom | TxPool | Y | Y | 参见实验性内存池 | | txpool_inspect | TxPool | Y | Y | 参见实验性内存池 | | txpool_status | TxPool | Y | Y | 参见实验性内存池 | | trace_callMany | Trace | N | N | 未实现 | | eth_signTypedData | Eth | W | N | EIP-712 部分支持 | | eth_fillTransaction | Eth | Y | Y | | | eth_getTransactionLogs | Eth | Y | Y | Cosmos 特有| | miner_start | Miner | N | N | 返回 undefined | | miner_stop | Miner | N | N | 返回 undefined | | miner_setEtherbase | Miner | N | N | 返回 undefined | | miner_setGasPrice | Miner | N | N | 返回 undefined | | miner_setGasLimit | Miner | N | N | 返回 undefined | | miner_setExtra | Miner | N | N | 返回 undefined | | miner_setRecommitInterval | Miner | N | N | 返回 undefined | | miner_getHashrate | Miner | N | N | 返回 undefined | | engine_newPayloadV1 | Engine | N | N | 返回 undefined | | engine_newPayloadV2 | Engine | N | N | 返回 undefined | | engine_newPayloadV3 | Engine | N | N | 返回 undefined | | engine_forkchoiceUpdatedV1 | Engine | N | N | 返回 undefined | | engine_forkchoiceUpdatedV2 | Engine | N | N | 返回 undefined | | engine_forkchoiceUpdatedV3 | Engine | N | N | 返回 undefined | | engine_getPayloadV1 | Engine | N | N | 返回 undefined | | engine_getPayloadV2 | Engine | N | N | 返回 undefined | | engine_getPayloadV3 | Engine | N | N | 返回 undefined | | engine_exchangeCapabilities | Engine | N | N | 返回 undefined | | engine_exchangeTransitionConfigurationV1 | Engine | N | N | 返回 undefined | | engine_getPayloadBodiesByHashV1 | Engine | N | N | 返回 undefined | | engine_getPayloadBodiesByRangeV1 | Engine | N | N | 返回 undefined | | engine_getBlobsV1 | Engine | N | N | 返回 undefined | | trace_call | Trace | N | N | 未实现 | | trace_rawTransaction | Trace | N | N | 未实现 | | trace_replayBlockTransactions | Trace | N | N | 未实现 | | trace_replayTransaction | Trace | N | N | 未实现 | | trace_block | Trace | N | N | 未实现 | | trace_filter | Trace | N | N | 未实现 | | trace_get | Trace | N | N | 未实现 | | trace_transaction | Trace | N | N | 未实现 |
区块号可以输入为十六进制字符串、"earliest"、"latest" 或 "pending"。
EIP-1559 支持:Cosmos EVM 支持 EIP-1559 交易类型以及 eth_maxPriorityFeePerGas,但 eth_feeHistory 尚未实现。共识差异:由于使用的是 CometBFT BFT 共识,而不是工作量证明/权益证明:
  • 与 uncle 相关的方法始终返回 0 或 null
  • 不会发生区块重组
  • Engine API(engine_*)不适用,CometBFT 负责处理共识
未实现的方法:
  • eth_createAccessList(EIP-2930)- 访问列表交易
  • eth_feeHistory - EIP-1559 的手续费历史
  • eth_getFilterChanges / eth_getFilterLogs - 过滤器管理问题
  • eth_fillTransaction - 交易填充工具
  • eth_resend - 交易重发工具
  • personal_sendTransaction / personal_ecRecover - Personal 命名空间方法
  • personal_lockAccount - 始终返回 false(不支持)
  • debug_getRaw* 方法 - 原始数据访问方法
  • debug_printBlock - 区块打印工具
  • trace_* 方法 - 高级追踪功能
  • engine_* 方法 - 合并后的 Engine API(改用 CometBFT)
  • admin_* 方法 - 节点管理
  • les_* 方法 - 轻量以太坊子协议
  • clique_* 方法 - 权威证明共识
部分实现:
  • eth_getProof - 要求区块高度 > 2
  • eth_signTypedData(EIP-712)- 部分实现
  • eth_subscribe - 支持 newHeads、logs 和 newPendingTransactions,但不支持 syncing
  • personal_unlockAccount - 始终返回 false
  • debug_traceTransaction - 在区块高度方面存在问题
有关 Cosmos EVM 与标准 Ethereum 实现差异的更多细节,请参见与标准 EVM 的差异。

示例

下面列出了各命名空间中的 RPC 方法、参数以及响应示例。

Web3 方法

web3_clientVersion

获取 web3 客户端版本。

参数 (0)

结果

{"jsonrpc":"2.0","id":1,"result":"Cosmos/0.1.3+/linux/go1.18"}

客户端示例

Shell HTTP
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "web3_clientVersion", "params": []}'
WebSocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "web3_clientVersion", "params": []}'
JavaScript 控制台
web3.clientVersion();

web3_sha3

返回给定数据的 Keccak-256(不是标准化的 SHA3-256)。

参数 (1)

1: input hexutil.Bytes
  • 必填:[Y] 是

结果

{"jsonrpc":"2.0","id":1,"result":"0x1b84adea42d5b7d192fd8a61a85b25abe0757e9a65cab1da470258914053823f"}

客户端示例

Shell HTTP
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "web3_sha3", "params": [<input>]}'
WebSocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "web3_sha3", "params": [<input>]}'
JavaScript 控制台
web3.sha3(input);

Net 方法

net_version

返回当前网络 ID。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"8"}

net_peerCount

返回当前连接到客户端的对等节点数量。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":23}

net_listening

返回客户端是否正在主动监听网络连接。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":true}

Eth 方法

eth_protocolVersion

返回当前的 Ethereum 协议版本。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_protocolVersion","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x3f"}

eth_syncing

同步状态对象可能需要根据 cometbft 同步协议的细节而有所不同。不过,synced 结果只是一个布尔值,可以很容易地从 cometbft 的内部同步状态中推导出来。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":false}

eth_gasPrice

返回默认 EVM 面额参数中的当前 gas 价格。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0"}

eth_accounts

返回所有 eth 账户组成的数组。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":["0x3b7252d007059ffc82d16d022da3cbf9992d2f70","0xddd64b4712f7c8f1ace3c145c950339eddaf221d","0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0"]}

eth_blockNumber

返回当前区块高度。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x66"}

eth_getBalance

返回给定账户地址在指定区块编号下的账户余额。

参数

  • 账户地址
  • 区块编号或区块哈希(EIP-1898)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x36354d5575577c8000"}

eth_getStorageAt

返回给定账户地址的存储地址。

参数

  • 账户地址
  • 存储中位置对应的整数
  • 区块编号或区块哈希(EIP-1898)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getStorageAt","params":["0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0", "0", "latest"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000000000000000000"}

eth_getTransactionCount

返回给定账户地址在指定区块编号下的交易总数。

参数

  • 账户地址
  • 区块编号或区块哈希(EIP-1898)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0x7bf7b17da59880d9bcca24915679668db75f9397", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x8"}

eth_getBlockTransactionCountByNumber

返回给定区块编号的交易总数。

参数

  • 区块编号
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params":["0x1"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"difficulty":null,"extraData":"0x0","gasLimit":"0xffffffff","gasUsed":"0x0","hash":"0x8101cc04aea3341a6d4b3ced715e3f38de1e72867d6c0db5f5247d1a42fbb085","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","nonce":null,"number":"0x17d","parentHash":"0x70445488069d2584fea7d18c829e179322e2b2185b25430850deced481ca2e77","sha3Uncles":null,"size":"0x1df","stateRoot":"0x269bb17fe7adb8dd5f15f57b717979f82078d6b7a675c1ba1b0da2d27e415fcc","timestamp":"0x5f5ba97c","totalDifficulty":null,"transactions":[],"transactionsRoot":"0x","uncles":[]}}

eth_getBlockTransactionCountByHash

返回给定区块哈希的交易总数。

参数

  • 区块哈希
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params":["0x8101cc04aea3341a6d4b3ced715e3f38de1e72867d6c0db5f5247d1a42fbb085"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x3"}

eth_getCode

返回给定账户地址在指定区块编号下的代码。

参数

  • 账户地址
  • 区块编号或区块哈希(EIP-1898)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getCode","params":["0x7bf7b17da59880d9bcca24915679668db75f9397", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xef616c92f3cfc9e92dc270d6acff9cea213cecc7020a76ee4395af09bdceb4837a1ebdb5735e11e7d3adb6104e0c3ac55180b4ddf5e54d022cc5e8837f6a4f971b"}

eth_sign

sign 方法会按如下方式计算一个以太坊特定签名:sign(keccak256("\x19Ethereum Signed Message:\n" + len(message) + message)))。 为消息添加前缀后,计算得到的签名可以被识别为以太坊特定签名。这可以防止恶意 DApp 对任意数据(例如交易)进行签名,并利用该签名冒充受害者。
用于签名的地址必须已解锁。

参数

  • 账户地址
  • 待签名的消息
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sign","params":["0x3b7252d007059ffc82d16d022da3cbf9992d2f70", "0xdeadbeaf"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x909809c76ed2a5d38733de39207d0f411222b9b49c64a192bf649cb13f63f37b45acb4f6939facb4f1c277bc70fb00407564140c0f18600ac44388f2c1dfd1dc1b"}

eth_signTypedData

根据 EIP-712 对类型化结构化数据进行签名。与 eth_sign 相比,此方法提供了更安全的结构化数据签名方式。
实现说明:此方法要求类型化数据结构中提供格式正确的 domain 参数。如果没有 domain,将返回错误:“domain is undefined”。

参数

  • 账户地址(20 字节)
  • 包含以下内容的类型化数据对象:
    • domain:EIP-712 域分隔符
    • types:类型定义
    • primaryType:主类型名称
    • message:要签名的消息
// Request - Note: proper domain structure is required
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_signTypedData","params":["0x3b7252d007059ffc82d16d022da3cbf9992d2f70", {"domain":{"name":"Example","version":"1","chainId":1,"verifyingContract":"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"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"}]},"primaryType":"Person","message":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"}}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x..."}  // Returns signature

eth_sendTransaction

将交易从给定账户发送到另一个给定账户。

参数

  • 包含以下内容的对象: from:DATA,20 字节 - 发送交易的地址。 to:DATA,20 字节 - 交易指向的地址(创建新合约时可选)。 gas:QUANTITY - (可选,默认:90000)为交易执行提供的 gas 整数值。未使用的 gas 会被退回。 gasPrice:QUANTITY - (可选,默认:待定)每单位已支付 gas 使用的 gasPrice 整数值 value:QUANTITY - 随此交易发送的值 data:DATA - 合约的已编译代码,或调用的方法签名哈希及编码后的参数。详情参见 Ethereum Contract ABI。 nonce:QUANTITY - (可选)nonce 的整数值。这允许你覆盖自己使用相同 nonce 的待处理交易。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70", "to":"0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0", "value":"0x16345785d8a0000", "gasLimit":"0x5208", "gasPrice":"0x55ae82600"}],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x33653249db68ebe5c7ae36d93c9b2abc10745c80a72f591e296f598e2d4709f6"}

eth_sendRawTransaction

为已签名交易创建新的消息调用交易或合约创建交易。你可以使用 personal_sign 方法获取已签名交易数据。

参数

  • 已签名的交易数据
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xf9ff74c86aefeb5f6019d77280bbb44fb695b4d45cfe97e6eed7acd62905f4a85034d5c68ed25a2e7a8eeb9baf1b8401e4f865d92ec48c1763bf649e354d900b1c"],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000000000000000000"}

eth_call

立即执行一次新的消息调用,而不会在区块链上创建交易。

参数

  • 包含以下内容的对象: from:DATA,20 字节 - (可选)发送交易的地址。 to:DATA,20 字节 - 交易指向的地址。 gas:QUANTITY - 为交易执行提供的 gas。eth_call 消耗零 gas,但某些执行可能仍需要此参数。 gasPrice:QUANTITY - 每单位已支付 gas 使用的 gasPrice value:QUANTITY - 随此交易发送的值 data:DATA - (可选)方法签名的哈希及编码后的参数。详情参见 Solidity 文档中的 Ethereum Contract ABI
  • 区块号或区块哈希(EIP-1898)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"from":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70", "to":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d", "gas":"0x5208", "gasPrice":"0x55ae82600", "value":"0x16345785d8a0000", "data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"}, "0x0"],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x"}

eth_createAccessList

为交易创建访问列表。访问列表会指定交易将访问哪些地址和存储键,从而可能降低复杂交易的 gas 成本。 实现: rpc/backend/tx_info.go:396

参数

  • 包含交易数据的对象:
    • from:DATA,20 字节 - (可选)发送交易的地址
    • to:DATA,20 字节 - 交易指向的地址
    • gas:QUANTITY - (可选)执行所提供的 gas
    • gasPrice:QUANTITY - (可选)每单位 gas 的价格
    • value:QUANTITY - (可选)随交易发送的值
    • data:DATA - (可选)交易数据负载
  • 区块号或区块哈希(EIP-1898)

返回值

  • 包含以下内容的对象:
    • accessList:访问列表条目数组
      • address:DATA,20 字节 - 账户地址
      • storageKeys:DATA 数组 - 被访问的存储键
    • gasUsed:QUANTITY - 使用访问列表执行时消耗的 gas

客户端示例

Shell HTTP
curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"eth_createAccessList",
  "params":[{
    "from":"0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
    "to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "gas":"0x76c0",
    "gasPrice":"0x9184e72a000",
    "data":"0xa9059cbb000000000000000000000000a0b86a33e6d1cde81f9c1ce51dd74f3d1111bb9e0000000000000000000000000000000000000000000000000de0b6b3a7640000"
  }, "latest"],
  "id":1
}' -H "Content-Type: application/json" http://localhost:8545
WebSocket
wscat -c ws://localhost:8546 -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_createAccessList",
  "params": [{
    "from":"0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
    "to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "data":"0xa9059cbb000000000000000000000000a0b86a33e6d1cde81f9c1ce51dd74f3d1111bb9e0000000000000000000000000000000000000000000000000de0b6b3a7640000"
  }, "latest"]
}'
JavaScript 控制台
await provider.send("eth_createAccessList", [{
  from: "0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
  to: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
  data: "0xa9059cbb000000000000000000000000a0b86a33e6d1cde81f9c1ce51dd74f3d1111bb9e0000000000000000000000000000000000000000000000000de0b6b3a7640000"
}, "latest"]);

结果

使用示例

// Generate access list for optimization
const accessList = await provider.send("eth_createAccessList", [{
    to: contractAddress,
    data: contract.interface.encodeFunctionData("complexFunction", [arg1, arg2]),
    gasPrice: "0x" + gasPrice.toString(16)
}, "latest"]);

// Use access list in actual transaction for gas savings
const tx = await contract.complexFunction(arg1, arg2, {
    accessList: accessList.accessList,
    gasLimit: accessList.gasUsed
});

eth_estimateGas

返回发送该交易所需 gas 的估算值。

参数

  • 包含以下内容的对象: from:DATA,20 字节 - 发送交易的地址。 to:DATA,20 字节 - 交易指向的地址(创建新合约时可选)。 value:QUANTITY - 随此交易发送的值
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0", "to":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70", "value":"0x16345785d8a00000"}],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x1199b"}

eth_getBlockByNumber

按区块号返回区块信息。

参数

  • 区块号
  • 如果为 true,则返回完整的交易对象;如果为 false,则只返回交易哈希。
// 请求
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1", false],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// 结果
{"jsonrpc":"2.0","id":1,"result":{"difficulty":null,"extraData":"0x0","gasLimit":"0xffffffff","gasUsed":null,"hash":"0xabac6416f737a0eb54f47495b60246d405d138a6a64946458cf6cbeae0d48465","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","nonce":null,"number":"0x1","parentHash":"0x","sha3Uncles":null,"size":"0x9b","stateRoot":"0x","timestamp":"0x5f5bd3e5","totalDifficulty":null,"transactions":[],"transactionsRoot":"0x","uncles":[]}}

eth_getBlockByHash

根据上一个命令中找到的哈希值和一个布尔值返回区块信息。

参数

  • 区块的哈希。
  • 如果为 true,则返回完整的交易对象;如果为 false,则只返回交易哈希。
// 请求
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByHash","params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4", false],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// 结果
{"jsonrpc":"2.0","id":1,"result":{"difficulty":null,"extraData":"0x0","gasLimit":"0xffffffff","gasUsed":null,"hash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4","logsBloom":"0x00000000100000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000002000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","nonce":null,"number":"0xc","parentHash":"0x404e58f31a9ede1b614b98701d6b0fbf1450f186842dbcf6426dd16811a5ca0d","sha3Uncles":null,"size":"0x307","stateRoot":"0x599ccdb111fc62c6398dc39be957df8e97bf8ab72ce6c06ff10641a92b754627","timestamp":"0x5f5fdbbd","totalDifficulty":null,"transactions":["0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615"],"transactionsRoot":"0x4764dba431128836fa919b83d314ba9cc000e75f38e1c31a60484409acea777b","uncles":[]}}

eth_getHeaderByHash

根据区块哈希返回区块头信息。区块头包含区块的元数据,但不包含完整的交易列表。 实现: rpc/backend/headers.go:21

参数

  • DATA,32 字节 - 区块的哈希

返回

  • 对象 - 区块头对象,包含:
    • parentHash: DATA,32 字节 - 父区块的哈希
    • sha3Uncles: DATA,32 字节 - 区块中叔块数据的 SHA3
    • miner: DATA,20 字节 - 区块矿工地址
    • stateRoot: DATA,32 字节 - 状态 trie 的根
    • transactionsRoot: DATA,32 字节 - 交易 trie 的根
    • receiptsRoot: DATA,32 字节 - 收据 trie 的根
    • logsBloom: DATA,256 字节 - 区块日志的布隆过滤器
    • difficulty: QUANTITY - 该区块的难度
    • number: QUANTITY - 区块号
    • gasLimit: QUANTITY - 该区块允许的最大 gas
    • gasUsed: QUANTITY - 所有交易消耗的 gas 总量
    • timestamp: QUANTITY - 区块创建时的 Unix 时间戳
    • extraData: DATA - 该区块的额外数据字段
    • mixHash: DATA,32 字节 - Mix 哈希
    • nonce: DATA,8 字节 - 工作量证明哈希
    • baseFeePerGas: QUANTITY - 每单位 gas 的基础费用(EIP-1559)
    • hash: DATA,32 字节 - 区块哈希

客户端示例

Shell HTTP
curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"eth_getHeaderByHash",
  "params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"],
  "id":1
}' -H "Content-Type: application/json" http://localhost:8545
WebSocket
wscat -c ws://localhost:8546 -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getHeaderByHash",
  "params": ["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"]
}'
JavaScript 控制台
await provider.send("eth_getHeaderByHash", ["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"]);

结果

{
  "jsonrpc":"2.0",
  "id":1,
  "result":{
    "parentHash":"0x404e58f31a9ede1b614b98701d6b0fbf1450f186842dbcf6426dd16811a5ca0d",
    "sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "miner":"0x0000000000000000000000000000000000000000",
    "stateRoot":"0x599ccdb111fc62c6398dc39be957df8e97bf8ab72ce6c06ff10641a92b754627",
    "transactionsRoot":"0x4764dba431128836fa919b83d314ba9cc000e75f38e1c31a60484409acea777b",
    "receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
    "logsBloom":"0x00000000100000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000002000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000",
    "difficulty":"0x0",
    "number":"0xc",
    "gasLimit":"0xffffffff",
    "gasUsed":"0x5289",
    "timestamp":"0x5f5fdbbd",
    "extraData":"0x0",
    "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
    "nonce":"0x0000000000000000",
    "baseFeePerGas":"0x7",
    "hash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"
  }
}

eth_getHeaderByNumber

根据区块号返回区块头信息。与 eth_getHeaderByHash 类似,但接收的是区块号而不是哈希。 实现: rpc/backend/headers.go:13

参数

  • 作为 QUANTITY(十六进制字符串)的区块号,或区块标签:
    • "latest" - 最新已挖出的区块
    • "earliest" - 创世区块
    • "pending" - 待处理状态/交易

返回

  • 对象 - 区块头对象(与 eth_getHeaderByHash 结构相同)

客户端示例

Shell HTTP
curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"eth_getHeaderByNumber",
  "params":["latest"],
  "id":1
}' -H "Content-Type: application/json" http://localhost:8545
WebSocket
wscat -c ws://localhost:8546 -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getHeaderByNumber",
  "params": ["0x1b4"]
}'
JavaScript 控制台
// 获取最新区块头
await provider.send("eth_getHeaderByNumber", ["latest"]);

// 获取指定区块头
await provider.send("eth_getHeaderByNumber", ["0xc"]);

结果

{
  "jsonrpc":"2.0",
  "id":1,
  "result":{
    "parentHash":"0x404e58f31a9ede1b614b98701d6b0fbf1450f186842dbcf6426dd16811a5ca0d",
    "sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "miner":"0x0000000000000000000000000000000000000000",
    "stateRoot":"0x599ccdb111fc62c6398dc39be957df8e97bf8ab72ce6c06ff10641a92b754627",
    "transactionsRoot":"0x4764dba431128836fa919b83d314ba9cc000e75f38e1c31a60484409acea777b",
    "receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
    "logsBloom":"0x00000000100000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000002000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000",
    "difficulty":"0x0",
    "number":"0xc",
    "gasLimit":"0xffffffff",
    "gasUsed":"0x5289",
    "timestamp":"0x5f5fdbbd",
    "extraData":"0x0",
    "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
    "nonce":"0x0000000000000000",
    "baseFeePerGas":"0x7",
    "hash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"
  }
}

eth_getTransactionByHash

给定以太坊交易哈希,返回交易详情。

参数

  • 交易的哈希值
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xec5fa15e1368d6ac314f9f64118c5794f076f63c02e66f97ea5fe1de761a8973"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x7a7398cc11d9c4c8e6f53e0c73824297aceafdab62db9e4b867a0da694384864","blockNumber":"0x188","from":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70","gas":"0x147ee","gasPrice":"0x3b9aca00","hash":"0xec5fa15e1368d6ac314f9f64118c5794f076f63c02e66f97ea5fe1de761a8973","input":"0x6dba746c","nonce":"0x18","to":"0xa655256f589060437e5ffe2246dec385d040f148","transactionIndex":"0x0","value":"0x0","v":"0xa96","r":"0x6db399d694a452fb4106419140a6e5dbbe6817743a0f6f695a651e6576e59a5e","s":"0x25dd6ab1f936d0280d2fed0caeb0ebe5b9a46de6d8cb08ad8fd2c88deb55fc31"}}

eth_getTransactionByBlockHashAndIndex

给定区块哈希和交易索引,返回交易详情。

参数

  • 区块的哈希值。
  • 交易索引位置。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockHashAndIndex","params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4","blockNumber":"0xc","from":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d","gas":"0x4c4b40","gasPrice":"0x3b9aca00","hash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","input":"0x4f2be91f","nonce":"0x0","to":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","transactionIndex":"0x0","value":"0x0","v":"0xa96","r":"0xced57d973e58b0f634f776d57daf41d3d3387ceb347a3a72ca0746e5ec2b709e","s":"0x384e89e209a5eb147a2bac3a4e399507400ac7b29cd155531f9d6203a89db3f2"}}

eth_getTransactionReceipt

根据交易哈希返回交易回执。 注意:CometBFT 的 Tx Code 与 Ethereum 的回执状态是相反的:
CometBFTEthereum
成功01
失败10

参数

  • 交易的哈希值
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea614"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4","blockNumber":"0xc","contractAddress":"0x0000000000000000000000000000000000000000","cumulativeGasUsed":null,"from":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d","gasUsed":"0x5289","logs":[{"address":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","topics":["0x64a55044d1f2eddebe1b90e8e2853e8e96931cefadbfa0b2ceb34bee36061941"],"data":"0x0000000000000000000000000000000000000000000000000000000000000002","blockNumber":"0xc","transactionHash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","transactionIndex":"0x0","blockHash":"0x0000000000000000000000000000000000000000000000000000000000000000","logIndex":"0x0","removed":false},{"address":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","topics":["0x938d2ee5be9cfb0f7270ee2eff90507e94b37625d9d2b3a61c97d30a4560b829"],"data":"0x0000000000000000000000000000000000000000000000000000000000000002","blockNumber":"0xc","transactionHash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","transactionIndex":"0x0","blockHash":"0x0000000000000000000000000000000000000000000000000000000000000000","logIndex":"0x1","removed":false}],"logsBloom":"0x00000000100000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000002000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000","status":"0x1","to":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","transactionHash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","transactionIndex":"0x0"}}

eth_newFilter

使用某种 topics 创建新的过滤器。

参数

  • 交易的哈希值
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"topics":["0x0000000000000000000000000000000000000000000000000000000012341234"]}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xdc714a4a2e3c39dc0b0b84d66a3ccb00"}

eth_newBlockFilter

在节点中创建一个过滤器,以便在新区块到达时接收通知。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x3503de5f0c766c68f78a03a3b05036a5"}

eth_newPendingTransactionFilter

在节点中创建一个过滤器,以便在新的待处理交易到达时接收通知。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newPendingTransactionFilter","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x9daacfb5893d946997d3801ea18e9902"}

eth_uninstallFilter

移除给定过滤器 ID 对应的过滤器。如果成功卸载过滤器则返回 true,否则返回 false。

参数

  • 过滤器 ID
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_uninstallFilter","params":["0xb91b6608b61bf56288a661a1bd5eb34a"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":true}

eth_getFilterChanges

用于过滤器的轮询方法,返回自上次轮询以来产生的日志数组。

参数

  • 过滤器 id
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x127e9eca4f7751fb4e5cb5291ad8b455"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":["0xc6f08d183a81e149896fc5317c872f9092068e88e956ca1864e9bd4c81c09b44","0x3ca6dfb5be15549d721d1b3d10c1bec50ed6217c9ac7b61df361fac9692a27e5","0x776fffac134171acb1ebf2e59856625501ad5ccc5c4c8fe0359e0d4dff8919f2","0x84123103704dbd738c089276ab2b04b5936330b24f6e78453c4ba8bf4848aaf9","0xffddbe5bd8e8aa41e44002daa9ea89ade9e6980a0d83f51d104cf16498827eca","0x53430e49963e8ae32605d8f22dec2e757a691e6436d593854ca4d9383eeab86a","0x975948058c9351a91fbec332ca00dda39d1a919f5f16b996a4c7e30c38ba423b","0x619e37e32024c8efef7f7220e6caff4ee1d682ea78b2ac91e0a6b30850dc0677","0x31a5d985a40d08303ac68000ce008df512bcd1a911c497415c97f0624b4a271a","0x91dcf1fce4503a8dbb3e6fb61073f25cd31d69c766ecba639fefde4436e59d07","0x606d9e0143cfdb410a6812c590a8135b5c6b5c59eec26d760d5cd930aa47257d","0xd3c00b859b29b20ba654415eef648ef58251389c73a138580db87675b0d5465f","0x954391f0eb50888be90489898016ebb54f750f612f3adec2a00854955d5e52d8","0x698905f06aff921a9e9fcef39b8b0d107747c3e6204d2ea79cf4c12debf8d253","0x9fcafec5721938a06eb8e2951ede4b6ef8fae54a8c8f85f3166ec9782a0032b5","0xaec6d3364e47a5716ba69e4705f3c705d017f81298859589591183bfea87be7a","0x91bf2ee13319b6eaca96ed89c126437b66c4df1b13560c6a9bb18556ee3b7e1f","0x4f426dc1fc0ea8149052033065b237892d2d34927b2d558ab50c5a7fb98d6e79","0xdd809fb07e5aab638fef5311371b4e2b27c9c9a6183fde0cdd2b7724f6d2a89b","0x7e12fc92ab953e233a304959a2a8474d96195e71efd9388fdceb1326a577811a","0x30618ef6b490c3cc9979c47163459db37c1a1e0aa5793c56accd417f9d89973b","0x614609f06ee24bae7408e45895b1a25e6b19a8159aeea7a95c9d1339d9ba286f","0x115ddc6d533620040791d241f01f1c5ae3d9d1a8f64b15af5e9793e4d9096e22","0xb7458c9323beeca2cd54f32a6af5671f3cd5a7a251aed9d82bdd6ebe5f56305b","0x573dd48a5ba7bf4cc3d49597cd7419f75ecc9897258f1ebadebd670446d0d358","0xcb6670918439f9698413b53f3b5336d82ca4be152fdefaacf45e052fff6262fc","0xf3fe2a8945abafd269ab97bfdc80b3dbff2202ffdce59a227f952874b966b230","0x989980707007533cc0840a079f77f261a2e818abae1a1ffd3af02f3fff1d35fd","0x886b6ae365fec996be8a9a2c31cf4cda97ff8352908be2c83f17abd66ef1591e","0xfd90df68706ef95a62b317de93d6899a9bd6c80416e42d007f5c30fcdedfce24","0x7af8491fbb0373886d9032bb74e0ef52ed9e100f260b79bd15f46126b38cbede","0x91d1e2cd55533cf7dd5de86c9aa73295e811b1279be193d429bbd6ba83810e16","0x6b65b3128c2104005a04923288fe2aa33a2477a4962bef70532f94cab582f2a7"]}

eth_getFilterLogs

返回与给定 id 的过滤器匹配的所有日志组成的数组。

参数

  • QUANTITY - 过滤器 id
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["0x127e9eca4f7751fb4e5cb5291ad8b455"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"filter 0x35b64c227ce30e84fc5c7bd347be380e doesn't have a LogsSubscription type: got 5"}}

eth_getLogs

返回与给定过滤器对象匹配的所有日志组成的数组。

参数

  • 包含以下内容的对象: fromBlock: QUANTITY|TAG - (可选,默认:"latest")整数区块号,或 "latest" 表示最后一个已挖出的区块,或 "pending"、"earliest" 表示尚未挖出的交易。 toBlock: QUANTITY|TAG - (可选,默认:"latest")整数区块号,或 "latest" 表示最后一个已挖出的区块,或 "pending"、"earliest" 表示尚未挖出的交易。 address: DATA|Array,20 字节 - (可选)合约地址,或日志应来源的一组地址。 topics: DATA 数组 - (可选)由 32 字节 DATA 主题组成的数组。主题顺序相关。每个主题也可以是带有“or”选项的 DATA 数组。 blockhash: (可选,未来)随着 EIP-234 的加入,blockHash 将成为一个新的过滤器选项,用于将返回的日志限制为哈希为 blockHash 的单个区块。使用 blockHash 等同于 fromBlock = toBlock = 哈希为 blockHash 的区块号。如果过滤条件中存在 blockHash,则不允许再使用 fromBlock 或 toBlock。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"topics":["0x775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd738898","0x0000000000000000000000000000000000000000000000000000000000000011"], "fromBlock":"latest"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":[]}

eth_coinbase

返回将接收挖矿奖励的账户。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_coinbase","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E"}

eth_mining

返回客户端是否正在积极挖掘新区块。
由于 Cosmos EVM 使用的是 ‘CometBFT’ 共识而不是挖矿,因此始终返回 false。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_mining","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":false}

eth_hashrate

返回节点挖矿时每秒执行的哈希数量。
由于 Cosmos EVM 使用的是 ‘CometBFT’ 共识而不是挖矿,因此始终返回 0x0。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_hashrate","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0"}

eth_chainId

返回用于签名重放保护交易的链 ID。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x40000"}

eth_getUncleCountByBlockHash

返回与给定区块哈希匹配的区块中 uncle 的数量。
由于 Cosmos EVM 使用的是 ‘CometBFT’ 共识且不存在 uncle,因此始终返回 0x0。

参数

  • 区块哈希
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleCountByBlockHash","params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0"}

eth_getUncleCountByBlockNumber

返回与给定区块号匹配的区块中 uncle 的数量。
由于 Cosmos EVM 使用的是 ‘CometBFT’ 共识且不存在 uncle,因此始终返回 0x0。

参数

  • 区块号
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleCountByBlockNumber","params":["latest"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0"}

eth_getUncleByBlockHashAndIndex

返回按区块哈希和 uncle 索引位置查询到的 uncle 信息。
由于 Cosmos EVM 使用的是 ‘CometBFT’ 共识且不存在 uncle,因此始终返回 null。

参数

  • 区块哈希
  • Uncle 索引位置
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleByBlockHashAndIndex","params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

eth_getUncleByBlockNumberAndIndex

返回按区块号和 uncle 索引位置查询到的 uncle 信息。
由于 Cosmos EVM 使用的是 ‘CometBFT’ 共识且不存在 uncle,因此始终返回 null。

参数

  • 区块号
  • Uncle 索引位置
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleByBlockNumberAndIndex","params":["0x1", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

eth_getTransactionByBlockNumberAndIndex

返回按区块号和交易索引位置查询到的交易信息。

参数

  • 区块号
  • 交易索引位置
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x1", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4","blockNumber":"0x1","from":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d","gas":"0x4c4b40","gasPrice":"0x3b9aca00","hash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","input":"0x4f2be91f","nonce":"0x0","to":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","transactionIndex":"0x0","value":"0x0","v":"0xa96","r":"0xced57d973e58b0f634f776d57daf41d3d3387ceb347a3a72ca0746e5ec2b709e","s":"0x384e89e209a5eb147a2bac3a4e399507400ac7b29cd155531f9d6203a89db3f2"}}

eth_maxPriorityFeePerGas

返回当前每单位 gas 的 maxPriorityFeePerGas,单位为 wei。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_maxPriorityFeePerGas","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0"}

eth_getBlockReceipts

返回给定区块中所有交易的收据。

参数

  • 区块号或区块哈希
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockReceipts","params":["latest"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":[{"blockHash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4","blockNumber":"0xc","contractAddress":"0x0000000000000000000000000000000000000000","cumulativeGasUsed":null,"from":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d","gasUsed":"0x5289","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","status":"0x1","to":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","transactionHash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","transactionIndex":"0x0"}]}

eth_getTransactionLogs

返回特定交易的日志。

参数

  • 交易哈希
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionLogs","params":["0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":[{"address":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","topics":["0x64a55044d1f2eddebe1b90e8e2853e8e96931cefadbfa0b2ceb34bee36061941"],"data":"0x0000000000000000000000000000000000000000000000000000000000000002","blockNumber":"0xc","transactionHash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","transactionIndex":"0x0","blockHash":"0x0000000000000000000000000000000000000000000000000000000000000000","logIndex":"0x0","removed":false}]}

eth_fillTransaction

为给定的未签名交易填充默认值(nonce、gas、gasPrice 或 1559 字段),并将其返回给调用方以便进一步处理(签名 + 广播)。

参数

  • 带有可选字段的交易对象
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_fillTransaction","params":[{"from":"0x0123456789012345678901234567890123456789","to":"0x0123456789012345678901234567890123456789","value":"0x1"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"raw":"0x...","tx":{"nonce":"0x0","gasPrice":"0x3b9aca00","gas":"0x5208","to":"0x0123456789012345678901234567890123456789","value":"0x1","input":"0x","v":"0x0","r":"0x0","s":"0x0","hash":"0x..."}}}

eth_resend

使用更新后的 gas 参数重新发送交易。将给定交易从池中移除,并使用新的 gas price 和 gas limit 重新插入。
实现说明:此方法要求在交易对象中提供交易 nonce 参数。如果没有 nonce,将返回错误:“missing transaction nonce in transaction spec”。

参数

  • 原始交易对象(必须包含 nonce)
  • 新的 gas price(十六进制)
  • 新的 gas limit(十六进制)
// Request - Note the required 'nonce' field in the transaction object
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_resend","params":[{"from":"0x0123456789012345678901234567890123456789","to":"0x0123456789012345678901234567890123456789","value":"0x1","gas":"0x5208","gasPrice":"0x3b9aca00","nonce":"0x0"},"0x3b9aca01","0x5209"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x..."}  // Returns transaction hash

eth_getProof

返回指定账户的账户值和存储值,包括其 Merkle 证明。
实现说明:此方法要求提供有效的区块高度。使用 “latest” 或小于 1 的区块高度将返回错误:“cannot query with height < 0; please provide a valid height”。你必须指定实际的区块号。

参数

  • 账户或合约地址
  • 存储位置数组(32 字节存储槽)
  • 区块号(必须是具体数字,不能是 "latest")
// Request - Note: using a specific block number instead of "latest"
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getProof","params":["0x1234567890123456789012345678901234567890",["0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000001"],"0x1"],"id":1}' -H "Content-type:application/json" http://localhost:8545
// Result
{"jsonrpc": "2.0", "id": 1, "result": {"address": "0x1234567890123456789012345678901234567890", "accountProof": ["0xf90211a090dcaf88c40c7bbc95a912cbdde67c175767b31173df9ee4b0d733bfdd511c43a0babe369f6b12092f49181ae04ca173fb68d1a5456f18d20fa32cba73954052bda0473ecf8a7e36a829e75039a3b055e51b8332cbf03324ab4af2066bbd6fbf0021a0bbda34753d7aa6c38e603f360244e8f59611921d9e1f128372fec0d586d4f9e0a04e44caecff45c9891f74f6a2156735886eedf6f1a733628ebc802ec79d844648a0a5f3f2f7542148c973977c8a1e154c4300fec92f755f7846f1b734d3ab1d90e7a0e823850f50bf72baae9d1733a36a444ab65d0a6faaba404f0583ce0ca4dad92da0f7a00cbe7d4b30b11faea3ae61b7f1f2b315b61d9f6bd68bfe587ad0eeceb721a07117ef9fc932f1a88e908eaead8565c19b5645dc9e5b1b6e841c5edbdfd71681a069eb2de283f32c11f859d7bcf93da23990d3e662935ed4d6b39ce3673ec84472a0203d26456312bbc4da5cd293b75b840fc5045e493d6f904d180823ec22bfed8ea09287b5c21f2254af4e64fca76acc5cd87399c7f1ede818db4326c98ce2dc2208a06fc2d754e304c48ce6a517753c62b1a9c1d5925b89707486d7fc08919e0a94eca07b1c54f15e299bd58bdfef9741538c7828b5d7d11a489f9c20d052b3471df475a051f9dd3739a927c89e357580a4c97b40234aa01ed3d5e0390dc982a7975880a0a089d613f26159af43616fd9455bb461f4869bfede26f2130835ed067a8b967bfb80", "0xf90211a0395d87a95873cd98c21cf1df9421af03f7247880a2554e20738eec2c7507a494a0bcf6546339a1e7e14eb8fb572a968d217d2a0d1f3bc4257b22ef5333e9e4433ca012ae12498af8b2752c99efce07f3feef8ec910493be749acd63822c3558e6671a0dbf51303afdc36fc0c2d68a9bb05dab4f4917e7531e4a37ab0a153472d1b86e2a0ae90b50f067d9a2244e3d975233c0a0558c39ee152969f6678790abf773a9621a01d65cd682cc1be7c5e38d8da5c942e0a73eeaef10f387340a40a106699d494c3a06163b53d956c55544390c13634ea9aa75309f4fd866f312586942daf0f60fb37a058a52c1e858b1382a8893eb9c1f111f266eb9e21e6137aff0dddea243a567000a037b4b100761e02de63ea5f1fcfcf43e81a372dafb4419d126342136d329b7a7ba032472415864b08f808ba4374092003c8d7c40a9f7f9fe9cc8291f62538e1cc14a074e238ff5ec96b810364515551344100138916594d6af966170ff326a092fab0a0d31ac4eef14a79845200a496662e92186ca8b55e29ed0f9f59dbc6b521b116fea090607784fe738458b63c1942bba7c0321ae77e18df4961b2bc66727ea996464ea078f757653c1b63f72aff3dcc3f2a2e4c8cb4a9d36d1117c742833c84e20de994a0f78407de07f4b4cb4f899dfb95eedeb4049aeb5fc1635d65cf2f2f4dfd25d1d7a0862037513ba9d45354dd3e36264aceb2b862ac79d2050f14c95657e43a51b85c80", "0xf90171a04ad705ea7bf04339fa36b124fa221379bd5a38ffe9a6112cb2d94be3a437b879a08e45b5f72e8149c01efcb71429841d6a8879d4bbe27335604a5bff8dfdf85dcea00313d9b2f7c03733d6549ea3b810e5262ed844ea12f70993d87d3e0f04e3979ea0b59e3cdd6750fa8b15164612a5cb6567cdfb386d4e0137fccee5f35ab55d0efda0fe6db56e42f2057a071c980a778d9a0b61038f269dd74a0e90155b3f40f14364a08538587f2378a0849f9608942cf481da4120c360f8391bbcc225d811823c6432a026eac94e755534e16f9552e73025d6d9c30d1d7682a4cb5bd7741ddabfd48c50a041557da9a74ca68da793e743e81e2029b2835e1cc16e9e25bd0c1e89d4ccad6980a041dda0a40a21ade3a20fcd1a4abb2a42b74e9a32b02424ff8db4ea708a5e0fb9a09aaf8326a51f613607a8685f57458329b41e938bb761131a5747e066b81a0a16808080a022e6cef138e16d2272ef58434ddf49260dc1de1f8ad6dfca3da5d2a92aaaadc58080", "0xf851808080a009833150c367df138f1538689984b8a84fc55692d3d41fe4d1e5720ff5483a6980808080808080808080a0a319c1c415b271afc0adcb664e67738d103ac168e0bc0b7bd2da7966165cb9518080"], "balance": "0x0", "codeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", "nonce": "0x0", "storageHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "storageProof": [{"key": "0x0000000000000000000000000000000000000000000000000000000000000000", "value": "0x0", "proof": []}, {"key": "0x0000000000000000000000000000000000000000000000000000000000000001", "value": "0x0", "proof": []}]}}

WebSocket 方法

阅读更多关于如何使用 websockets 的内容。

eth_subscribe

使用 JSON-RPC 通知进行订阅。这使客户端可以等待事件,而不是轮询事件。其工作方式是订阅特定事件。节点将返回一个订阅 id。对于每个匹配该订阅的事件,都会连同订阅 id 一起发送包含相关数据的通知。

参数

  • 订阅名称
  • 可选参数
// Request
{"id": 1, "method": "eth_subscribe", "params": ["newHeads", {"includeTransactions": true}]}
// Result
< {"jsonrpc":"2.0","result":"0x34da6f29e3e953af4d0c7c58658fd525","id":1}

eth_unsubscribe

使用订阅 id 取消事件订阅。

参数

  • 订阅 ID
// Request
{"id": 1, "method": "eth_unsubscribe", "params": ["0x34da6f29e3e953af4d0c7c58658fd525"]}
// Result
{"jsonrpc":"2.0","result":true,"id":1}

Personal 方法

personal_importRawKey

私有:需要身份验证。
将给定的未加密私钥(十六进制编码字符串)导入密钥库,并使用口令进行加密。返回新账户的地址。
实现说明:私钥必须是有效的 64 个字符十六进制字符串(32 字节),且不包含 "0x" 前缀。无效的十六进制字符会返回错误:"invalid hex character 'x' in private key"。

参数 (2)

1: privkey string
  • 必填:[Y] 是
  • 格式:64 个十六进制字符(32 字节),不带 "0x" 前缀
2: password string
  • 必填:[Y] 是
// Request - Note: private key without "0x" prefix
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_importRawKey","params":["c5bd76cd0cd948de17a31261567d219576e992d9066fe1a6bca97496dec634e2", "the key is this"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x..."} // Returns the address

personal_listAccounts

私有:需要身份验证。
返回该节点管理的账户地址列表。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_listAccounts","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":["0x3b7252d007059ffc82d16d022da3cbf9992d2f70","0xddd64b4712f7c8f1ace3c145c950339eddaf221d","0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0"]}

personal_lockAccount

私有:需要身份验证。
从内存中移除给定地址对应的私钥。该账户将无法再用于发送交易。

参数

  • 账户地址
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_lockAccount","params":["0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":true}

personal_newAccount

私有:需要身份验证。
生成一个新的私钥并将其存储在密钥库目录中。密钥文件会使用给定口令加密。它会返回新账户的地址。

参数

  • 口令
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_newAccount","params":["This is the passphrase"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xf0e4086ad1c6aab5d42161d5baaae2f9ad0571c0"}

personal_unlockAccount

私有:需要身份验证。
从密钥库中解密给定地址对应的密钥。 在使用 JavaScript 控制台时,口令和解锁时长都是可选的。未加密的密钥会保留在内存中,直到解锁时长到期。如果未指定,解锁时长默认为 300 秒。显式将时长设为 0 秒会使密钥保持解锁状态,直到 geth 退出。 账户在解锁期间可与 eth_sign 和 eth_sendTransaction 一起使用。

参数

  • 账户地址
  • 口令
  • 时长
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0", "secret passphrase", 30],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":true}

personal_sendTransaction

私有:需要身份验证。
验证给定的密码短语并提交交易。 该交易参数与 eth_sendTransaction 相同,并包含 from 地址。如果该密码短语可用于解密属于 tx.from 的私钥,则会对交易进行校验、签名并发送到网络。
该账户不会在节点中被全局解锁,也不能用于其他 RPC 调用。

参数

  • 对象,包含: from:DATA,20 字节 - 发送该交易的地址。 to:DATA,20 字节 - (创建新合约时可选)交易发送到的目标地址。 value:QUANTITY - 随该交易发送的数值
  • 密码短语
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_sendTransaction","params":[{"from":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70","to":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d", "value":"0x16345785d8a0000"}, "passphrase"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xd2a31ec1b89615c8d1f4d08fe4e4182efa4a9c0d5758ace6676f485ea60e154c"}

personal_sign

私有:需要身份验证。
签名方法使用以下方式计算以太坊特定签名:sign(keccack256("\x19Ethereum Signed Message:\n" + len(message) + message))),

参数

  • 消息
  • 账户地址
  • 密码
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_sign","params":["0xdeadbeaf", "0x3b7252d007059ffc82d16d022da3cbf9992d2f70", "password"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xf9ff74c86aefeb5f6019d77280bbb44fb695b4d45cfe97e6eed7acd62905f4a85034d5c68ed25a2e7a8eeb9baf1b8401e4f865d92ec48c1763bf649e354d900b1c"}

personal_ecRecover

私有:需要身份验证。
ecRecover 返回用于在 personal_sign 中计算签名的私钥所对应的地址。
实现说明:签名必须严格为 65 字节(130 个十六进制字符)。其他长度的签名将返回错误:“signature must be 65 bytes long”。

参数

  • 消息(十六进制编码)
  • 从 personal_sign 返回的签名(65 字节)
// Request - Note: signature must be exactly 130 hex characters (65 bytes)
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_ecRecover","params":["0xdeadbeaf", "0xf9ff74c86aefeb5f6019d77280bbb44fb695b4d45cfe97e6eed7acd62905f4a85034d5c68ed25a2e7a8eeb9baf1b8401e4f865d92ec48c1763bf649e354d900b1c"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70"}

personal_initializeWallet

私有:需要身份验证。
在提供的 URL 处初始化一个新钱包,方法是生成并返回一个新的私钥。

参数(1)

参数必须按位置提供。 1:url string
  • 必填:[Y] 是

客户端示例

Shell HTTP
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "personal_initializeWallet", "params": [<url>]}'
WebSocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "personal_initializeWallet", "params": [<url>]}'
Javascript 控制台
personal.initializeWallet(url);

personal_unpair

私有:需要身份验证。
Unpair 会删除钱包与节点之间的配对关系。

参数(2)

  • URL
  • 配对密码

客户端示例

Shell HTTP
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "personal_unpair", "params": [<url>, <pin>]}'
WebSocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "personal_unpair", "params": [<url>, <pin>]}'
Javascript 控制台
personal.unpair(url,pin);

personal_listWallets

私有:需要身份验证。
返回该节点管理的钱包列表。
当前返回 null,因为尚不支持钱包级管理。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_listWallets","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

调试方法

debug_traceTransaction

traceTransaction 调试方法会尝试以该交易在网络上执行时完全相同的方式运行该交易。它会先重放在此交易之前可能已执行的所有交易,然后再尝试执行与给定哈希对应的交易。

参数

  • Trace Config
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["0xddecdb13226339681372b44e01df0fbc0f446fca6f834b2de5ecb1e569022ec8", {"tracer": "{data: [], fault: function(log) {}, step: function(log) { if(log.op.toString() == \"CALL\") this.data.push(log.stack.peek(0)); }, result: function() { return this.data; }}"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
//Result
["68410", "51470"]

debug_traceBlockByNumber

traceBlockByNumber 端点接收一个区块号,并重放数据库中已存在的该区块。
存根实现:该方法已实现,但当前对所有请求都返回空数组。在 Cosmos EVM 中,追踪功能尚未完全可用。

参数

  • 区块号(十六进制字符串)
  • Trace Config(可选)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_traceBlockByNumber","params":["0xe", {"tracer": "{data: [], fault: function(log) {}, step: function(log) { if(log.op.toString() == \"CALL\") this.data.push(log.stack.peek(0)); }, result: function() { return this.data; }}"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result - Currently returns empty array
{"jsonrpc":"2.0","id":1,"result":[]}

debug_traceBlockByHash

与 debug_traceBlockByNumber 类似,该方法接收一个区块哈希,并重放数据库中已存在的该区块。
存根实现:该方法已实现,但当前对所有请求都返回空数组。在 Cosmos EVM 中,追踪功能尚未完全可用。

参数

  • 区块哈希(32 字节哈希)
  • Trace Config(可选)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_traceBlockByHash","params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4", {}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result - Currently returns empty array
{"jsonrpc":"2.0","id":1,"result":[]}

debug_traceCall

在给定区块的上下文中追踪一次 eth_call 的执行。这使你可以在不将交易广播到网络的情况下模拟交易并追踪其执行过程。 实现: rpc/namespaces/ethereum/debug/api.go:158

参数

  • 包含交易调用数据的对象:
    • from:DATA,20 字节 - (可选)发起该调用的地址
    • to:DATA,20 字节 - 该调用的目标地址
    • gas:QUANTITY - (可选)为调用执行提供的 Gas
    • gasPrice:QUANTITY - (可选)每单位 Gas 的 Gas 价格
    • value:QUANTITY - (可选)随调用发送的数值
    • data:DATA - (可选)调用数据负载
  • 区块号或区块哈希(EIP-1898)
  • Tracer 配置(可选)- 对象,包含:
    • tracer:string - Tracer 类型(“callTracer”、“prestateTracer”、“4byteTracer” 或自定义 JavaScript tracer)
    • timeout:string - 追踪执行的超时时间(例如 “5s”)
    • tracerConfig:对象 - Tracer 专用配置选项

返回值

  • 对象 - 追踪结果结构取决于所使用的 tracer:
    • callTracer:返回包含 Gas 使用情况和子调用的调用帧树
    • prestateTracer:返回前置状态(账户余额、nonce、代码、存储)
    • 4byteTracer:返回 4 字节函数选择器到调用次数的映射
    • opcodeTracer:返回已执行的操作码列表

客户端示例

Shell HTTP
curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"debug_traceCall",
  "params":[{
    "from":"0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
    "to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "data":"0x70a08231000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
  }, "latest", {"tracer": "callTracer"}],
  "id":1
}' -H "Content-Type: application/json" http://localhost:8545
WebSocket
wscat -c ws://localhost:8546 -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "debug_traceCall",
  "params": [{
    "from":"0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
    "to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "data":"0x70a08231000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
  }, "latest", {"tracer": "callTracer"}]
}'
JavaScript 控制台
await provider.send("debug_traceCall", [{
  from: "0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
  to: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
  data: "0x70a08231000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
}, "latest", {tracer: "callTracer"}]);

结果

用法示例

// Trace a contract call to debug execution
const trace = await provider.send("debug_traceCall", [
  {
    to: contractAddress,
    data: contract.interface.encodeFunctionData("transfer", [recipient, amount])
  },
  "latest",
  { tracer: "callTracer" }
]);

// Use prestate tracer to see initial state
const prestate = await provider.send("debug_traceCall", [
  {
    to: contractAddress,
    data: callData
  },
  "latest",
  { tracer: "prestateTracer" }
]);

// Trace with timeout
const trace = await provider.send("debug_traceCall", [
  {
    from: sender,
    to: contractAddress,
    data: complexCallData
  },
  "latest",
  {
    tracer: "callTracer",
    timeout: "10s"
  }
]);

debug_freeOSMemory

强制 Go 运行时执行一次垃圾回收,并将未使用的内存归还给操作系统。
私有:需要认证。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_freeOSMemory","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_setGCPercent

设置垃圾回收目标百分比。负值将禁用垃圾回收。
私有:需要认证。

参数

  • GC 百分比(整数)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_setGCPercent","params":[100],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":100}

debug_memStats

返回详细的运行时内存统计信息。
私有:需要认证。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_memStats","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"Alloc":83328680,"TotalAlloc":451796592,"Sys":166452520,"Lookups":0,"Mallocs":4071615,"Frees":3772501,"HeapAlloc":83328680,"HeapSys":153452544,"HeapIdle":51568640,"HeapInuse":101883904,"HeapReleased":44720128,"HeapObjects":299114,"StackInuse":1736704,"StackSys":1736704,"MSpanInuse":1119520,"MSpanSys":1958400,"MCacheInuse":16912,"MCacheSys":31408,"BuckHashSys":1583603,"GCSys":5251008,"OtherSys":2438853,"NextGC":142217095,"LastGC":1754180652189080000,"PauseTotalNs":1266251,"NumGC":18,"NumForcedGC":1,"GCCPUFraction":0.0002128524091018015,"EnableGC":true,"DebugGC":false}}

debug_setBlockProfileRate

设置 goroutine 阻塞分析数据的采集速率。非零值会启用阻塞分析。
私有:需要认证。

参数

  • 分析速率(整数)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_setBlockProfileRate","params":[1],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_writeBlockProfile

将 goroutine 阻塞分析写入指定文件。
私有:需要认证。

参数

  • 文件路径(字符串)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_writeBlockProfile","params":["block.prof"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_writeMemProfile

将分配分析写入指定文件。
私有:需要认证。

参数

  • 文件路径(字符串)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_writeMemProfile","params":["mem.prof"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_writeMutexProfile

将互斥锁竞争分析写入指定文件。
私有:需要认证。

参数

  • 文件路径(字符串)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_writeMutexProfile","params":["mutex.prof"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_blockProfile

为给定时长开启阻塞分析,并将分析数据写入磁盘。
私有:需要认证。

参数

  • 文件路径(字符串) - 分析结果的输出文件
  • 持续时间(秒,数字)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_blockProfile","params":["block.prof", 30],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_cpuProfile

为给定时长开启 CPU 分析,并将分析数据写入磁盘。
私有:需要认证。

参数

  • 文件路径(字符串) - 分析结果的输出文件
  • 持续时间(秒,数字)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_cpuProfile","params":["cpu.prof", 30],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_gcStats

返回垃圾回收统计信息。
私有:需要认证。 Cosmos 特有:此方法是 Cosmos EVM 独有的。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_gcStats","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"NumGC":10,"PauseTotal":1000000,"Pause":[100000,200000],"PauseEnd":[1234567890,1234567891],"...":"..."}}

debug_goTrace

为给定时长开启 Go 运行时跟踪,并将跟踪数据写入磁盘。
私有:需要认证。

参数

  • 文件路径(字符串) - 跟踪结果的输出文件
  • 持续时间(秒,数字)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_goTrace","params":["trace.out", 5],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_stacks

返回所有 goroutine 栈的打印表示。
私有:需要认证。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_stacks","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"goroutine 1 [running]:\n..."}

debug_startCPUProfile

开始无限期的 CPU 分析,并写入给定文件。
私有:需要认证。

参数

  • 文件路径(字符串) - 分析结果的输出文件
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_startCPUProfile","params":["cpu.prof"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_stopCPUProfile

停止正在进行的 CPU 性能分析。
私有:需要身份验证。
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_stopCPUProfile","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_mutexProfile

为给定时长开启互斥锁性能分析,并将分析数据写入磁盘。
私有:需要身份验证。

参数

  • 文件路径(string)- 分析结果的输出文件
  • 持续时间(秒,number)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_mutexProfile","params":["mutex.prof", 10],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_setMutexProfileFraction

设置互斥锁性能分析的采样率。
私有:需要身份验证。 Cosmos 特有:此方法是 Cosmos EVM 独有的。

参数

  • 采样率(number)- 0 表示禁用,1 表示完整分析
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_setMutexProfileFraction","params":[1],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":0}

debug_getHeaderRlp

返回区块头的 RLP 编码。
私有:需要身份验证。
参数类型:此方法要求区块号为 uint64(数字类型),而不是十六进制字符串。传入字符串会返回错误:“invalid argument 0: json: cannot unmarshal string into Go value of type uint64”。

参数

  • 区块号(uint64 数字,不是十六进制字符串)
// Request - Note: block number as integer, not hex string
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_getHeaderRlp","params":[100],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xf90..."}

debug_getBlockRlp

返回区块的 RLP 编码。
私有:需要身份验证。
参数类型:此方法要求区块号为 uint64(数字类型),而不是十六进制字符串。传入字符串会返回错误:“invalid argument 0: json: cannot unmarshal string into Go value of type uint64”。

参数

  • 区块号(uint64 数字,不是十六进制字符串)
// Request - Note: block number as integer, not hex string
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_getBlockRlp","params":[100],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xf90..."}

debug_printBlock

返回区块的格式化字符串。
私有:需要身份验证。
参数类型:此方法要求区块号为 uint64(数字类型),而不是十六进制字符串。传入字符串会返回错误:“invalid argument 0: json: cannot unmarshal string into Go value of type uint64”。

参数

  • 区块号(uint64 数字,不是十六进制字符串)
// Request - Note: block number as integer, not hex string
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_printBlock","params":[100],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"Block #100\nParent: 0x...\nStateRoot: 0x...\n..."}

debug_intermediateRoots

返回某笔交易的中间状态根。
私有:需要身份验证。

参数

  • 交易哈希(hash)
  • 跟踪配置(object,可选)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_intermediateRoots","params":["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b", {}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":["0x...","0x..."]}

TxPool 方法

txpool_content

返回当前所有待打包进后续区块的交易的精确详细信息列表,以及那些仅被安排在未来执行的交易。

参数(0)

客户端示例

Shell HTTP
curl -X POST --data '{"jsonrpc":"2.0","method":"txpool_content","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
WebSocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "txpool_content", "params": []}'
JavaScript 控制台
txpool.content();

结果

{"jsonrpc":"2.0","id":1,"result":{"pending":{},"queued":{}}}

txpool_contentFrom

返回来自指定地址、当前待打包进后续区块的交易,以及那些仅被安排在未来执行的交易。

参数(1)

  1. address - 用于筛选交易的地址(20 字节)

客户端示例

Shell HTTP
curl -X POST --data '{"jsonrpc":"2.0","method":"txpool_contentFrom","params":["0x1234567890abcdef1234567890abcdef12345678"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
WebSocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "txpool_contentFrom", "params": ["0x1234567890abcdef1234567890abcdef12345678"]}'
JavaScript 控制台
txpool.contentFrom("0x1234567890abcdef1234567890abcdef12345678");

结果

{"jsonrpc":"2.0","id":1,"result":{"pending":{},"queued":{}}}

txpool_inspect

以文本格式返回列表,汇总当前所有待打包进后续区块的交易,以及那些仅被安排在未来执行的交易。此方法专门为开发者设计,用于快速查看交易池中的交易并发现潜在问题。

参数(0)

客户端示例

Shell HTTP
curl -X POST --data '{"jsonrpc":"2.0","method":"txpool_inspect","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
WebSocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "txpool_inspect", "params": []}'
JavaScript 控制台
txpool.inspect();

结果

{"jsonrpc":"2.0","id":1,"result":{"pending":{},"queued":{}}}

txpool_status

返回当前待打包进后续区块的交易数量,以及那些仅被安排在未来执行的交易数量。

参数(0)

客户端示例

Shell HTTP
curl -X POST --data '{"jsonrpc":"2.0","method":"txpool_status","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
WebSocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "txpool_status", "params": []}'
JavaScript 控制台
txpool.status();

结果

{"jsonrpc":"2.0","id":1,"result":{"pending":"0x0","queued":"0x0"}}

eth_createAccessList

此方法已完整实现,并支持 EIP-2930 访问列表交易。
为给定交易创建访问列表。这对于优化调用合约时的 gas 成本很有帮助,因为它允许交易指定将要访问哪些存储槽,从而可能降低这些访问的 gas 成本。 访问列表包含交易计划访问的地址和存储键。当其包含在交易中时,这些预先声明的访问会消耗更少的 gas。

参数

  1. 交易对象 - 交易调用对象
    • from: DATA,20 字节 - (可选)发送该交易的地址
    • to: DATA,20 字节 - 交易发送到的目标地址
    • gas: QUANTITY - (可选)为交易执行提供的 gas 整数值
    • gasPrice: QUANTITY - (可选)每单位已支付 gas 使用的 gasPrice 整数值
    • maxFeePerGas: QUANTITY - (可选)发送方愿意支付的每单位 gas 的最高费用
    • maxPriorityFeePerGas: QUANTITY - (可选)发送方愿意支付的每单位 gas 的最高优先费
    • value: QUANTITY - (可选)随该交易发送的值的整数值
    • data: DATA - (可选)方法签名的哈希及编码后的参数
    • accessList: ARRAY - (可选)交易计划访问的地址和存储键列表
  2. 区块参数 - QUANTITY|TAG - 整数区块号,或字符串 "latest"、"earliest" 或 "pending"

客户端示例

Shell HTTP
curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"eth_createAccessList",
  "params":[{
    "from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",
    "to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",
    "data": "0x70a08231000000000000000000000000d3CdA913deB6f67967B99D67aCDFa1712C293601"
  }, "latest"],
  "id":1
}' -H "Content-Type: application/json" http://localhost:8545
WebSocket
wscat -c ws://localhost:8546 -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_createAccessList",
  "params": [{
    "from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",
    "to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",
    "data": "0x70a08231000000000000000000000000d3CdA913deB6f67967B99D67aCDFa1712C293601"
  }, "latest"]
}'
JavaScript(web3.js)
web3.eth.createAccessList({
  from: "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",
  to: "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",
  data: "0x70a08231000000000000000000000000d3CdA913deB6f67967B99D67aCDFa1712C293601"
}, "latest");

结果

返回值

  • accessList: ARRAY - 交易使用的地址和存储键列表
    • address: DATA,20 Bytes - 交易访问的地址
    • storageKeys: ARRAY - 在该地址访问的存储键数组
  • gasUsed: QUANTITY - 交易在使用访问列表时预计消耗的 gas

**Legend**:
- **Y** - Functional
- **Stub** - Returns success but with null/empty/zero values for compatibility
- **N** - Not Implemented - Returns error or not available
This documentation lists all Ethereum JSON-RPC methods and their implementation status in Cosmos EVM. For the official Ethereum JSON-RPC specification, see the Ethereum Execution APIs repository.
Namespace Configuration: By default, only the eth, net, and web3 namespaces are enabled. To enable additional namespaces like personal, txpool, debug, or miner, you must configure them in your node’s app.toml config.

Non-Implemented Namespaces

The following namespaces are not implemented in Cosmos EVM but may be present in the interactive explorer for testing against other networks:
The debug namespace provides debugging and tracing tools for development. Some tracing and profiling methods are implemented in Cosmos EVM. Many methods require the Profiling config to be enabled.
The admin namespace handles node administration and peer management. Cosmos nodes use different administration mechanisms through the Cosmos SDK CLI and configuration files.
The miner namespace controls Proof of Work mining operations. Cosmos EVM uses ‘CometBFT’ Byzantine Fault Tolerant consensus instead of mining.
The engine namespace implements Ethereum’s post-merge Engine API for communication with the consensus layer. Cosmos EVM uses ‘CometBFT’ consensus instead of the beacon chain.
The clique namespace implements Proof of Authority consensus for private networks. Cosmos EVM uses ‘CometBFT’ consensus.
The les namespace implements the Light Ethereum Subprotocol. Cosmos has a different light client architecture through IBC.

Endpoints

MethodNamespaceStatusPublicNotes
web3_clientVersionWeb3YY
web3_sha3Web3YY
net_versionNetYY
net_peerCountNetStubYReturns “0x0”
net_listeningNetStubYReturns true
eth_protocolVersionEthYY
eth_syncingEthStubYReturns false
eth_gasPriceEthStubYReturns “0x0”
eth_accountsEthYY
eth_blockNumberEthYY
eth_getBalanceEthYY
eth_getStorageAtEthYY
eth_getTransactionCountEthYY
eth_getBlockTransactionCountByNumberEthStubYReturns “0x0”
eth_getBlockTransactionCountByHashEthStubYReturns “0x0”
eth_getCodeEthStubYReturns “0x”
eth_signEthYN
eth_sendTransactionEthNNNot implemented
eth_sendRawTransactionEthYY
eth_callEthStubYReturns “0x”
eth_createAccessListEthYYEIP-2930
eth_estimateGasEthYYOptimized
eth_getBlockByNumberEthYY
eth_getBlockByHashEthYY
eth_getTransactionByHashEthStubYReturns null
eth_getTransactionByBlockHashAndIndexEthStubYReturns null
eth_getTransactionReceiptEthStubYReturns null
eth_newFilterEthYY
eth_newBlockFilterEthYY
eth_newPendingTransactionFilterEthYY
eth_uninstallFilterEthStubYReturns true
eth_getFilterChangesEthStubYReturns empty array
eth_getFilterLogsEthStubYReturns empty array
eth_getLogsEthStubYReturns []
eth_getTransactionByBlockNumberAndIndexEthStubYReturns null
eth_getWorkEthNYNot implemented
eth_submitWorkEthNYNot implemented
eth_submitHashrateEthNYNot implemented
eth_getCompilersEthNNNot implemented
eth_compileLLLEthNNNot implemented
eth_compileSolidityEthNNNot implemented
eth_compileSerpentEthNNNot implemented
eth_signTransactionEthNNNot implemented
eth_miningEthYYDeprecated - always false
eth_coinbaseEthYYDeprecated in geth
eth_hashrateEthYYDeprecated - always 0
eth_getUncleCountByBlockHashEthStubYAlways “0x0”
eth_getUncleCountByBlockNumberEthStubYAlways “0x0”
eth_getUncleByBlockHashAndIndexEthStubYAlways null
eth_getUncleByBlockNumberAndIndexEthStubYAlways null
eth_getProofEthYY
eth_feeHistoryEthYYEIP-1559
eth_maxPriorityFeePerGasEthStubYReturns “0x0”
eth_chainIdEthYY
eth_getBlockReceiptsEthStubYReturns empty array
eth_resendEthNYRequires nonce param
eth_createAccessListEthYYEIP-2930
eth_blobBaseFeeEthNYEIP-4844 not implemented
eth_fillTransactionEthNYNot implemented
eth_signTypedDataEthNNRequires domain param
eth_signTypedData_v3EthNNNot implemented
eth_signTypedData_v4EthNNNot implemented
eth_pendingTransactionsEthNYNot implemented
eth_getPendingTransactionsEthYYDeprecated in geth
eth_getHeaderByHashEthYY
eth_getHeaderByNumberEthYY
eth_simulateV1EthNYGeth-specific, not implemented
eth_getRawTransactionByHashEthNYNot implemented
eth_getRawTransactionByBlockNumberAndIndexEthNYNot implemented
eth_getRawTransactionByBlockHashAndIndexEthNYNot implemented
eth_subscribeWebsocketYYWebSocket only
eth_unsubscribeWebsocketYYWebSocket only
personal_importRawKeyPersonalNNRequires valid hex key
personal_listAccountsPersonalYNRequires v0.4.x mempool
personal_lockAccountPersonalStubNAlways false
personal_newAccountPersonalYNRequires v0.4.x mempool
personal_unlockAccountPersonalStubNAlways false
personal_sendTransactionPersonalNNNot implemented
personal_signPersonalYNRequires v0.4.x mempool
personal_ecRecoverPersonalNNRequires 65-byte sig
personal_initializeWalletPersonalNNNot implemented
personal_unpairPersonalNNNot implemented
personal_listWalletsPersonalStubNReturns null
personal_signTransactionPersonalNNNot implemented
personal_signAndSendTransactionPersonalNNNot implemented
personal_openWalletPersonalNNNot implemented
personal_deriveAccountPersonalNNNot implemented
db_putStringDBNNDeprecated
db_getStringDBNNDeprecated
db_putHexDBNNDeprecated
db_getHexDBNNDeprecated
shh_postSSHNNDeprecated
shh_versionSSHNNDeprecated
shh_newIdentitySSHNNDeprecated
shh_hasIdentitySSHNNDeprecated
shh_newGroupSSHNNDeprecated
shh_addToGroupSSHNNDeprecated
shh_newFilterSSHNNDeprecated
shh_uninstallFilterSSHNNDeprecated
shh_getFilterChangesSSHNNDeprecated
shh_getMessagesSSHNNDeprecated
admin_addPeerAdminNNReturns undefined
admin_removePeerAdminNNReturns undefined
admin_datadirAdminNNReturns undefined
admin_nodeInfoAdminNNReturns undefined
admin_peersAdminNNReturns undefined
admin_startHTTPAdminNNReturns undefined
admin_startWSAdminNNReturns undefined
admin_stopHTTPAdminNNReturns undefined
admin_stopWSAdminNNReturns undefined
admin_addTrustedPeerAdminNNReturns undefined
admin_removeTrustedPeerAdminNNReturns undefined
admin_startRPCAdminNNReturns undefined
admin_stopRPCAdminNNReturns undefined
admin_exportChainAdminNNReturns undefined
admin_importChainAdminNNReturns undefined
admin_sleepBlocksAdminNNReturns undefined
admin_clearPeerBanListAdminNNReturns undefined
admin_listPeerBanListAdminNNReturns undefined
clique_getSnapshotCliqueNNReturns undefined
clique_getSnapshotAtHashCliqueNNReturns undefined
clique_getSignersCliqueNNReturns undefined
clique_getSignersAtHashCliqueNNReturns undefined
clique_proposeCliqueNNReturns undefined
clique_discardCliqueNNReturns undefined
clique_statusCliqueNNReturns undefined
clique_getSignerCliqueNNReturns undefined
debug_backtraceAtDebugNNReturns undefined
debug_blockProfileDebugYN
debug_cpuProfileDebugYN
debug_dumpBlockDebugNNReturns undefined
debug_gcStatsDebugYN
debug_getBlockRlpDebugNNRequires uint64 param
debug_goTraceDebugYN
debug_freeOSMemoryDebugYN
debug_memStatsDebugYN
debug_mutexProfileDebugYN
debug_seedHashDebugNNNot implemented
debug_setHeadDebugNNNot implemented
debug_setBlockProfileRateDebugYN
debug_setGCPercentDebugYN
debug_setMutexProfileFractionDebugYN
debug_stacksDebugYN
debug_startCPUProfileDebugYN
debug_startGoTraceDebugYN
debug_stopCPUProfileDebugYN
debug_stopGoTraceDebugYN
debug_traceBlockDebugYN
debug_traceBlockByNumberDebugYN
debug_traceBlockByHashDebugYN
debug_traceBlockFromFileDebugNNReturns undefined
debug_standardTraceBlockToFileDebugNNReturns undefined
debug_standardTraceBadBlockToFileDebugNNReturns undefined
debug_traceTransactionDebugYN
debug_traceCallDebugYN
debug_traceChainDebugNNReturns undefined
debug_traceBadBlockDebugNNReturns undefined
debug_verbosityDebugNNNot implemented
debug_vmoduleDebugNNNot implemented
debug_writeBlockProfileDebugYN
debug_writeMemProfileDebugYN
debug_writeMutexProfileDebugYN
debug_getRawBlockDebugNNNot implemented
debug_getRawHeaderDebugNNNot implemented
debug_getRawReceiptsDebugNNNot implemented
debug_getRawTransactionDebugNNNot implemented
debug_printBlockDebugYN
debug_getHeaderRlpDebugNNRequires uint64 param
debug_intermediateRootsDebugYNReturns empty hash
debug_getBadBlocksDebugNNNot implemented
debug_storageRangeAtDebugNNNot implemented
debug_getModifiedAccountsByNumberDebugNNNot implemented
debug_getModifiedAccountsByHashDebugNNNot implemented
les_serverInfoLesNNReturns undefined
les_clientInfoLesNNReturns undefined
les_priorityClientInfoLesNNReturns undefined
les_addBalanceLesNNReturns undefined
les_setClientParamsLesNNReturns undefined
les_setDefaultParamsLesNNReturns undefined
les_latestCheckpointLesNNReturns undefined
les_getCheckpointLesNNReturns undefined
les_getCheckpointContractAddressLesNNReturns undefined
txpool_contentTxPoolYYSee experimental mempool
txpool_contentFromTxPoolYYSee experimental mempool
txpool_inspectTxPoolYYSee experimental mempool
txpool_statusTxPoolYYSee experimental mempool
trace_callManyTraceNNNot implemented
eth_signTypedDataEthWNEIP-712 partial
eth_fillTransactionEthYY
eth_getTransactionLogsEthYYCosmos-specific
miner_startMinerNNReturns undefined
miner_stopMinerNNReturns undefined
miner_setEtherbaseMinerNNReturns undefined
miner_setGasPriceMinerNNReturns undefined
miner_setGasLimitMinerNNReturns undefined
miner_setExtraMinerNNReturns undefined
miner_setRecommitIntervalMinerNNReturns undefined
miner_getHashrateMinerNNReturns undefined
engine_newPayloadV1EngineNNReturns undefined
engine_newPayloadV2EngineNNReturns undefined
engine_newPayloadV3EngineNNReturns undefined
engine_forkchoiceUpdatedV1EngineNNReturns undefined
engine_forkchoiceUpdatedV2EngineNNReturns undefined
engine_forkchoiceUpdatedV3EngineNNReturns undefined
engine_getPayloadV1EngineNNReturns undefined
engine_getPayloadV2EngineNNReturns undefined
engine_getPayloadV3EngineNNReturns undefined
engine_exchangeCapabilitiesEngineNNReturns undefined
engine_exchangeTransitionConfigurationV1EngineNNReturns undefined
engine_getPayloadBodiesByHashV1EngineNNReturns undefined
engine_getPayloadBodiesByRangeV1EngineNNReturns undefined
engine_getBlobsV1EngineNNReturns undefined
trace_callTraceNNNot implemented
trace_rawTransactionTraceNNNot implemented
trace_replayBlockTransactionsTraceNNNot implemented
trace_replayTransactionTraceNNNot implemented
trace_blockTraceNNNot implemented
trace_filterTraceNNNot implemented
trace_getTraceNNNot implemented
trace_transactionTraceNNNot implemented
Block Number can be entered as a Hex string, "earliest", "latest" or "pending".
EIP-1559 Support: Cosmos EVM supports EIP-1559 transaction types with eth_maxPriorityFeePerGas, though eth_feeHistory is not yet implemented.Consensus Differences: Due to using ‘CometBFT’ BFT consensus instead of Proof of Work/Stake:
  • Uncle-related methods always return 0 or null
  • Block reorganizations are not possible
  • Engine API (engine_*) is not applicable - ‘CometBFT’ handles consensus
Methods Not Implemented:
  • eth_createAccessList (EIP-2930) - Access list transactions
  • eth_feeHistory - Fee history for EIP-1559
  • eth_getFilterChanges / eth_getFilterLogs - Filter management issues
  • eth_fillTransaction - Transaction filling utility
  • eth_resend - Transaction resending utility
  • personal_sendTransaction / personal_ecRecover - Personal namespace methods
  • personal_lockAccount - Always returns false (not supported)
  • debug_getRaw* methods - Raw data access methods
  • debug_printBlock - Block printing utility
  • trace_* methods - Advanced tracing features
  • engine_* methods - Post-merge Engine API (uses ‘CometBFT’ instead)
  • admin_* methods - Node administration
  • les_* methods - Light Ethereum Subprotocol
  • clique_* methods - Proof of Authority consensus
Partial Implementations:
  • eth_getProof - Requires block height > 2
  • eth_signTypedData (EIP-712) - Partial implementation
  • eth_subscribe - Works for newHeads, logs, and newPendingTransactions but not syncing
  • personal_unlockAccount - Always returns false
  • debug_traceTransaction - Has issues with block height
For more details on how Cosmos EVM differs from standard Ethereum implementations, see Differences from Standard EVMs.

Examples

Below is a list of the RPC methods, the parameters and an example response from the namespaces.

Web3 Methods

web3_clientVersion

Get the web3 client version.

Parameters (0)

Result

{"jsonrpc":"2.0","id":1,"result":"Cosmos/0.1.3+/linux/go1.18"}

Client Examples

Shell HTTP
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "web3_clientVersion", "params": []}'
Websocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "web3_clientVersion", "params": []}'
Javascript Console
web3.clientVersion();

web3_sha3

Returns Keccak-256 (not the standardized SHA3-256) of the given data.

Parameters (1)

1: input hexutil.Bytes
  • Required: [Y] Yes

Result

{"jsonrpc":"2.0","id":1,"result":"0x1b84adea42d5b7d192fd8a61a85b25abe0757e9a65cab1da470258914053823f"}

Client Examples

Shell HTTP
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "web3_sha3", "params": [<input>]}'
Websocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "web3_sha3", "params": [<input>]}'
Javascript Console
web3.sha3(input);

Net Methods

net_version

Returns the current network id.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_version","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"8"}

net_peerCount

Returns the number of peers currently connected to the client.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":23}

net_listening

Returns if client is actively listening for network connections.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"net_listening","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":true}

Eth Methods

eth_protocolVersion

Returns the current ethereum protocol version.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_protocolVersion","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x3f"}

eth_syncing

The sync status object may need to be different depending on the details of cometbft’s sync protocol. However, the ‘synced’ result is simply a boolean, and can easily be derived from cometbft’s internal sync state.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_syncing","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":false}

eth_gasPrice

Returns the current gas price in the default EVM denomination parameter.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0"}

eth_accounts

Returns array of all eth accounts.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_accounts","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":["0x3b7252d007059ffc82d16d022da3cbf9992d2f70","0xddd64b4712f7c8f1ace3c145c950339eddaf221d","0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0"]}

eth_blockNumber

Returns the current block height.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x66"}

eth_getBalance

Returns the account balance for a given account address and Block Number.

Parameters

  • Account Address
  • Block Number or Block Hash (EIP-1898)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBalance","params":["0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x36354d5575577c8000"}

eth_getStorageAt

Returns the storage address for a given account address.

Parameters

  • Account Address
  • Integer of the position in the storage
  • Block Number or Block Hash (EIP-1898)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getStorageAt","params":["0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0", "0", "latest"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000000000000000000"}

eth_getTransactionCount

Returns the total transaction for a given account address and Block Number.

Parameters

  • Account Address
  • Block Number or Block Hash (EIP-1898)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionCount","params":["0x7bf7b17da59880d9bcca24915679668db75f9397", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x8"}

eth_getBlockTransactionCountByNumber

Returns the total transaction count for a given block number.

Parameters

  • Block number
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByNumber","params":["0x1"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"difficulty":null,"extraData":"0x0","gasLimit":"0xffffffff","gasUsed":"0x0","hash":"0x8101cc04aea3341a6d4b3ced715e3f38de1e72867d6c0db5f5247d1a42fbb085","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","nonce":null,"number":"0x17d","parentHash":"0x70445488069d2584fea7d18c829e179322e2b2185b25430850deced481ca2e77","sha3Uncles":null,"size":"0x1df","stateRoot":"0x269bb17fe7adb8dd5f15f57b717979f82078d6b7a675c1ba1b0da2d27e415fcc","timestamp":"0x5f5ba97c","totalDifficulty":null,"transactions":[],"transactionsRoot":"0x","uncles":[]}}

eth_getBlockTransactionCountByHash

Returns the total transaction count for a given block hash.

Parameters

  • Block Hash
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockTransactionCountByHash","params":["0x8101cc04aea3341a6d4b3ced715e3f38de1e72867d6c0db5f5247d1a42fbb085"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x3"}

eth_getCode

Returns the code for a given account address and Block Number.

Parameters

  • Account Address
  • Block Number or Block Hash (EIP-1898)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getCode","params":["0x7bf7b17da59880d9bcca24915679668db75f9397", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xef616c92f3cfc9e92dc270d6acff9cea213cecc7020a76ee4395af09bdceb4837a1ebdb5735e11e7d3adb6104e0c3ac55180b4ddf5e54d022cc5e8837f6a4f971b"}

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 recognizable 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.
The address to sign with must be unlocked.

Parameters

  • Account Address
  • Message to sign
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sign","params":["0x3b7252d007059ffc82d16d022da3cbf9992d2f70", "0xdeadbeaf"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x909809c76ed2a5d38733de39207d0f411222b9b49c64a192bf649cb13f63f37b45acb4f6939facb4f1c277bc70fb00407564140c0f18600ac44388f2c1dfd1dc1b"}

eth_signTypedData

Signs typed structured data according to EIP-712. This method provides a more secure way to sign structured data compared to eth_sign.
Implementation Note: This method requires a properly formatted domain parameter in the typed data structure. Without the domain, it will return an error: “domain is undefined”.

Parameters

  • Account Address (20 bytes)
  • Typed data object containing:
    • domain: EIP-712 domain separator
    • types: Type definitions
    • primaryType: Primary type name
    • message: Message to sign
// Request - Note: proper domain structure is required
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_signTypedData","params":["0x3b7252d007059ffc82d16d022da3cbf9992d2f70", {"domain":{"name":"Example","version":"1","chainId":1,"verifyingContract":"0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC"},"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"}]},"primaryType":"Person","message":{"name":"Bob","wallet":"0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB"}}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x..."}  // Returns signature

eth_sendTransaction

Sends transaction from given account to a given account.

Parameters

  • Object containing: from: DATA, 20 Bytes - The address the transaction is send from. to: DATA, 20 Bytes - (optional when creating new contract) The address the transaction is directed to. gas: QUANTITY - (optional, default: 90000) Integer of the gas provided for the transaction execution. It will return unused gas. gasPrice: QUANTITY - (optional, default: To-Be-Determined) Integer of the gasPrice used for each paid gas value: QUANTITY - value sent with this transaction data: DATA - The compiled code of a contract OR the hash of the invoked method signature and 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.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendTransaction","params":[{"from":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70", "to":"0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0", "value":"0x16345785d8a0000", "gasLimit":"0x5208", "gasPrice":"0x55ae82600"}],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x33653249db68ebe5c7ae36d93c9b2abc10745c80a72f591e296f598e2d4709f6"}

eth_sendRawTransaction

Creates new message call transaction or a contract creation for signed transactions. You can get signed transaction data using the personal_sign method.

Parameters

  • The signed transaction data
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_sendRawTransaction","params":["0xf9ff74c86aefeb5f6019d77280bbb44fb695b4d45cfe97e6eed7acd62905f4a85034d5c68ed25a2e7a8eeb9baf1b8401e4f865d92ec48c1763bf649e354d900b1c"],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0000000000000000000000000000000000000000000000000000000000000000"}

eth_call

Executes a new message call immediately without creating a transaction on the block chain.

Parameters

  • Object containing: 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 - gas provided for the transaction execution. eth_call consumes zero gas, but this parameter may be needed by some executions. gasPrice: QUANTITY - gasPrice used for each paid gas value: QUANTITY - value sent with this transaction data: DATA - (optional) Hash of the method signature and encoded parameters. For details see Ethereum Contract ABI in the Solidity documentation
  • Block number or Block Hash (EIP-1898)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_call","params":[{"from":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70", "to":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d", "gas":"0x5208", "gasPrice":"0x55ae82600", "value":"0x16345785d8a0000", "data": "0xd46e8dd67c5d32be8d46e8dd67c5d32be8058bb8eb970870f072445675058bb8eb970870f072445675"}, "0x0"],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x"}

eth_createAccessList

Creates an access list for a transaction. Access lists specify which addresses and storage keys a transaction will access, potentially reducing gas costs for complex transactions. Implementation: rpc/backend/tx_info.go:396

Parameters

  • Object containing transaction data:
    • 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) Gas provided for execution
    • gasPrice: QUANTITY - (optional) Gas price for each unit of gas
    • value: QUANTITY - (optional) Value sent with the transaction
    • data: DATA - (optional) Transaction data payload
  • Block number or Block Hash (EIP-1898)

Returns

  • Object containing:
    • accessList: Array of access list entries
      • address: DATA, 20 Bytes - Account address
      • storageKeys: Array of DATA - Storage keys accessed
    • gasUsed: QUANTITY - Gas used for execution with access list

Client Examples

Shell HTTP
curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"eth_createAccessList",
  "params":[{
    "from":"0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
    "to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "gas":"0x76c0",
    "gasPrice":"0x9184e72a000",
    "data":"0xa9059cbb000000000000000000000000a0b86a33e6d1cde81f9c1ce51dd74f3d1111bb9e0000000000000000000000000000000000000000000000000de0b6b3a7640000"
  }, "latest"],
  "id":1
}' -H "Content-Type: application/json" http://localhost:8545
Websocket
wscat -c ws://localhost:8546 -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_createAccessList",
  "params": [{
    "from":"0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
    "to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "data":"0xa9059cbb000000000000000000000000a0b86a33e6d1cde81f9c1ce51dd74f3d1111bb9e0000000000000000000000000000000000000000000000000de0b6b3a7640000"
  }, "latest"]
}'
Javascript Console
await provider.send("eth_createAccessList", [{
  from: "0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
  to: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
  data: "0xa9059cbb000000000000000000000000a0b86a33e6d1cde81f9c1ce51dd74f3d1111bb9e0000000000000000000000000000000000000000000000000de0b6b3a7640000"
}, "latest"]);

Result

Usage Example

// Generate access list for optimization
const accessList = await provider.send("eth_createAccessList", [{
    to: contractAddress,
    data: contract.interface.encodeFunctionData("complexFunction", [arg1, arg2]),
    gasPrice: "0x" + gasPrice.toString(16)
}, "latest"]);

// Use access list in actual transaction for gas savings
const tx = await contract.complexFunction(arg1, arg2, {
    accessList: accessList.accessList,
    gasLimit: accessList.gasUsed
});

eth_estimateGas

Returns an estimate value of the gas required to send the transaction.

Parameters

  • Object containing: from: DATA, 20 Bytes - The address the transaction is send from. to: DATA, 20 Bytes - (optional when creating new contract) The address the transaction is directed to. value: QUANTITY - value sent with this transaction
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_estimateGas","params":[{"from":"0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0", "to":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70", "value":"0x16345785d8a00000"}],"id":1}'  -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x1199b"}

eth_getBlockByNumber

Returns information about a block by block number.

Parameters

  • Block Number
  • If true it returns the full transaction objects, if false only the hashes of the transactions.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByNumber","params":["0x1", false],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"difficulty":null,"extraData":"0x0","gasLimit":"0xffffffff","gasUsed":null,"hash":"0xabac6416f737a0eb54f47495b60246d405d138a6a64946458cf6cbeae0d48465","logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","nonce":null,"number":"0x1","parentHash":"0x","sha3Uncles":null,"size":"0x9b","stateRoot":"0x","timestamp":"0x5f5bd3e5","totalDifficulty":null,"transactions":[],"transactionsRoot":"0x","uncles":[]}}

eth_getBlockByHash

Returns the block info given the hash found in the command above and a bool.

Parameters

  • Hash of a block.
  • If true it returns the full transaction objects, if false only the hashes of the transactions.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockByHash","params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4", false],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"difficulty":null,"extraData":"0x0","gasLimit":"0xffffffff","gasUsed":null,"hash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4","logsBloom":"0x00000000100000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000002000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000","miner":"0x0000000000000000000000000000000000000000","nonce":null,"number":"0xc","parentHash":"0x404e58f31a9ede1b614b98701d6b0fbf1450f186842dbcf6426dd16811a5ca0d","sha3Uncles":null,"size":"0x307","stateRoot":"0x599ccdb111fc62c6398dc39be957df8e97bf8ab72ce6c06ff10641a92b754627","timestamp":"0x5f5fdbbd","totalDifficulty":null,"transactions":["0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615"],"transactionsRoot":"0x4764dba431128836fa919b83d314ba9cc000e75f38e1c31a60484409acea777b","uncles":[]}}

eth_getHeaderByHash

Returns block header information by block hash. The header contains metadata about the block without the full transaction list. Implementation: rpc/backend/headers.go:21

Parameters

  • DATA, 32 Bytes - Hash of a block

Returns

  • Object - Block header object containing:
    • parentHash: DATA, 32 Bytes - Hash of the parent block
    • sha3Uncles: DATA, 32 Bytes - SHA3 of the uncles data in the block
    • miner: DATA, 20 Bytes - Address of the block miner
    • stateRoot: DATA, 32 Bytes - Root of the state trie
    • transactionsRoot: DATA, 32 Bytes - Root of the transaction trie
    • receiptsRoot: DATA, 32 Bytes - Root of the receipts trie
    • logsBloom: DATA, 256 Bytes - Bloom filter for block logs
    • difficulty: QUANTITY - Difficulty for this block
    • number: QUANTITY - Block number
    • gasLimit: QUANTITY - Maximum gas allowed in this block
    • gasUsed: QUANTITY - Total gas used by all transactions
    • timestamp: QUANTITY - Unix timestamp when block was created
    • extraData: DATA - Extra data field of this block
    • mixHash: DATA, 32 Bytes - Mix hash
    • nonce: DATA, 8 Bytes - Proof-of-work hash
    • baseFeePerGas: QUANTITY - Base fee per gas (EIP-1559)
    • hash: DATA, 32 Bytes - Hash of the block

Client Examples

Shell HTTP
curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"eth_getHeaderByHash",
  "params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"],
  "id":1
}' -H "Content-Type: application/json" http://localhost:8545
Websocket
wscat -c ws://localhost:8546 -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getHeaderByHash",
  "params": ["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"]
}'
Javascript Console
await provider.send("eth_getHeaderByHash", ["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"]);

Result

{
  "jsonrpc":"2.0",
  "id":1,
  "result":{
    "parentHash":"0x404e58f31a9ede1b614b98701d6b0fbf1450f186842dbcf6426dd16811a5ca0d",
    "sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "miner":"0x0000000000000000000000000000000000000000",
    "stateRoot":"0x599ccdb111fc62c6398dc39be957df8e97bf8ab72ce6c06ff10641a92b754627",
    "transactionsRoot":"0x4764dba431128836fa919b83d314ba9cc000e75f38e1c31a60484409acea777b",
    "receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
    "logsBloom":"0x00000000100000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000002000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000",
    "difficulty":"0x0",
    "number":"0xc",
    "gasLimit":"0xffffffff",
    "gasUsed":"0x5289",
    "timestamp":"0x5f5fdbbd",
    "extraData":"0x0",
    "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
    "nonce":"0x0000000000000000",
    "baseFeePerGas":"0x7",
    "hash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"
  }
}

eth_getHeaderByNumber

Returns block header information by block number. Similar to eth_getHeaderByHash but accepts a block number instead of a hash. Implementation: rpc/backend/headers.go:13

Parameters

  • Block number as QUANTITY (hex string) or block tag:
    • "latest" - Latest mined block
    • "earliest" - Genesis block
    • "pending" - Pending state/transactions

Returns

  • Object - Block header object (same structure as eth_getHeaderByHash)

Client Examples

Shell HTTP
curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"eth_getHeaderByNumber",
  "params":["latest"],
  "id":1
}' -H "Content-Type: application/json" http://localhost:8545
Websocket
wscat -c ws://localhost:8546 -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_getHeaderByNumber",
  "params": ["0x1b4"]
}'
Javascript Console
// Get latest block header
await provider.send("eth_getHeaderByNumber", ["latest"]);

// Get specific block header
await provider.send("eth_getHeaderByNumber", ["0xc"]);

Result

{
  "jsonrpc":"2.0",
  "id":1,
  "result":{
    "parentHash":"0x404e58f31a9ede1b614b98701d6b0fbf1450f186842dbcf6426dd16811a5ca0d",
    "sha3Uncles":"0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
    "miner":"0x0000000000000000000000000000000000000000",
    "stateRoot":"0x599ccdb111fc62c6398dc39be957df8e97bf8ab72ce6c06ff10641a92b754627",
    "transactionsRoot":"0x4764dba431128836fa919b83d314ba9cc000e75f38e1c31a60484409acea777b",
    "receiptsRoot":"0x056b23fbba480696b65fe5a59b8f2148a1299103c4f57df839233af2cf4ca2d2",
    "logsBloom":"0x00000000100000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000002000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000",
    "difficulty":"0x0",
    "number":"0xc",
    "gasLimit":"0xffffffff",
    "gasUsed":"0x5289",
    "timestamp":"0x5f5fdbbd",
    "extraData":"0x0",
    "mixHash":"0x0000000000000000000000000000000000000000000000000000000000000000",
    "nonce":"0x0000000000000000",
    "baseFeePerGas":"0x7",
    "hash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"
  }
}

eth_getTransactionByHash

Returns transaction details given the ethereum tx something.

Parameters

  • hash of a transaction
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByHash","params":["0xec5fa15e1368d6ac314f9f64118c5794f076f63c02e66f97ea5fe1de761a8973"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x7a7398cc11d9c4c8e6f53e0c73824297aceafdab62db9e4b867a0da694384864","blockNumber":"0x188","from":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70","gas":"0x147ee","gasPrice":"0x3b9aca00","hash":"0xec5fa15e1368d6ac314f9f64118c5794f076f63c02e66f97ea5fe1de761a8973","input":"0x6dba746c","nonce":"0x18","to":"0xa655256f589060437e5ffe2246dec385d040f148","transactionIndex":"0x0","value":"0x0","v":"0xa96","r":"0x6db399d694a452fb4106419140a6e5dbbe6817743a0f6f695a651e6576e59a5e","s":"0x25dd6ab1f936d0280d2fed0caeb0ebe5b9a46de6d8cb08ad8fd2c88deb55fc31"}}

eth_getTransactionByBlockHashAndIndex

Returns transaction details given the block hash and the transaction index.

Parameters

  • Hash of a block.
  • Transaction index position.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockHashAndIndex","params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4","blockNumber":"0xc","from":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d","gas":"0x4c4b40","gasPrice":"0x3b9aca00","hash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","input":"0x4f2be91f","nonce":"0x0","to":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","transactionIndex":"0x0","value":"0x0","v":"0xa96","r":"0xced57d973e58b0f634f776d57daf41d3d3387ceb347a3a72ca0746e5ec2b709e","s":"0x384e89e209a5eb147a2bac3a4e399507400ac7b29cd155531f9d6203a89db3f2"}}

eth_getTransactionReceipt

Returns the receipt of a transaction by transaction hash. Note: Tx Code from CometBFT and the Ethereum receipt status are switched:
CometBFTEthereum
Success01
Fail10

Parameters

  • Hash of a transaction
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionReceipt","params":["0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea614"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4","blockNumber":"0xc","contractAddress":"0x0000000000000000000000000000000000000000","cumulativeGasUsed":null,"from":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d","gasUsed":"0x5289","logs":[{"address":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","topics":["0x64a55044d1f2eddebe1b90e8e2853e8e96931cefadbfa0b2ceb34bee36061941"],"data":"0x0000000000000000000000000000000000000000000000000000000000000002","blockNumber":"0xc","transactionHash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","transactionIndex":"0x0","blockHash":"0x0000000000000000000000000000000000000000000000000000000000000000","logIndex":"0x0","removed":false},{"address":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","topics":["0x938d2ee5be9cfb0f7270ee2eff90507e94b37625d9d2b3a61c97d30a4560b829"],"data":"0x0000000000000000000000000000000000000000000000000000000000000002","blockNumber":"0xc","transactionHash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","transactionIndex":"0x0","blockHash":"0x0000000000000000000000000000000000000000000000000000000000000000","logIndex":"0x1","removed":false}],"logsBloom":"0x00000000100000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000040000000000000000000000000200000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000000000000000000000004000000000000002000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000000000010000000000000000000000000000000000000000000000000000000000000000000000000000","status":"0x1","to":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","transactionHash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","transactionIndex":"0x0"}}

eth_newFilter

Create new filter using topics of some kind.

Parameters

  • hash of a transaction
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newFilter","params":[{"topics":["0x0000000000000000000000000000000000000000000000000000000012341234"]}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xdc714a4a2e3c39dc0b0b84d66a3ccb00"}

eth_newBlockFilter

Creates a filter in the node, to notify when a new block arrives.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newBlockFilter","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x3503de5f0c766c68f78a03a3b05036a5"}

eth_newPendingTransactionFilter

Creates a filter in the node, to notify when new pending transactions arrive.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_newPendingTransactionFilter","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x9daacfb5893d946997d3801ea18e9902"}

eth_uninstallFilter

Removes the filter with the given filter id. Returns true if the filter was successfully uninstalled, otherwise false.

Parameters

  • The filter id
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_uninstallFilter","params":["0xb91b6608b61bf56288a661a1bd5eb34a"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":true}

eth_getFilterChanges

Polling method for a filter, which returns an array of logs which occurred since last poll.

Parameters

  • The filter id
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterChanges","params":["0x127e9eca4f7751fb4e5cb5291ad8b455"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":["0xc6f08d183a81e149896fc5317c872f9092068e88e956ca1864e9bd4c81c09b44","0x3ca6dfb5be15549d721d1b3d10c1bec50ed6217c9ac7b61df361fac9692a27e5","0x776fffac134171acb1ebf2e59856625501ad5ccc5c4c8fe0359e0d4dff8919f2","0x84123103704dbd738c089276ab2b04b5936330b24f6e78453c4ba8bf4848aaf9","0xffddbe5bd8e8aa41e44002daa9ea89ade9e6980a0d83f51d104cf16498827eca","0x53430e49963e8ae32605d8f22dec2e757a691e6436d593854ca4d9383eeab86a","0x975948058c9351a91fbec332ca00dda39d1a919f5f16b996a4c7e30c38ba423b","0x619e37e32024c8efef7f7220e6caff4ee1d682ea78b2ac91e0a6b30850dc0677","0x31a5d985a40d08303ac68000ce008df512bcd1a911c497415c97f0624b4a271a","0x91dcf1fce4503a8dbb3e6fb61073f25cd31d69c766ecba639fefde4436e59d07","0x606d9e0143cfdb410a6812c590a8135b5c6b5c59eec26d760d5cd930aa47257d","0xd3c00b859b29b20ba654415eef648ef58251389c73a138580db87675b0d5465f","0x954391f0eb50888be90489898016ebb54f750f612f3adec2a00854955d5e52d8","0x698905f06aff921a9e9fcef39b8b0d107747c3e6204d2ea79cf4c12debf8d253","0x9fcafec5721938a06eb8e2951ede4b6ef8fae54a8c8f85f3166ec9782a0032b5","0xaec6d3364e47a5716ba69e4705f3c705d017f81298859589591183bfea87be7a","0x91bf2ee13319b6eaca96ed89c126437b66c4df1b13560c6a9bb18556ee3b7e1f","0x4f426dc1fc0ea8149052033065b237892d2d34927b2d558ab50c5a7fb98d6e79","0xdd809fb07e5aab638fef5311371b4e2b27c9c9a6183fde0cdd2b7724f6d2a89b","0x7e12fc92ab953e233a304959a2a8474d96195e71efd9388fdceb1326a577811a","0x30618ef6b490c3cc9979c47163459db37c1a1e0aa5793c56accd417f9d89973b","0x614609f06ee24bae7408e45895b1a25e6b19a8159aeea7a95c9d1339d9ba286f","0x115ddc6d533620040791d241f01f1c5ae3d9d1a8f64b15af5e9793e4d9096e22","0xb7458c9323beeca2cd54f32a6af5671f3cd5a7a251aed9d82bdd6ebe5f56305b","0x573dd48a5ba7bf4cc3d49597cd7419f75ecc9897258f1ebadebd670446d0d358","0xcb6670918439f9698413b53f3b5336d82ca4be152fdefaacf45e052fff6262fc","0xf3fe2a8945abafd269ab97bfdc80b3dbff2202ffdce59a227f952874b966b230","0x989980707007533cc0840a079f77f261a2e818abae1a1ffd3af02f3fff1d35fd","0x886b6ae365fec996be8a9a2c31cf4cda97ff8352908be2c83f17abd66ef1591e","0xfd90df68706ef95a62b317de93d6899a9bd6c80416e42d007f5c30fcdedfce24","0x7af8491fbb0373886d9032bb74e0ef52ed9e100f260b79bd15f46126b38cbede","0x91d1e2cd55533cf7dd5de86c9aa73295e811b1279be193d429bbd6ba83810e16","0x6b65b3128c2104005a04923288fe2aa33a2477a4962bef70532f94cab582f2a7"]}

eth_getFilterLogs

Returns an array of all logs matching filter with given id.

Parameters

  • QUANTITY - The filter id
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getFilterLogs","params":["0x127e9eca4f7751fb4e5cb5291ad8b455"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"error":{"code":-32000,"message":"filter 0x35b64c227ce30e84fc5c7bd347be380e doesn't have a LogsSubscription type: got 5"}}

eth_getLogs

Returns an array of all logs matching a given filter object.

Parameters

  • Object containing: 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 Bytes DATA topics. Topics are order-dependent. Each topic can also be an array of DATA with “or” options. blockhash: (optional, future) With the addition of EIP-234, blockHash will be a new filter option which restricts the logs returned to the single block with the 32-byte hash blockHash. Using blockHash is equivalent to fromBlock = toBlock = the block number with hash blockHash. If blockHash is present in in the filter criteria, then neither fromBlock nor toBlock are allowed.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getLogs","params":[{"topics":["0x775a94827b8fd9b519d36cd827093c664f93347070a554f65e4a6f56cd738898","0x0000000000000000000000000000000000000000000000000000000000000011"], "fromBlock":"latest"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":[]}

eth_coinbase

Returns the account the mining rewards will be send to.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_coinbase","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x7cB61D4117AE31a12E393a1Cfa3BaC666481D02E"}

eth_mining

Returns whether the client is actively mining new blocks.
Always returns false as Cosmos EVM uses ‘CometBFT’ consensus instead of mining.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_mining","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":false}

eth_hashrate

Returns the number of hashes per second that the node is mining with.
Always returns 0x0 as Cosmos EVM uses ‘CometBFT’ consensus instead of mining.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_hashrate","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0"}

eth_chainId

Returns the chain ID used for signing replay-protected transactions.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_chainId","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x40000"}

eth_getUncleCountByBlockHash

Returns the number of uncles in a block matching the given block hash.
Always returns 0x0 as Cosmos EVM does not have uncles due to using ‘CometBFT’ consensus.

Parameters

  • Block hash
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleCountByBlockHash","params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0"}

eth_getUncleCountByBlockNumber

Returns the number of uncles in a block matching the given block number.
Always returns 0x0 as Cosmos EVM does not have uncles due to using ‘CometBFT’ consensus.

Parameters

  • Block number
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleCountByBlockNumber","params":["latest"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0"}

eth_getUncleByBlockHashAndIndex

Returns information about an uncle by block hash and uncle index position.
Always returns null as Cosmos EVM does not have uncles due to using ‘CometBFT’ consensus.

Parameters

  • Block hash
  • Uncle index position
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleByBlockHashAndIndex","params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

eth_getUncleByBlockNumberAndIndex

Returns information about an uncle by block number and uncle index position.
Always returns null as Cosmos EVM does not have uncles due to using ‘CometBFT’ consensus.

Parameters

  • Block number
  • Uncle index position
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getUncleByBlockNumberAndIndex","params":["0x1", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

eth_getTransactionByBlockNumberAndIndex

Returns information about a transaction by block number and transaction index position.

Parameters

  • Block number
  • Transaction index position
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionByBlockNumberAndIndex","params":["0x1", "0x0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"blockHash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4","blockNumber":"0x1","from":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d","gas":"0x4c4b40","gasPrice":"0x3b9aca00","hash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","input":"0x4f2be91f","nonce":"0x0","to":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","transactionIndex":"0x0","value":"0x0","v":"0xa96","r":"0xced57d973e58b0f634f776d57daf41d3d3387ceb347a3a72ca0746e5ec2b709e","s":"0x384e89e209a5eb147a2bac3a4e399507400ac7b29cd155531f9d6203a89db3f2"}}

eth_maxPriorityFeePerGas

Returns the current maxPriorityFeePerGas per gas in wei.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_maxPriorityFeePerGas","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x0"}

eth_getBlockReceipts

Returns all transaction receipts for a given block.

Parameters

  • Block number or block hash
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getBlockReceipts","params":["latest"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":[{"blockHash":"0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4","blockNumber":"0xc","contractAddress":"0x0000000000000000000000000000000000000000","cumulativeGasUsed":null,"from":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d","gasUsed":"0x5289","logs":[],"logsBloom":"0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000","status":"0x1","to":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","transactionHash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","transactionIndex":"0x0"}]}

eth_getTransactionLogs

Returns the logs for a specific transaction.

Parameters

  • Transaction hash
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getTransactionLogs","params":["0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":[{"address":"0x439c697e0742a0ddb124a376efd62a72a94ac35a","topics":["0x64a55044d1f2eddebe1b90e8e2853e8e96931cefadbfa0b2ceb34bee36061941"],"data":"0x0000000000000000000000000000000000000000000000000000000000000002","blockNumber":"0xc","transactionHash":"0xae64961cb206a9773a6e5efeb337773a6fd0a2085ce480a174135a029afea615","transactionIndex":"0x0","blockHash":"0x0000000000000000000000000000000000000000000000000000000000000000","logIndex":"0x0","removed":false}]}

eth_fillTransaction

Fills the defaults (nonce, gas, gasPrice or 1559 fields) on a given unsigned transaction, and returns it to the caller for further processing (signing + broadcast).

Parameters

  • Transaction object with optional fields
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_fillTransaction","params":[{"from":"0x0123456789012345678901234567890123456789","to":"0x0123456789012345678901234567890123456789","value":"0x1"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"raw":"0x...","tx":{"nonce":"0x0","gasPrice":"0x3b9aca00","gas":"0x5208","to":"0x0123456789012345678901234567890123456789","value":"0x1","input":"0x","v":"0x0","r":"0x0","s":"0x0","hash":"0x..."}}}

eth_resend

Resends a transaction with updated gas parameters. Removes the given transaction from the pool and reinserts it with the new gas price and limit.
Implementation Note: This method requires a transaction nonce parameter in the transaction object. Without the nonce, it will return an error: “missing transaction nonce in transaction spec”.

Parameters

  • Original transaction object (must include nonce)
  • New gas price (hex)
  • New gas limit (hex)
// Request - Note the required 'nonce' field in the transaction object
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_resend","params":[{"from":"0x0123456789012345678901234567890123456789","to":"0x0123456789012345678901234567890123456789","value":"0x1","gas":"0x5208","gasPrice":"0x3b9aca00","nonce":"0x0"},"0x3b9aca01","0x5209"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x..."}  // Returns transaction hash

eth_getProof

Returns the account- and storage-values of the specified account including the Merkle-proof.
Implementation Note: This method requires a valid block height. Using “latest” or block heights less than 1 will return an error: “cannot query with height < 0; please provide a valid height”. You must specify an actual block number.

Parameters

  • Address of account or contract
  • Array of storage positions (32-byte storage slot)
  • Block Number (must be a specific number, not “latest”)
// Request - Note: using a specific block number instead of "latest"
curl -X POST --data '{"jsonrpc":"2.0","method":"eth_getProof","params":["0x1234567890123456789012345678901234567890",["0x0000000000000000000000000000000000000000000000000000000000000000","0x0000000000000000000000000000000000000000000000000000000000000001"],"0x1"],"id":1}' -H "Content-type:application/json" http://localhost:8545
// Result
{"jsonrpc": "2.0", "id": 1, "result": {"address": "0x1234567890123456789012345678901234567890", "accountProof": ["0xf90211a090dcaf88c40c7bbc95a912cbdde67c175767b31173df9ee4b0d733bfdd511c43a0babe369f6b12092f49181ae04ca173fb68d1a5456f18d20fa32cba73954052bda0473ecf8a7e36a829e75039a3b055e51b8332cbf03324ab4af2066bbd6fbf0021a0bbda34753d7aa6c38e603f360244e8f59611921d9e1f128372fec0d586d4f9e0a04e44caecff45c9891f74f6a2156735886eedf6f1a733628ebc802ec79d844648a0a5f3f2f7542148c973977c8a1e154c4300fec92f755f7846f1b734d3ab1d90e7a0e823850f50bf72baae9d1733a36a444ab65d0a6faaba404f0583ce0ca4dad92da0f7a00cbe7d4b30b11faea3ae61b7f1f2b315b61d9f6bd68bfe587ad0eeceb721a07117ef9fc932f1a88e908eaead8565c19b5645dc9e5b1b6e841c5edbdfd71681a069eb2de283f32c11f859d7bcf93da23990d3e662935ed4d6b39ce3673ec84472a0203d26456312bbc4da5cd293b75b840fc5045e493d6f904d180823ec22bfed8ea09287b5c21f2254af4e64fca76acc5cd87399c7f1ede818db4326c98ce2dc2208a06fc2d754e304c48ce6a517753c62b1a9c1d5925b89707486d7fc08919e0a94eca07b1c54f15e299bd58bdfef9741538c7828b5d7d11a489f9c20d052b3471df475a051f9dd3739a927c89e357580a4c97b40234aa01ed3d5e0390dc982a7975880a0a089d613f26159af43616fd9455bb461f4869bfede26f2130835ed067a8b967bfb80", "0xf90211a0395d87a95873cd98c21cf1df9421af03f7247880a2554e20738eec2c7507a494a0bcf6546339a1e7e14eb8fb572a968d217d2a0d1f3bc4257b22ef5333e9e4433ca012ae12498af8b2752c99efce07f3feef8ec910493be749acd63822c3558e6671a0dbf51303afdc36fc0c2d68a9bb05dab4f4917e7531e4a37ab0a153472d1b86e2a0ae90b50f067d9a2244e3d975233c0a0558c39ee152969f6678790abf773a9621a01d65cd682cc1be7c5e38d8da5c942e0a73eeaef10f387340a40a106699d494c3a06163b53d956c55544390c13634ea9aa75309f4fd866f312586942daf0f60fb37a058a52c1e858b1382a8893eb9c1f111f266eb9e21e6137aff0dddea243a567000a037b4b100761e02de63ea5f1fcfcf43e81a372dafb4419d126342136d329b7a7ba032472415864b08f808ba4374092003c8d7c40a9f7f9fe9cc8291f62538e1cc14a074e238ff5ec96b810364515551344100138916594d6af966170ff326a092fab0a0d31ac4eef14a79845200a496662e92186ca8b55e29ed0f9f59dbc6b521b116fea090607784fe738458b63c1942bba7c0321ae77e18df4961b2bc66727ea996464ea078f757653c1b63f72aff3dcc3f2a2e4c8cb4a9d36d1117c742833c84e20de994a0f78407de07f4b4cb4f899dfb95eedeb4049aeb5fc1635d65cf2f2f4dfd25d1d7a0862037513ba9d45354dd3e36264aceb2b862ac79d2050f14c95657e43a51b85c80", "0xf90171a04ad705ea7bf04339fa36b124fa221379bd5a38ffe9a6112cb2d94be3a437b879a08e45b5f72e8149c01efcb71429841d6a8879d4bbe27335604a5bff8dfdf85dcea00313d9b2f7c03733d6549ea3b810e5262ed844ea12f70993d87d3e0f04e3979ea0b59e3cdd6750fa8b15164612a5cb6567cdfb386d4e0137fccee5f35ab55d0efda0fe6db56e42f2057a071c980a778d9a0b61038f269dd74a0e90155b3f40f14364a08538587f2378a0849f9608942cf481da4120c360f8391bbcc225d811823c6432a026eac94e755534e16f9552e73025d6d9c30d1d7682a4cb5bd7741ddabfd48c50a041557da9a74ca68da793e743e81e2029b2835e1cc16e9e25bd0c1e89d4ccad6980a041dda0a40a21ade3a20fcd1a4abb2a42b74e9a32b02424ff8db4ea708a5e0fb9a09aaf8326a51f613607a8685f57458329b41e938bb761131a5747e066b81a0a16808080a022e6cef138e16d2272ef58434ddf49260dc1de1f8ad6dfca3da5d2a92aaaadc58080", "0xf851808080a009833150c367df138f1538689984b8a84fc55692d3d41fe4d1e5720ff5483a6980808080808080808080a0a319c1c415b271afc0adcb664e67738d103ac168e0bc0b7bd2da7966165cb9518080"], "balance": "0x0", "codeHash": "0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470", "nonce": "0x0", "storageHash": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421", "storageProof": [{"key": "0x0000000000000000000000000000000000000000000000000000000000000000", "value": "0x0", "proof": []}, {"key": "0x0000000000000000000000000000000000000000000000000000000000000001", "value": "0x0", "proof": []}]}}

WebSocket Methods

Read more about using websockets.

eth_subscribe

subscribe using JSON-RPC notifications. This allows clients to wait for events instead of polling for them. It works by subscribing to particular events. The node will return a subscription id. For each event that matches the subscription a notification with relevant data is send together with the subscription id.

Parameters

  • Subscription Name
  • Optional Arguments
// Request
{"id": 1, "method": "eth_subscribe", "params": ["newHeads", {"includeTransactions": true}]}
// Result
< {"jsonrpc":"2.0","result":"0x34da6f29e3e953af4d0c7c58658fd525","id":1}

eth_unsubscribe

Unsubscribe from an event using the subscription id

Parameters

  • Subscription ID
// Request
{"id": 1, "method": "eth_unsubscribe", "params": ["0x34da6f29e3e953af4d0c7c58658fd525"]}
// Result
{"jsonrpc":"2.0","result":true,"id":1}

Personal Methods

personal_importRawKey

Private: Requires authentication.
Imports the given unencrypted private key (hex encoded string) into the key store, encrypting it with the passphrase. Returns the address of the new account.
Implementation Note: The private key must be a valid 64-character hex string (32 bytes) without the “0x” prefix. Invalid hex characters will return an error: “invalid hex character ‘x’ in private key”.

Parameters (2)

1: privkey string
  • Required: [Y] Yes
  • Format: 64 hex characters (32 bytes) without “0x” prefix
2: password string
  • Required: [Y] Yes
// Request - Note: private key without "0x" prefix
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_importRawKey","params":["c5bd76cd0cd948de17a31261567d219576e992d9066fe1a6bca97496dec634e2", "the key is this"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x..."} // Returns the address

personal_listAccounts

Private: Requires authentication.
Returns a list of addresses for accounts this node manages.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_listAccounts","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":["0x3b7252d007059ffc82d16d022da3cbf9992d2f70","0xddd64b4712f7c8f1ace3c145c950339eddaf221d","0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0"]}

personal_lockAccount

Private: Requires authentication.
Removes the private key with given address from memory. The account can no longer be used to send transactions.

Parameters

  • Account Address
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_lockAccount","params":["0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":true}

personal_newAccount

Private: Requires authentication.
Generates a new private key and stores it in the key store directory. The key file is encrypted with the given passphrase. It returns the address of the new account.

Parameters

  • Passphrase
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_newAccount","params":["This is the passphrase"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xf0e4086ad1c6aab5d42161d5baaae2f9ad0571c0"}

personal_unlockAccount

Private: Requires authentication.
Decrypts the key with the given address from the key store. Both passphrase and unlock duration are optional when using the JavaScript console. The unencrypted key will be held in memory until the unlock duration expires. If the unlock duration defaults to 300 seconds. An explicit duration of zero seconds unlocks the key until geth exits. The account can be used with eth_sign and eth_sendTransaction while it is unlocked.

Parameters

  • Account Address
  • Passphrase
  • Duration
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_unlockAccount","params":["0x0f54f47bf9b8e317b214ccd6a7c3e38b893cd7f0", "secret passphrase", 30],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":true}

personal_sendTransaction

Private: Requires authentication.
Validate the given passphrase and submit transaction. The transaction is the same argument as for eth_sendTransaction and contains the from address. If the passphrase can be used to decrypt the private key belonging to tx.from the transaction is verified, signed and send onto the network.
The account is not unlocked globally in the node and cannot be used in other RPC calls.

Parameters

  • Object containing: from: DATA, 20 Bytes - The address the transaction is send from. to: DATA, 20 Bytes - (optional when creating new contract) The address the transaction is directed to. value: QUANTITY - value sent with this transaction
  • Passphrase
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_sendTransaction","params":[{"from":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70","to":"0xddd64b4712f7c8f1ace3c145c950339eddaf221d", "value":"0x16345785d8a0000"}, "passphrase"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xd2a31ec1b89615c8d1f4d08fe4e4182efa4a9c0d5758ace6676f485ea60e154c"}

personal_sign

Private: Requires authentication.
The sign method calculates an Ethereum specific signature with: sign(keccack256("\x19Ethereum Signed Message:\n" + len(message) + message))),

Parameters

  • Message
  • Account Address
  • Password
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_sign","params":["0xdeadbeaf", "0x3b7252d007059ffc82d16d022da3cbf9992d2f70", "password"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xf9ff74c86aefeb5f6019d77280bbb44fb695b4d45cfe97e6eed7acd62905f4a85034d5c68ed25a2e7a8eeb9baf1b8401e4f865d92ec48c1763bf649e354d900b1c"}

personal_ecRecover

Private: Requires authentication.
ecRecover returns the address associated with the private key that was used to calculate the signature in personal_sign.
Implementation Note: The signature must be exactly 65 bytes (130 hex characters). Signatures of other lengths will return an error: “signature must be 65 bytes long”.

Parameters

  • Message (hex encoded)
  • Signature returned from personal_sign (65 bytes)
// Request - Note: signature must be exactly 130 hex characters (65 bytes)
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_ecRecover","params":["0xdeadbeaf", "0xf9ff74c86aefeb5f6019d77280bbb44fb695b4d45cfe97e6eed7acd62905f4a85034d5c68ed25a2e7a8eeb9baf1b8401e4f865d92ec48c1763bf649e354d900b1c"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0x3b7252d007059ffc82d16d022da3cbf9992d2f70"}

personal_initializeWallet

Private: Requires authentication.
Initializes a new wallet at the provided URL, by generating and returning a new private key.

Parameters (1)

Parameters must be given by position. 1: url string
  • Required: [Y] Yes

Client Examples

Shell HTTP
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "personal_initializeWallet", "params": [<url>]}'
Websocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "personal_initializeWallet", "params": [<url>]}'
Javascript Console
personal.initializeWallet(url);

personal_unpair

Private: Requires authentication.
Unpair deletes a pairing between wallet and the node.

Parameters (2)

  • URL
  • Pairing password

Client Examples

Shell HTTP
curl -X POST -H "Content-Type: application/json" http://localhost:8545 --data '{"jsonrpc": "2.0", "id": 42, "method": "personal_unpair", "params": [<url>, <pin>]}'
WebSocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "personal_unpair", "params": [<url>, <pin>]}'
Javascript Console
personal.unpair(url,pin);

personal_listWallets

Private: Requires authentication.
Returns a list of wallets this node manages.
Currently returns null as wallet-level management is not supported.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"personal_listWallets","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

Debug Methods

debug_traceTransaction

The traceTransaction debugging method will attempt to run the transaction in the exact same manner as it was executed on the network. It will replay any transaction that may have been executed prior to this one before it will finally attempt to execute the transaction that corresponds to the given hash.

Parameters

  • Trace Config
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_traceTransaction","params":["0xddecdb13226339681372b44e01df0fbc0f446fca6f834b2de5ecb1e569022ec8", {"tracer": "{data: [], fault: function(log) {}, step: function(log) { if(log.op.toString() == \"CALL\") this.data.push(log.stack.peek(0)); }, result: function() { return this.data; }}"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
//Result
["68410", "51470"]

debug_traceBlockByNumber

The traceBlockByNumber endpoint accepts a block number and will replay the block that is already present in the database.
Stub Implementation: This method is implemented but currently returns an empty array for all requests. The tracing functionality is not fully operational in Cosmos EVM.

Parameters

  • Block number (hex string)
  • Trace Config (optional)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_traceBlockByNumber","params":["0xe", {"tracer": "{data: [], fault: function(log) {}, step: function(log) { if(log.op.toString() == \"CALL\") this.data.push(log.stack.peek(0)); }, result: function() { return this.data; }}"}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result - Currently returns empty array
{"jsonrpc":"2.0","id":1,"result":[]}

debug_traceBlockByHash

Similar to debug_traceBlockByNumber, this method accepts a block hash and will replay the block that is already present in the database.
Stub Implementation: This method is implemented but currently returns an empty array for all requests. The tracing functionality is not fully operational in Cosmos EVM.

Parameters

  • Block hash (32-byte hash)
  • Trace Config (optional)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_traceBlockByHash","params":["0x1b9911f57c13e5160d567ea6cf5b545413f96b95e43ec6e02787043351fb2cc4", {}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result - Currently returns empty array
{"jsonrpc":"2.0","id":1,"result":[]}

debug_traceCall

Traces the execution of an eth_call within the context of a given block. This allows you to simulate a transaction and trace its execution without broadcasting it to the network. Implementation: rpc/namespaces/ethereum/debug/api.go:158

Parameters

  • Object containing transaction call data:
    • from: DATA, 20 Bytes - (optional) The address the call is sent from
    • to: DATA, 20 Bytes - The address the call is directed to
    • gas: QUANTITY - (optional) Gas provided for the call execution
    • gasPrice: QUANTITY - (optional) Gas price for each unit of gas
    • value: QUANTITY - (optional) Value sent with the call
    • data: DATA - (optional) Call data payload
  • Block number or Block Hash (EIP-1898)
  • Tracer configuration (optional) - Object containing:
    • tracer: string - Tracer type (“callTracer”, “prestateTracer”, “4byteTracer”, or custom JavaScript tracer)
    • timeout: string - Timeout for trace execution (e.g., “5s”)
    • tracerConfig: Object - Tracer-specific configuration options

Returns

  • Object - Trace result structure depends on the tracer used:
    • callTracer: Returns call frame tree with gas usage and sub-calls
    • prestateTracer: Returns pre-state (account balances, nonces, code, storage)
    • 4byteTracer: Returns map of 4-byte function selectors to call counts
    • opcodeTracer: Returns list of executed opcodes

Client Examples

Shell HTTP
curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"debug_traceCall",
  "params":[{
    "from":"0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
    "to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "data":"0x70a08231000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
  }, "latest", {"tracer": "callTracer"}],
  "id":1
}' -H "Content-Type: application/json" http://localhost:8545
Websocket
wscat -c ws://localhost:8546 -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "debug_traceCall",
  "params": [{
    "from":"0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
    "to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
    "data":"0x70a08231000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
  }, "latest", {"tracer": "callTracer"}]
}'
Javascript Console
await provider.send("debug_traceCall", [{
  from: "0x8ba1f109551bD432803012645Hac136c5dd7E3D40",
  to: "0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2",
  data: "0x70a08231000000000000000000000000c02aaa39b223fe8d0a0e5c4f27ead9083c756cc2"
}, "latest", {tracer: "callTracer"}]);

Result

Usage Examples

// Trace a contract call to debug execution
const trace = await provider.send("debug_traceCall", [
  {
    to: contractAddress,
    data: contract.interface.encodeFunctionData("transfer", [recipient, amount])
  },
  "latest",
  { tracer: "callTracer" }
]);

// Use prestate tracer to see initial state
const prestate = await provider.send("debug_traceCall", [
  {
    to: contractAddress,
    data: callData
  },
  "latest",
  { tracer: "prestateTracer" }
]);

// Trace with timeout
const trace = await provider.send("debug_traceCall", [
  {
    from: sender,
    to: contractAddress,
    data: complexCallData
  },
  "latest",
  {
    tracer: "callTracer",
    timeout: "10s"
  }
]);

debug_freeOSMemory

Forces the Go runtime to perform a garbage collection and return unused memory to the OS.
Private: Requires authentication.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_freeOSMemory","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_setGCPercent

Sets the garbage collection target percentage. A negative value disables garbage collection.
Private: Requires authentication.

Parameters

  • GC percentage (integer)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_setGCPercent","params":[100],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":100}

debug_memStats

Returns detailed runtime memory statistics.
Private: Requires authentication.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_memStats","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"Alloc":83328680,"TotalAlloc":451796592,"Sys":166452520,"Lookups":0,"Mallocs":4071615,"Frees":3772501,"HeapAlloc":83328680,"HeapSys":153452544,"HeapIdle":51568640,"HeapInuse":101883904,"HeapReleased":44720128,"HeapObjects":299114,"StackInuse":1736704,"StackSys":1736704,"MSpanInuse":1119520,"MSpanSys":1958400,"MCacheInuse":16912,"MCacheSys":31408,"BuckHashSys":1583603,"GCSys":5251008,"OtherSys":2438853,"NextGC":142217095,"LastGC":1754180652189080000,"PauseTotalNs":1266251,"NumGC":18,"NumForcedGC":1,"GCCPUFraction":0.0002128524091018015,"EnableGC":true,"DebugGC":false}}

debug_setBlockProfileRate

Sets the rate of goroutine block profile data collection. A non-zero value enables block profiling.
Private: Requires authentication.

Parameters

  • Profile rate (integer)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_setBlockProfileRate","params":[1],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_writeBlockProfile

Writes a goroutine blocking profile to the specified file.
Private: Requires authentication.

Parameters

  • File path (string)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_writeBlockProfile","params":["block.prof"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_writeMemProfile

Writes an allocation profile to the specified file.
Private: Requires authentication.

Parameters

  • File path (string)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_writeMemProfile","params":["mem.prof"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_writeMutexProfile

Writes a mutex contention profile to the specified file.
Private: Requires authentication.

Parameters

  • File path (string)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_writeMutexProfile","params":["mutex.prof"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_blockProfile

Turns on block profiling for the given duration and writes the profile data to disk.
Private: Requires authentication.

Parameters

  • File path (string) - Output file for the profile
  • Duration in seconds (number)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_blockProfile","params":["block.prof", 30],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_cpuProfile

Turns on CPU profiling for the given duration and writes the profile data to disk.
Private: Requires authentication.

Parameters

  • File path (string) - Output file for the profile
  • Duration in seconds (number)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_cpuProfile","params":["cpu.prof", 30],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_gcStats

Returns garbage collection statistics.
Private: Requires authentication. Cosmos-specific: This method is unique to Cosmos EVM.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_gcStats","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":{"NumGC":10,"PauseTotal":1000000,"Pause":[100000,200000],"PauseEnd":[1234567890,1234567891],"...":"..."}}

debug_goTrace

Turns on Go runtime tracing for the given duration and writes the trace data to disk.
Private: Requires authentication.

Parameters

  • File path (string) - Output file for the trace
  • Duration in seconds (number)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_goTrace","params":["trace.out", 5],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_stacks

Returns a printed representation of the stacks of all goroutines.
Private: Requires authentication.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_stacks","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"goroutine 1 [running]:\n..."}

debug_startCPUProfile

Starts indefinite CPU profiling, writing to the given file.
Private: Requires authentication.

Parameters

  • File path (string) - Output file for the profile
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_startCPUProfile","params":["cpu.prof"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_stopCPUProfile

Stops an ongoing CPU profile.
Private: Requires authentication.
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_stopCPUProfile","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_mutexProfile

Turns on mutex profiling for the given duration and writes the profile data to disk.
Private: Requires authentication.

Parameters

  • File path (string) - Output file for the profile
  • Duration in seconds (number)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_mutexProfile","params":["mutex.prof", 10],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":null}

debug_setMutexProfileFraction

Sets the rate of mutex profiling.
Private: Requires authentication. Cosmos-specific: This method is unique to Cosmos EVM.

Parameters

  • Rate (number) - 0 to disable, 1 for full profiling
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_setMutexProfileFraction","params":[1],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":0}

debug_getHeaderRlp

Returns the RLP encoding of the header of the block.
Private: Requires authentication.
Parameter Type: This method requires the block number as a uint64 (number type), not a hex string. Passing a string will return an error: “invalid argument 0: json: cannot unmarshal string into Go value of type uint64”.

Parameters

  • Block number (uint64 number, not hex string)
// Request - Note: block number as integer, not hex string
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_getHeaderRlp","params":[100],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xf90..."}

debug_getBlockRlp

Returns the RLP encoding of the block.
Private: Requires authentication.
Parameter Type: This method requires the block number as a uint64 (number type), not a hex string. Passing a string will return an error: “invalid argument 0: json: cannot unmarshal string into Go value of type uint64”.

Parameters

  • Block number (uint64 number, not hex string)
// Request - Note: block number as integer, not hex string
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_getBlockRlp","params":[100],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"0xf90..."}

debug_printBlock

Returns a formatted string of the block.
Private: Requires authentication.
Parameter Type: This method requires the block number as a uint64 (number type), not a hex string. Passing a string will return an error: “invalid argument 0: json: cannot unmarshal string into Go value of type uint64”.

Parameters

  • Block number (uint64 number, not hex string)
// Request - Note: block number as integer, not hex string
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_printBlock","params":[100],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":"Block #100\nParent: 0x...\nStateRoot: 0x...\n..."}

debug_intermediateRoots

Returns the intermediate state roots for a transaction.
Private: Requires authentication.

Parameters

  • Transaction hash (hash)
  • Trace config (object, optional)
// Request
curl -X POST --data '{"jsonrpc":"2.0","method":"debug_intermediateRoots","params":["0x88df016429689c079f3b2f6ad39fa052532c56795b733da78a91ebe6a713944b", {}],"id":1}' -H "Content-Type: application/json" http://localhost:8545
// Result
{"jsonrpc":"2.0","id":1,"result":["0x...","0x..."]}

TxPool Methods

txpool_content

Returns a list of the exact details of all the transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only.

Parameters (0)

Client Examples

Shell HTTP
curl -X POST --data '{"jsonrpc":"2.0","method":"txpool_content","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
Websocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "txpool_content", "params": []}'
Javascript Console
txpool.content();

Result

{"jsonrpc":"2.0","id":1,"result":{"pending":{},"queued":{}}}

txpool_contentFrom

Returns transactions from a specific address that are currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only.

Parameters (1)

  1. address - The address to filter transactions from (20 bytes)

Client Examples

Shell HTTP
curl -X POST --data '{"jsonrpc":"2.0","method":"txpool_contentFrom","params":["0x1234567890abcdef1234567890abcdef12345678"],"id":1}' -H "Content-Type: application/json" http://localhost:8545
Websocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "txpool_contentFrom", "params": ["0x1234567890abcdef1234567890abcdef12345678"]}'
Javascript Console
txpool.contentFrom("0x1234567890abcdef1234567890abcdef12345678");

Result

{"jsonrpc":"2.0","id":1,"result":{"pending":{},"queued":{}}}

txpool_inspect

Returns a list on text format to summarize all the transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only. This is a method specifically tailored to developers to quickly see the transactions in the pool and find any potential issues.

Parameters (0)

Client Examples

Shell HTTP
curl -X POST --data '{"jsonrpc":"2.0","method":"txpool_inspect","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
Websocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "txpool_inspect", "params": []}'
Javascript Console
txpool.inspect();

Result

{"jsonrpc":"2.0","id":1,"result":{"pending":{},"queued":{}}}

txpool_status

Returns the number of transactions currently pending for inclusion in the next block(s), as well as the ones that are being scheduled for future execution only.

Parameters (0)

Client Examples

Shell HTTP
curl -X POST --data '{"jsonrpc":"2.0","method":"txpool_status","params":[],"id":1}' -H "Content-Type: application/json" http://localhost:8545
Websocket
wscat -c ws://localhost:8546 -x '{"jsonrpc": "2.0", "id": 1, "method": "txpool_status", "params": []}'
Javascript Console
txpool.status();

Result

{"jsonrpc":"2.0","id":1,"result":{"pending":"0x0","queued":"0x0"}}

eth_createAccessList

This method is fully implemented and supports EIP-2930 access list transactions.
Creates an access list for a given transaction. This is useful for optimizing gas costs when calling contracts, as it allows the transaction to specify which storage slots will be accessed, potentially reducing gas costs for those accesses. The access list contains addresses and storage keys that the transaction plans to access. When included in a transaction, these pre-declared accesses cost less gas.

Parameters

  1. Transaction 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
    • gasPrice: QUANTITY - (optional) Integer of the gasPrice used for each paid gas
    • maxFeePerGas: QUANTITY - (optional) Maximum fee per gas the sender is willing to pay
    • maxPriorityFeePerGas: QUANTITY - (optional) Maximum priority fee per gas the sender is willing to pay
    • value: QUANTITY - (optional) Integer of the value sent with this transaction
    • data: DATA - (optional) Hash of the method signature and encoded parameters
    • accessList: ARRAY - (optional) List of addresses and storage keys the transaction plans to access
  2. Block Parameter - QUANTITY|TAG - integer block number, or the string “latest”, “earliest” or “pending”

Client Examples

Shell HTTP
curl -X POST --data '{
  "jsonrpc":"2.0",
  "method":"eth_createAccessList",
  "params":[{
    "from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",
    "to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",
    "data": "0x70a08231000000000000000000000000d3CdA913deB6f67967B99D67aCDFa1712C293601"
  }, "latest"],
  "id":1
}' -H "Content-Type: application/json" http://localhost:8545
Websocket
wscat -c ws://localhost:8546 -x '{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "eth_createAccessList",
  "params": [{
    "from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",
    "to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",
    "data": "0x70a08231000000000000000000000000d3CdA913deB6f67967B99D67aCDFa1712C293601"
  }, "latest"]
}'
Javascript (web3.js)
web3.eth.createAccessList({
  from: "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",
  to: "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",
  data: "0x70a08231000000000000000000000000d3CdA913deB6f67967B99D67aCDFa1712C293601"
}, "latest");

Result

Return Values

  • accessList: ARRAY - List of addresses and storage keys used by the transaction
    • address: DATA, 20 Bytes - Address accessed by the transaction
    • storageKeys: ARRAY - Array of storage keys accessed at this address
  • gasUsed: QUANTITY - Estimated gas consumed by the transaction with the access list