# Ethereum eth_call RPC method
Ethereum API method that executes a new message call immediately without creating a transaction on the blockchain.
Parameters:
object
— the transaction call object with:from
— (optional) the string of the address, the transaction is sent from.to
— the string of the address, the transaction is directed to.gas
— (optional) the integer of the gas provided for the transaction execution.gasPrice
— (optional) the integer of the gas price used for each paid gas, encoded as hexadecimal.value
— (optional) the integer of the value sent with this transaction, encoded as hexadecimal.data
— (optional) the string of the hash of the method signature and encoded parameters, see the Ethereum Contract ABI (opens new window).quantity or tag
— the integer block number, or the string with:latest
— the latest block that is to be validated. The Beacon Chain may reorg and the latest block can become orphaned.safe
— the block that is equal to the tip of the chain and is very unlikely to be orphaned.finalized
— the block that is accepted by the two thirds of the Ethereum validators.earliest
— the genesis block.pending
— the pending state and transactions block.
Returns:
data
- the return value of the executed contract.
Example:
The examples below call the balanceOf
function of the Chainlink token (opens new window) for the Chainlink VRF coordinator (opens new window) address at the latest block.
Information
cURL needs a HEX String
starting with 0x
to identify the block if you want to use a hex integer block number as a parameter.
For example, block number 14000000
will be 0xD59F80
.
- web3.js
- web3.py
- eth.rb
- cURL
const Web3 = require("web3");
const web3 = new Web3(new Web3.providers.HttpProvider("CHAINSTACK_NODE_URL"));
web3.eth.defaultBlock = "latest";
web3.eth.call({
to: "0x514910771AF9Ca656af840dff83E8264EcF986CA",
data: "0x70a08231000000000000000000000000271682deb8c4e0901d1a1550ad2e64d568e69909"
})
.then(result => {
console.log(web3.utils.fromWei(result));
});