Docs
Docs
Home
Getting Started
Agent Tooling
CLI
Supported Chains
Acala
Aptos
Arbitrum
Arc
Asset Hub
Astar
Avalanche
Base
Berachain
Bifrost
Binance Smart Chain
Bittensor
Blast
Boba Network
Bridge Hub
Celo
Centrifuge
Chiliz
Cronos
Enjin
Ethereum
Etherlink
Flow EVM Gateway
Gnosis
Hydration
Hyperliquid
Immutable
Ink
IoTeX
Kusama
Linea
LISK
Manta Atlantic
Manta Pacific
Mantle
MegaETH
Monad
Movement
Neuroweb
opBNB
Optimism
Plasma
Polkadot
Polygon
Pulsechain
Robinhood
Ronin
Scroll
Sonic
Starknet
Taiko
Tempo
Sui
TRON
Unichain
Viction
World Chain
XDC Network
XX Network
Zetachain
zkSync Era
Zora
Supported ChainsMantleJSON-RPC APISmart Contract Methods

eth_call - Mantle RPC Method

Execute smart contract calls without creating transactions on Mantle. Essential for reading contract state for liquid staking (mETH $1.87B TVL), institutional DeFi via Bybit, and yield optimization strategies.

Mantle RPC endpoint: endpoint URLs, plans and pricing.

Executes a new message call immediately without creating a transaction on Mantle. Used for reading smart contract state.

Why Mantle? Build on the world's largest ZK rollup by TVL with $2.5B+ secured and deep Bybit integration with near-instant ZK finality via OP Succinct, $6.2B treasury backing, mETH liquid staking, and 25% Bybit trading fee discounts.

When to Use This Method

The eth_call method serves these key scenarios for DeFi developers, liquid staking builders, and teams seeking institutional exchange integration:

  • Read smart contract state - Execute view and pure functions to query token balances, DeFi positions, and protocol data without spending gas
  • Simulate transactions - Test contract interactions before submitting them on-chain, avoiding failed transactions and wasted gas costs
  • Multi-call aggregator queries - Batch multiple read calls into a single request using multicall contracts, reducing API overhead on Mantle
  • MEV and arbitrage analysis - Simulate transaction bundles to evaluate profitable opportunities before execution on liquid staking (mETH $1.87B TVL), institutional DeFi via Bybit, and yield optimization strategies

Common Use Cases

1. Read ERC20 Token Balance

Query an ERC20 token contract to retrieve the balance for a specific wallet address using the balanceOf(address) function selector encoded as calldata. The selector is derived from the first 4 bytes of keccak256("balanceOf(address)"), followed by the 32-byte zero-padded address argument.

JavaScript
import { JsonRpcProvider } from 'ethers';

const provider = new JsonRpcProvider('https://api-mantle-mainnet.n.dwellir.com/YOUR_API_KEY');
const tokenAddress = '0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8';
const walletAddress = '0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8';

const balanceSelector = '0x70a08231' + walletAddress.slice(2).padStart(64, '0');

async function getTokenBalance() {
  const result = await provider.call({
    to: tokenAddress,
    data: balanceSelector
  });
  console.log('Balance (raw):', BigInt(result).toString());
  return result;
}

getTokenBalance();

2. Query DeFi Protocol State

Read protocol reserves, price oracles, or user positions from DeFi contracts on Mantle. Each protocol exposes view functions that let you inspect pool state without modifying it - ideal for building analytics dashboards and trading bots.

JavaScript
import { JsonRpcProvider, Interface } from 'ethers';

const provider = new JsonRpcProvider('https://api-mantle-mainnet.n.dwellir.com/YOUR_API_KEY');

const poolAbi = [
  'function getReserves() view returns (uint112 reserve0, uint112 reserve1, uint32 blockTimestamp)'
];
const poolInterface = new Interface(poolAbi);
const poolAddress = '0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8';

async function getPoolReserves() {
  const data = poolInterface.encodeFunctionData('getReserves');
  const result = await provider.call({ to: poolAddress, data });
  const decoded = poolInterface.decodeFunctionResult('getReserves', result);
  console.log('Reserve 0:', decoded[0].toString());
  console.log('Reserve 1:', decoded[1].toString());
  return decoded;
}

getPoolReserves();

3. Simulate a Swap Before Execution

Before committing a token swap, call the router contract's quote function to calculate the expected output. This lets you validate slippage tolerance and compare rates across DEXes without risking gas on a failed trade.

JavaScript
import { JsonRpcProvider, Interface, parseEther } from 'ethers';

const provider = new JsonRpcProvider('https://api-mantle-mainnet.n.dwellir.com/YOUR_API_KEY');
const routerAddress = '0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8';

const routerAbi = [
  'function getAmountsOut(uint amountIn, address[] calldata path) view returns (uint[] amounts)'
];
const routerInterface = new Interface(routerAbi);

async function simulateSwap(amountIn, tokenIn, tokenOut) {
  const data = routerInterface.encodeFunctionData('getAmountsOut', [
    parseEther(amountIn),
    [tokenIn, tokenOut]
  ]);
  const result = await provider.call({ to: routerAddress, data });
  const decoded = routerInterface.decodeFunctionResult('getAmountsOut', result);
  console.log('Expected output:', decoded[0][1].toString());
  return decoded[0][1];
}

simulateSwap('1.0', '0xTokenA...', '0xTokenB...');

Best Practices

  • Use latest for current-state reads and pending for pre-confirmation simulation on Mantle
  • Encode function selectors correctly: take the first 4 bytes of the keccak256 hash of the function signature
  • Handle revert errors gracefully by parsing the revert reason from the error response data
  • For batch reads, use multicall contracts to combine multiple eth_call requests into a single RPC call
  • eth_call does not consume gas, making it ideal for unlimited read queries on Mantle
JSON-RPC request
{
  "jsonrpc": "2.0",
  "method": "eth_call",
  "params": [
    {
      "to": "0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8",
      "data": "0x70a0823100000000000000000000000078c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8"
    },
    "latest"
  ],
  "id": 1
}

Code Examples

Error Handling

Error CodeMessageDescription
-32000Execution revertedContract function reverted
-32602Invalid parametersInvalid data encoding
-32015VM execution errorContract logic error

Related Methods

  • eth_estimateGas - Estimate gas for transaction
  • eth_sendRawTransaction - Send actual transaction

eth_sendTransaction

Send a transaction from an unlocked account on Mantle. Requires the node to hold the sender's private key - intended for development and testing only.

eth_getLogs

Query event logs on Mantle. Essential for indexing liquid staking (mETH $1.87B TVL), institutional DeFi via Bybit, and yield optimization strategies on the world's largest ZK rollup by TVL with $2.5B+ secured and deep Bybit integration.

On this page

When to Use This MethodCommon Use Cases1. Read ERC20 Token Balance2. Query DeFi Protocol State3. Simulate a Swap Before ExecutionBest PracticesCode ExamplesError HandlingRelated Methods