Ethereum Methods

The eth_* namespace contains all core Ethereum protocol methods. OPN Chain implements every standard Ethereum JSON-RPC method, ensuring complete compatibility.

Table of Contents

Reading Blockchain Data

  • eth_blockNumber - Get latest block number

  • eth_getBalance - Get account balance

  • eth_getCode - Get contract code

  • eth_getStorageAt - Get storage value

  • eth_getBlockByHash - Get block by hash

  • eth_getBlockByNumber - Get block by number

  • eth_getTransactionByHash - Get transaction

  • eth_getTransactionReceipt - Get receipt

Sending Transactions

  • eth_sendRawTransaction - Send signed transaction

  • eth_call - Execute call without creating transaction

  • eth_estimateGas - Estimate gas needed

Network Information

  • eth_chainId - Get chain ID

  • eth_gasPrice - Get current gas price

  • eth_syncing - Get sync status

  • eth_mining - Check if mining

  • eth_hashrate - Get hashrate

Account Methods

  • eth_accounts - List accounts

  • eth_getTransactionCount - Get nonce

Filters and Logs

  • eth_newFilter - Create log filter

  • eth_newBlockFilter - Create block filter

  • eth_getFilterChanges - Get filter updates

  • eth_getLogs - Get historical logs


eth_blockNumber

Returns the number of the most recent block.

Parameters

None

Returns

QUANTITY - Integer of the current block number

Example

JavaScript:


eth_getBalance

Returns the balance of the account at given address.

Parameters

  1. DATA, 20 bytes - Address to check balance

  2. QUANTITY|TAG - Block number or "latest", "earliest", "pending"

Returns

QUANTITY - Balance in wei

Example


eth_getCode

Returns code at a given address.

Parameters

  1. DATA, 20 bytes - Address

  2. QUANTITY|TAG - Block number or tag

Returns

DATA - The code from the given address

Example


eth_getStorageAt

Returns the value from a storage position at a given address.

Parameters

  1. DATA, 20 bytes - Address

  2. QUANTITY - Storage position

  3. QUANTITY|TAG - Block number or tag

Returns

DATA - The value at this storage position

Example


eth_getBlockByHash

Returns information about a block by hash.

Parameters

  1. DATA, 32 bytes - Block hash

  2. Boolean - If true returns full transaction objects, if false only hashes

Returns

Object - Block object or null

Example


eth_getBlockByNumber

Returns information about a block by number.

Parameters

  1. QUANTITY|TAG - Block number or "latest", "earliest", "pending"

  2. Boolean - If true returns full transaction objects

Returns

Object - Block object or null

Example

Block Object Structure


eth_getTransactionByHash

Returns information about a transaction by hash.

Parameters

  1. DATA, 32 bytes - Transaction hash

Returns

Object - Transaction object or null

Example


eth_getTransactionReceipt

Returns the receipt of a transaction by transaction hash.

Parameters

  1. DATA, 32 bytes - Transaction hash

Returns

Object - Receipt object or null

Example

Receipt Object Structure


eth_sendRawTransaction

Submits a pre-signed transaction.

Parameters

  1. DATA - Signed transaction data

Returns

DATA, 32 bytes - Transaction hash

Example


eth_call

Executes a new message call without creating a transaction.

Parameters

  1. Object - Transaction call object

  2. QUANTITY|TAG - Block number or tag

Returns

DATA - Return value of executed contract

Example

Advanced Call Options


eth_estimateGas

Estimates gas needed for a transaction.

Parameters

  1. Object - Transaction object (same as eth_call)

  2. QUANTITY|TAG - Optional block number

Returns

QUANTITY - Estimated gas amount

Example


eth_chainId

Returns the chain ID.

Parameters

None

Returns

QUANTITY - Chain ID (984 for OPN testnet)

Example


eth_gasPrice

Returns the current gas price.

Parameters

None

Returns

QUANTITY - Gas price in wei

Example


eth_getTransactionCount

Returns the number of transactions sent from an address (nonce).

Parameters

  1. DATA, 20 bytes - Address

  2. QUANTITY|TAG - Block number or tag

Returns

QUANTITY - Transaction count

Example


eth_getLogs

Returns logs matching filter criteria.

Parameters

  1. Object - Filter object:

    • fromBlock: Starting block

    • toBlock: Ending block

    • address: Contract address or array

    • topics: Array of topics

Returns

Array - Array of log objects

Example


Error Handling

Common Errors

Handling Reverts

Performance Tips

Batch Requests

Caching Strategies


Last updated