Please note that for this RPC method, if the block number is set to pending, Polygon zkEVM assumes it as the latest.
Parameters
- transactionobject
The transaction call object:
- fromstring
The address from which the transaction is sent
- tostringREQUIRED
The address to which the transaction is addressed
- gasinteger
The integer of gas provided for the transaction execution
- gasPriceinteger
The integer of gasPrice used for each paid gas encoded as hexadecimal
- valueinteger
The integer of value sent with this transaction encoded as hexadecimal
- datastring
The hash of the method signature and encoded parameters. For more information, see the Contract ABI description in the Solidity documentation.
- blockNumberstring
The block number in hexadecimal format or the string latest, earliest, pending, safe or finalized
Returns
- resultstring
The estimated amount of gas used
Request
1curl https://docs-demo.soneium-mainnet.quiknode.pro/ \2-X POST \3-H "Content-Type: application/json" \4--data '{"method":"eth_estimateGas","params":[{"from":"0x8D97689C9818892B700e27F316cc3E41e17fBeb9","to":"0xd3CdA913deB6f67967B99D67aCDFa1712C293601"}],"id":1,"jsonrpc":"2.0"}'
1curl https://docs-demo.soneium-mainnet.quiknode.pro/ \2-X POST \3-H "Content-Type: application/json" \4--data '{"method":"eth_estimateGas","params":[{"from":"0x8D97689C9818892B700e27F316cc3E41e17fBeb9","to":"0xd3CdA913deB6f67967B99D67aCDFa1712C293601"}],"id":1,"jsonrpc":"2.0"}'
1import { Core } from '@quicknode/sdk'23const core = new Core({4endpointUrl: "https://docs-demo.soneium-mainnet.quiknode.pro/",5})67core.client8.estimateGas({9account,10to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',11value: parseEther('1')12})13.then(res => console.log(res))14
1import { Core } from '@quicknode/sdk'23const core = new Core({4endpointUrl: "https://docs-demo.soneium-mainnet.quiknode.pro/",5})67core.client8.estimateGas({9account,10to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',11value: parseEther('1')12})13.then(res => console.log(res))14
1require 'eth'23client = Eth::Client.create 'https://docs-demo.soneium-mainnet.quiknode.pro/'4payload = {5"jsonrpc": "2.0",6"method": "eth_estimateGas",7"params": [{"from":"0x8D97689C9818892B700e27F316cc3E41e17fBeb9","to":"0xd3CdA913deB6f67967B99D67aCDFa1712C293601"}],8"id": "1"9}1011response = client.send(payload.to_json)12puts response
1require 'eth'23client = Eth::Client.create 'https://docs-demo.soneium-mainnet.quiknode.pro/'4payload = {5"jsonrpc": "2.0",6"method": "eth_estimateGas",7"params": [{"from":"0x8D97689C9818892B700e27F316cc3E41e17fBeb9","to":"0xd3CdA913deB6f67967B99D67aCDFa1712C293601"}],8"id": "1"9}1011response = client.send(payload.to_json)12puts response
1import { ethers } from "ethers";2(async () => {3const provider = new ethers.JsonRpcProvider("https://docs-demo.soneium-mainnet.quiknode.pro/");4const estimate = await provider.estimateGas({5"from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",6"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",7});8console.log(estimate);9})();10
1import { ethers } from "ethers";2(async () => {3const provider = new ethers.JsonRpcProvider("https://docs-demo.soneium-mainnet.quiknode.pro/");4const estimate = await provider.estimateGas({5"from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",6"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",7});8console.log(estimate);9})();10
1var myHeaders = new Headers();2myHeaders.append("Content-Type", "application/json");34var raw = JSON.stringify({5"method": "eth_estimateGas",6"params": [7{8"from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",9"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"10}11],12"id": 1,13"jsonrpc": "2.0"14});1516var requestOptions = {17method: 'POST',18headers: myHeaders,19body: raw,20redirect: 'follow'21};2223fetch("https://docs-demo.soneium-mainnet.quiknode.pro/", requestOptions)24.then(response => response.text())25.then(result => console.log(result))26.catch(error => console.log('error', error));
1var myHeaders = new Headers();2myHeaders.append("Content-Type", "application/json");34var raw = JSON.stringify({5"method": "eth_estimateGas",6"params": [7{8"from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",9"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"10}11],12"id": 1,13"jsonrpc": "2.0"14});1516var requestOptions = {17method: 'POST',18headers: myHeaders,19body: raw,20redirect: 'follow'21};2223fetch("https://docs-demo.soneium-mainnet.quiknode.pro/", requestOptions)24.then(response => response.text())25.then(result => console.log(result))26.catch(error => console.log('error', error));
1import requests2import json34url = "https://docs-demo.soneium-mainnet.quiknode.pro/"56payload = json.dumps({7"method": "eth_estimateGas",8"params": [9{10"from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",11"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"12}13],14"id": 1,15"jsonrpc": "2.0"16})17headers = {18'Content-Type': 'application/json'19}2021response = requests.request("POST", url, headers=headers, data=payload)2223print(response.text)24
1import requests2import json34url = "https://docs-demo.soneium-mainnet.quiknode.pro/"56payload = json.dumps({7"method": "eth_estimateGas",8"params": [9{10"from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",11"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"12}13],14"id": 1,15"jsonrpc": "2.0"16})17headers = {18'Content-Type': 'application/json'19}2021response = requests.request("POST", url, headers=headers, data=payload)2223print(response.text)24
1require "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.soneium-mainnet.quiknode.pro/")67https = Net::HTTP.new(url.host, url.port)8https.use_ssl = true910request = Net::HTTP::Post.new(url)11request["Content-Type"] = "application/json"12request.body = JSON.dump({13"method": "eth_estimateGas",14"params": [15{16"from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",17"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"18}19],20"id": 1,21"jsonrpc": "2.0"22})2324response = https.request(request)25puts response.read_body26
1require "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.soneium-mainnet.quiknode.pro/")67https = Net::HTTP.new(url.host, url.port)8https.use_ssl = true910request = Net::HTTP::Post.new(url)11request["Content-Type"] = "application/json"12request.body = JSON.dump({13"method": "eth_estimateGas",14"params": [15{16"from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",17"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"18}19],20"id": 1,21"jsonrpc": "2.0"22})2324response = https.request(request)25puts response.read_body26
1from web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.soneium-mainnet.quiknode.pro/'))3estimate = w3.eth.estimate_gas({"from":"0x8D97689C9818892B700e27F316cc3E41e17fBeb9","to":"0xd3CdA913deB6f67967B99D67aCDFa1712C293601"})4print(estimate)
1from web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.soneium-mainnet.quiknode.pro/'))3estimate = w3.eth.estimate_gas({"from":"0x8D97689C9818892B700e27F316cc3E41e17fBeb9","to":"0xd3CdA913deB6f67967B99D67aCDFa1712C293601"})4print(estimate)
Don't have an account yet?
Create your Quicknode endpoint in seconds and start building
Get started for free