Skip to main content

Read Methods

The read interface executes view and pure functions via eth_call. These calls don’t modify state and don’t require gas.
This uses the Contract pattern - a copyable implementation you add to your codebase.

Basic Usage

How It Works

When you call a read method:
  1. Encode - Arguments are ABI-encoded with the function selector
  2. Call - eth_call is sent to the provider
  3. Decode - Return data is ABI-decoded to JavaScript types

Return Values

Read methods return decoded values directly:

Block Parameter

By default, reads execute against the latest block. Override this with options:

Error Handling

Read calls can fail for several reasons:
Common failures:
  • Reverts - Contract reverted (e.g., require failed)
  • Invalid address - Contract doesn’t exist at address
  • Network errors - Provider connectivity issues

Calling From Address

Some contracts check msg.sender even in view functions. Specify a from address:

Batching Reads

For efficiency, batch multiple reads:
For many reads, consider using a multicall contract to batch them into a single RPC call.