Skip to main content
Tempo API method that executes a new message call immediately without creating a transaction on the blockchain. This is commonly used to read data from smart contracts, such as TIP-20 token balances.

Parameters

  • callObject — the call object:
    • from — (optional) address the call is sent from
    • to — the address the call is directed to
    • gas — (optional) gas provided for the call
    • gasPrice — (optional) gas price for the call
    • value — (optional) value sent with the call
    • data — (optional) hash of the method signature and encoded parameters
  • blockParameter — the block number (hex) or tag (latest, earliest, pending)

Response

  • result — the return value of the executed contract call

eth_call code examples

The following example queries the balanceOf function on the pathUSD TIP-20 token contract:
const ethers = require('ethers');
const NODE_URL = "CHAINSTACK_NODE_URL";
const provider = new ethers.JsonRpcProvider(NODE_URL);

// pathUSD token address
const PATHUSD = "0x20c0000000000000000000000000000000000000";

const getBalance = async (address) => {
    const abi = ["function balanceOf(address) view returns (uint256)"];
    const token = new ethers.Contract(PATHUSD, abi, provider);
    const balance = await token.balanceOf(address);
    // TIP-20 tokens use 6 decimals
    console.log(`pathUSD balance: ${ethers.formatUnits(balance, 6)}`);
  };

getBalance("0x9729187D9E8Bbefa8295F39f5634cA454dd9d294");