eth_call - BSC

Example code for the eth_call JSON RPC method. Сomplete guide on how to use eth_call JSON RPC in GetBlock Web3 documentation.

This method executes a new message call immediately without creating a transaction on the blockchain. This is commonly used for reading data from smart contracts, simulating transactions, and querying contract state on the BNB Smart Chain without spending gas.

Parameters

Parameter
Type
Required
Description

transaction

object

Yes

Transaction call object

blockNumber

string

Yes

Block number in hex, or "latest", "earliest", "pending"

Transaction Object

Field
Type
Required
Description

from

string

No

Sender address

to

string

Yes

Contract address

gas

string

No

Gas limit

gasPrice

string

No

Gas price

value

string

No

Value to send

data

string

No

Encoded function call

Request Example

curl --location --request POST 'https://go.getblock.io/<ACCESS-TOKEN>/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "jsonrpc": "2.0",
    "method": "eth_call",
    "params": [{
        "to": "0x55d398326f99059fF775485246999027B3197955",
        "data": "0x70a08231000000000000000000000000742d35cc6634c0532925a3b844bc9e7595f8bb45"
    }, "latest"],
    "id": "getblock.io"
}'

Response Example

Response Parameters

Parameter
Type
Description

jsonrpc

string

JSON-RPC version (2.0)

id

string

Request identifier

result

string

Hex-encoded return data from the call

Use Cases

  • Read BEP-20 token balances

  • Query PancakeSwap pool reserves

  • Simulate transactions before sending

  • Get NFT metadata

  • Check allowances and approvals

Error Handling

Error Code
Description

-32602

Invalid params - malformed call object

-32603

Internal error - execution reverted

-32000

Execution error - contract revert

SDK Integration

Last updated

Was this helpful?