⚠️Blast API (blastapi.io) ends Oct 31. Migrate to Dwellir and skip Alchemy's expensive compute units.
Switch Today →
Skip to main content

eth_estimateGas

Overview

Estimates the gas required to execute a transaction.

Movement-Specific Considerations

  • Parallel execution doesn’t change estimation behavior.
  • Provide realistic from, to, data, and value for accurate estimates.

Parameters

NameTypeRequiredDescription
txobjectYesTx template including from,to,data,value
blockTagstringNoOptional block context, default latest

Returns

Hex string gas estimate, e.g., 0x5208 (21000).

Code Examples

cURL

curl -X POST https://api-movement-mainnet.n.dwellir.com/YOUR_API_KEY/v1 \
-H "Content-Type: application/json" \
-d '{
"jsonrpc":"2.0",
"method":"eth_estimateGas",
"params":[{"from":"0x0000000000000000000000000000000000000000","to":"0x0000000000000000000000000000000000000000","value":"0x0"}],
"id":1
}'

Ethers.js v6

import { JsonRpcProvider } from 'ethers';
const provider = new JsonRpcProvider('https://api-movement-mainnet.n.dwellir.com/YOUR_API_KEY/v1');
const gas = await provider.send('eth_estimateGas', [{
from: '0x0000000000000000000000000000000000000000',
to: '0x0000000000000000000000000000000000000000',
value: '0x0'
}]);
console.log(gas);

Web3.js

import Web3 from 'web3';
const web3 = new Web3('https://api-movement-mainnet.n.dwellir.com/YOUR_API_KEY/v1');
const gas = await web3.eth.estimateGas({ from: '0x0000000000000000000000000000000000000000', to: '0x0000000000000000000000000000000000000000', value: '0x0' });
console.log(gas);

viem

import { createPublicClient, http } from 'viem';

const movement = {
id: 3073,
name: 'Movement',
nativeCurrency: { name: 'MOVE', symbol: 'MOVE', decimals: 18 },
rpcUrls: { default: { http: ['https://api-movement-mainnet.n.dwellir.com/YOUR_API_KEY/v1'] } },
} as const;

const client = createPublicClient({
chain: movement,
transport: http('https://api-movement-mainnet.n.dwellir.com/YOUR_API_KEY/v1'),
});

const gasViem = await client.estimateGas({
to: '0x0000000000000000000000000000000000000000',
value: 0n,
});
console.log(gasViem);

Move Equivalent

Use Move transaction simulation: POST /v1/transactions/simulate.

Common Errors

  • execution reverted: adjust input or handle revert.
  • insufficient funds: ensure sender has enough balance for intrinsic gas.