POST
/
35848e183f3e3303c8cfeacbea831cab
curl --request POST \
  --url https://bsc-mainnet.core.chainstack.com/35848e183f3e3303c8cfeacbea831cab \
  --header 'Content-Type: application/json' \
  --data '{
  "jsonrpc": "2.0",
  "method": "eth_call",
  "id": 1,
  "params": [
    {
      "to": "0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82",
      "data": "0x893d20e8"
    },
    "latest"
  ]
}'
{
  "jsonrpc": "<string>",
  "id": 123,
  "result": "<string>"
}

BNB API method that enables instant execution of a new message call without requiring the creation of a transaction on the blockchain. This can be useful for testing and debugging by simulating transfers or smart contract transactions and retrieving data from the blockchain.

Get you own node endpoint today

Start for free and get your app to production levels immediately. No credit card required.

You can sign up with your GitHub, X, Google, or Microsoft account.

Disclaimer

The interactive example in this page uses eth_call to call the getOwner() method from the Cake Token smart contract on BNB Chain. It returns the address of the owner of the smart contract, in this case, 0x73feaa1ee314f8c655e354234017be2193c9e24e

Parameters

  • object — the transaction call object:
    • from — (optional) the address string used to send the transaction.
    • to — the string of the address to which the transaction is directed, a wallet, or a smart contract.
    • gas — (optional) the maximum amount of gas that can be used by the transaction.
    • gasprice — (optional) the amount of gas price the sender is willing to pay for each gas unit in Wei.
    • value — (optional) the value sent with this transaction, encoded as hexadecimal.
    • data — (optional) additional data to be sent with the call, usually used to invoke functions from smart contracts as a string of the hash of the method signature and encoded parameters. See the Ethereum Contract ABI.
  • quantity or tag — the integer of a block encoded as hexadecimal or the string with:
  • latest — the most recent block in the blockchain and the current state of the blockchain at the most recent block. A chain reorganization is to be expected.
  • safe—the block that received justification from the beacon chain. Although this block could be involved in a chain reorganization, it would necessitate either a coordinated attack by the majority of validators or severe propagation latency.
  • finalized—the block accepted as canonical by more than 2/3 of the validators. A chain reorganization is extremely unlikely, requiring burning at least 1/3 of the staked amount.
  • earliest — the earliest available or genesis block.
  • pending—the pending state and transactions block. This is the current state of transactions that have been broadcast to the network but have not yet been included in a block.

Response

  • data — the result of executing the specified call on the Ethereum Virtual Machine (EVM), encoded as a hexadecimal string.

eth_call code examples

The following code snippets clearly demonstrate how to simulate a standard ether transfer between two accounts. Note that when using eth_call to simulate a transfer or a smart contract transaction, the sender account must have a sufficient balance to cover the associated gas fee.

const { Web3 } = require('web3');

const NODE_URL = "CHAINSTACK_NODE_URL";

const web3 = new Web3(NODE_URL);



async function simulateTransfer() {

    try {

        // Define the accounts to transfer between

        const fromAddress = "0x95222290DD7278Aa3Ddd389Cc1E1d165CC4BAfe5";

        const toAddress = "0x19e7e376e7c213b7e7e7e46cc70a5dd086daff2a";



        // Define the value to transfer (converted to Wei)

        const value = web3.utils.toWei("100", "ether");



        // Build transaction object

        const transactionObject = {

            from: fromAddress,

            to: toAddress,

            gas: 21000, // 21000 is the standard for a regular tranfer

            value: value,

            data: ""

        }



        // Use eth_call to simulate the transfer on the latest block

        const result = await web3.eth.call({

            transactionObject

        }, "latest");



        console.log(`Transaction hash: ${result}`);

    } catch (error) {

        console.error(`Error: ${error.message}`);

    }

}



simulateTransfer();

Executing this code will produce a return value of 0x, indicating a successful transaction. This implies that the transaction will be executed without errors when the code is used to send the transaction.

Use case

A common use case for eth_call is calling smart contract functions. For example, interact with an ERC-20 token smart contract deployed on the BNB network and retrieve the balance of a specific account.

Body

application/json
jsonrpc
string
default:2.0
method
string
default:eth_call
id
integer
default:1
params
object[]

Response

200 - application/json
The result of the call.
jsonrpc
string
id
integer
result
string