TheRPCを始める
APIリファレンス
イーサリアムAPI
Core API
ガイド

eth_call

The eth_call method executes a new message call immediately without creating a transaction on the blockchain. This method is perfect for reading data from smart contracts without spending gas or modifying the blockchain state, making it one of the most frequently used methods for DApp development.

Use Cases

  • Reading token balances from ERC20 contracts
  • Querying contract state variables and mappings
  • Checking transaction validity before submission
  • Debugging smart contract functions
  • Testing contract behavior with different inputs
  • Simulating complex transaction outcomes
  • Fetching price data from DEX contracts
  • Verifying access rights before attempting state changes

Method Details

This method allows interaction with deployed smart contracts in a read-only manner with optional state overrides. The state overrides feature is particularly useful for testing "what-if" scenarios.

パラメータ:

The transaction call object which contains the following fields:

The address from which the transaction is sent

The address to which the transaction is addressed

The integer of gas provided for the transaction execution

The integer of gasPrice used for each paid gas encoded as hexadecimal

The integer of value sent with this transaction encoded as hexadecimal

The hash of the method signature and encoded parameters. For more information, see the Contract ABI description in the Solidity documentation

The block number in hexadecimal format or one of the string tags: latest, earliest, pending, safe or finalized (safe and finalized tags are only supported on Ethereum, Gnosis, Arbitrum, Arbitrum Nova and Avalanche C-chain)

The State Override Set option allows you to change the state of a contract before executing the call

The fake balance to set for the account before executing the call

The fake nonce to set for the account before executing the call

The fake EVM bytecode to inject into the account before executing the call

The fake key-value mapping to override all slots in the account storage before executing the call

The fake key-value mapping to override individual slots in the account storage before executing the call

返り値:

The return value of the executed contract method

Response Example

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

Common ERC20 Function Calls

One of the most common uses of eth_call is to check ERC20 token balances. The data field typically contains the function signature followed by the parameters:

  • balanceOf(address): 0x70a08231 + padded address
  • decimals(): 0x313ce567
  • symbol(): 0x95d89b41
  • totalSupply(): 0x18160ddd

The response will need to be decoded according to the expected return type.

See also

より良くするためにご協力ください!
このページを共有して、より良い製品を作るのに協力してください。