Skip to content

The eth_ methods (Eth)

The eth_ namespace: what an execution client serves. Each export is one JSON-RPC method as a typed function, and the eth_subscribe kinds are under Eth.subscribe.

import { Effect } from "effect";
import { Eth } from "@ethect/core/rpc";
const head = Effect.gen(function* () {
const number = yield* Eth.blockNumber();
const block = yield* Eth.getBlockByNumber(number, false);
return block?.hash;
});

A method takes its JSON-RPC params in order and returns an Effect of the decoded result. The name is the wire name without its prefix: eth_getBalance is Eth.getBalance.

Method JSON-RPC Returns Description
chainId eth_chainId number The chain id of the network.
blockNumber eth_blockNumber bigint The number of the most recent block.
syncing eth_syncing false or progress Whether the node is syncing, and how far it is.
accounts eth_accounts Address[] The accounts the node or wallet holds keys for.
coinbase eth_coinbase Address The address that receives the node’s block rewards.
protocolVersion eth_protocolVersion number The version of the eth wire protocol.
config eth_config ChainConfig The fork configuration: current, next and last.
capabilities eth_capabilities Capabilities What history the node keeps.
Method JSON-RPC Returns Description
getBlockByNumber eth_getBlockByNumber Block | null A block by number or tag.
getBlockByHash eth_getBlockByHash Block | null A block by hash.
getBlockReceipts eth_getBlockReceipts Receipt[] | null The receipts of every transaction in a block.
getHeaderByNumber eth_getHeaderByNumber Header | null A block header by number or tag.
getHeaderByHash eth_getHeaderByHash Header | null A block header by hash.
getBlockTransactionCountByNumber eth_getBlockTransactionCountByNumber number | null How many transactions a block has, by number or tag.
getBlockTransactionCountByHash eth_getBlockTransactionCountByHash number | null How many transactions a block has, by hash.
getUncleCountByBlockNumber eth_getUncleCountByBlockNumber number | null How many uncles a block has, by number or tag.
getUncleCountByBlockHash eth_getUncleCountByBlockHash number | null How many uncles a block has, by hash.
getUncleByBlockNumberAndIndex eth_getUncleByBlockNumberAndIndex Block | null An uncle of a block, by block number or tag and position.
getUncleByBlockHashAndIndex eth_getUncleByBlockHashAndIndex Block | null An uncle of a block, by block hash and position.
getBlockAccessList eth_getBlockAccessList BlockAccessList | null What a block read and wrote, per account.
Method JSON-RPC Returns Description
getTransactionByHash eth_getTransactionByHash Transaction | null A transaction by hash, pending or mined.
getTransactionReceipt eth_getTransactionReceipt Receipt | null The receipt of a mined transaction.
getTransactionByBlockNumberAndIndex eth_getTransactionByBlockNumberAndIndex Transaction | null A transaction by its position in a block, by number or tag.
getTransactionByBlockHashAndIndex eth_getTransactionByBlockHashAndIndex Transaction | null A transaction by its position in a block, by block hash.
getTransactionBySenderAndNonce eth_getTransactionBySenderAndNonce Transaction | null The transaction an account sent with a given nonce.
getRawTransactionByHash eth_getRawTransactionByHash Hex | null A transaction in its signed, encoded form, by hash.
getRawTransactionByBlockNumberAndIndex eth_getRawTransactionByBlockNumberAndIndex Hex | null The same, by position in a block, by number or tag.
getRawTransactionByBlockHashAndIndex eth_getRawTransactionByBlockHashAndIndex Hex | null The same, by position in a block, by block hash.
pendingTransactions eth_pendingTransactions Transaction[] The transactions in the node’s pending pool.
Method JSON-RPC Returns Description
getBalance eth_getBalance bigint The balance of an account, in wei.
getTransactionCount eth_getTransactionCount number The number of transactions an account has sent: its next nonce.
getCode eth_getCode Hex The code of a contract.
getStorageAt eth_getStorageAt Hex The value of one storage slot of a contract.
getStorageValues eth_getStorageValues Record<Address, Hex[]> The values of several slots of several contracts.
getProof eth_getProof Proof The Merkle proof of an account and of storage slots.
getAccount eth_getAccount Account | null An account’s nonce, balance, storage root and code hash.
Method JSON-RPC Returns Description
call eth_call Hex Runs a call without sending a transaction.
estimateGas eth_estimateGas bigint The gas a transaction would need.
createAccessList eth_createAccessList AccessList.Result The access list a transaction would use.
simulateV1 eth_simulateV1 simulated blocks Simulates calls in a sequence of blocks.
Method JSON-RPC Returns Description
feeHistory eth_feeHistory FeeHistory Base fees, gas usage and priority fees over a range of blocks.
gasPrice eth_gasPrice bigint The node’s suggestion for a legacy gas price.
maxPriorityFeePerGas eth_maxPriorityFeePerGas bigint The node’s suggestion for a priority fee.
baseFee eth_baseFee bigint The base fee of the next block.
blobBaseFee eth_blobBaseFee bigint | null The blob base fee of the next block.
Method JSON-RPC Returns Description
getLogs eth_getLogs Log[] The logs matching a filter.
newFilter eth_newFilter Hex Installs a log filter on the node.
newBlockFilter eth_newBlockFilter Hex Installs a filter that collects new block hashes.
newPendingTransactionFilter eth_newPendingTransactionFilter Hex Installs a filter that collects pending transaction hashes.
getFilterChanges eth_getFilterChanges Hash[] or Log[] What a filter collected since it was last polled.
getFilterLogs eth_getFilterLogs Log[] Every log matching a log filter.
uninstallFilter eth_uninstallFilter boolean Removes a filter.
Method JSON-RPC Returns Description
sendTransaction eth_sendTransaction Hash Signs and sends a transaction from an account the node or wallet holds.
sendTransactionSync eth_sendTransactionSync Receipt The same, and waits for the receipt.
sendRawTransaction eth_sendRawTransaction Hash Sends a signed, encoded transaction.
sendRawTransactionSync eth_sendRawTransactionSync Receipt The same, and waits for the receipt.
fillTransaction eth_fillTransaction { raw, tx } Fills in what a request leaves out, without sending it.
signTransaction eth_signTransaction Hex Signs a transaction without sending it.
sign eth_sign Hex Signs a message with an account’s key.
signTypedDataV4 eth_signTypedData_v4 Hex Signs EIP-712 typed data.

A subscription is a Stream, and it needs a transport that can push: WebSocket, IPC or EIP-1193. See Subscriptions.

Kind eth_subscribe param Item Description
subscribe.newHeads newHeads Block.Header The header of each block added to the chain.
subscribe.logs logs Log The logs matching a filter, as blocks are added.
subscribe.newPendingTransactions newPendingTransactions Hash or Transaction The transactions entering the pending pool.
subscribe.transactionReceipts transactionReceipts ReadonlyArray<Receipt> The receipts of each block added to the chain.
subscribe.syncing syncing sync status The sync status, each time it changes.

These eth_ methods have no definition in the namespace. Any of them is one line to add.

Methods Why
eth_subscribe, eth_unsubscribe covered by Eth.subscribe and the Subscriptions service
eth_mining, eth_hashrate, eth_getWork, eth_submitWork, eth_submitHashrate proof-of-work leftovers
eth_callMany, eth_callBundle, eth_resend, eth_getAccountInfo, eth_signRawTransaction, eth_sendRawTransactionConditional, eth_signTypedData v1 and v3 client-specific or superseded