call - SDK
Returns the result of executing the transaction, using call . A call does not require any ether, but cannot change any state. This is useful for calling getters on Contracts.
Returns the result of executing the transaction, using call
. A call does not require any ether, but cannot change any state. This is useful for calling getters on Contracts.
Don’t have an API key?
Start using this method in your app today. Get started for free
Description
Returns the result of executing the transaction, using call
. A call does not require any ether, but cannot change any state. This is useful for calling getters on Contracts.
Starting from Geth 1.9.13,
eth_call
will check the balance of the sender (to make sure that the sender has enough gas to complete the request) before executing the call when one of the following conditions is true:
- the
gas_price
parameter is populated, or- the contract function being called (i.e. in data modifies blockchain state)
In these two cases, even though the
eth_call
requests don’t consume any gas, the from address must have enough gas to execute the call as if it were a write transaction becauseeth_call
is being used to simulate the transaction.
eth_call
has a timeout restriction at the node level. Batching multiple eth_call
together on-chain using pre-deployed smart contracts might result in unexpected timeouts that cause none of your calls to complete. Instead, consider serializing these calls, or using smaller batches if they fail with a node error code.
Parameters
transaction
object parameters
Response
blocktag
parameters
pending
- A sample next block built by the client on top of the latest and containing the set of transactions usually taken from the local mempool. Intuitively, you can think of these as blocks that have not been mined yet.latest
- The most recent block in the canonical chain observed by the client, this block may be re-orged out of the canonical chain even under healthy/normal conditions.safe
- The most recent crypto-economically secure block, cannot be re-orged outside of manual intervention driven by community coordination. Intuitively, this block is “unlikely” to be re-orged. Only available on Ethereum Goerli.finalized
- The most recent crypto-economically secure block, that has been accepted by >2/3 of validators. Cannot be re-orged outside of manual intervention driven by community coordination. Intuitively, this block is very unlikely to be re-orged. Only available on Ethereum Goerli.earliest
- The lowest numbered block the client has available. Intuitively, you can think of this as the first block created.
Example Request and Response
Prerequisite: You will need to install the Alchemy SDK before making requests with it.
The commands for installing it using npm or yarn are given below:
Request
Response
Use Cases
The call
method is used for making low-level calls to the EVM blockchains. It can be used for a variety of use cases, including:
-
Reading data from smart contracts: Developers can use the
call
method to read data from a smart contract on the EVM blockchain. -
Querying blockchain data: Developers can use the
call
method to query blockchain data, such as account balances, transaction history, and block data.
Overall, the call
method is a versatile SDK method that can be used for a wide range of tasks related to interacting with the EVM blockchain.