Parameters
- objectobject
The transaction call object which contains the following fields:
- fromstring
The address from which the transaction is sent
- tostringREQUIRED
The address to which the transaction is addressed
- gasstring
The integer of gas provided for the transaction execution
- gasPricestring
The integer of gasPrice used for each paid gas encoded as hexadecimal
- valuestring
The integer of value sent with this transaction encoded as hexadecimal
- datastring
The hash of the method signature and encoded parameters
- blockNumber/tagstringREQUIRED
The block number in hexadecimal format or the string latest, earliest, pending, safe or finalized (safe and finalized tags are only supported on Ethereum, Gnosis, Arbitrum, Arbitrum Nova and Avalanche C-chain), see the default block parameter description in the official Ethereum documentation
Returns
- quantity
The expected execution gas cost of a transaction. This does not include any information about the cost to publish the transaction data to Layer 1
1curl -X POST "https://docs-demo.optimism.quiknode.pro/" \2-H "Content-Type: application/json" \3-d '{4"jsonrpc": "2.0",5"method": "eth_estimateExecutionGas",6"params": [7{8"to": "0x6b175474e89094c44da98b954eedeac495271d0f",9"gas": "0x7a120",10"gasPrice": "0x0",11"value": "0x0",12"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"13},14"latest"15],16"id": 117}'
1curl -X POST "https://docs-demo.optimism.quiknode.pro/" \2-H "Content-Type: application/json" \3-d '{4"jsonrpc": "2.0",5"method": "eth_estimateExecutionGas",6"params": [7{8"to": "0x6b175474e89094c44da98b954eedeac495271d0f",9"gas": "0x7a120",10"gasPrice": "0x0",11"value": "0x0",12"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"13},14"latest"15],16"id": 117}'
1import { ethers } from "ethers";23async function main() {4const provider = new ethers.JsonRpcProvider("https://docs-demo.optimism.quiknode.pro/");5const response = await provider.send("eth_estimateExecutionGas", [6{7"to": "0x6b175474e89094c44da98b954eedeac495271d0f",8"gas": "0x7a120",9"gasPrice": "0x0",10"value": "0x0",11"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"12},13"latest"14]);15console.log(response);16}1718main();
1import { ethers } from "ethers";23async function main() {4const provider = new ethers.JsonRpcProvider("https://docs-demo.optimism.quiknode.pro/");5const response = await provider.send("eth_estimateExecutionGas", [6{7"to": "0x6b175474e89094c44da98b954eedeac495271d0f",8"gas": "0x7a120",9"gasPrice": "0x0",10"value": "0x0",11"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"12},13"latest"14]);15console.log(response);16}1718main();
1import json2from web3 import Web3, HTTPProvider3w3 = Web3(HTTPProvider('https://docs-demo.optimism.quiknode.pro/'))4response = w3.provider.make_request("eth_estimateExecutionGas", [{"to":"0x6b175474e89094c44da98b954eedeac495271d0f","gas":"0x7a120","gasPrice":"0x0","value":"0x0","data":"0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"},"latest"])5print(response)
1import json2from web3 import Web3, HTTPProvider3w3 = Web3(HTTPProvider('https://docs-demo.optimism.quiknode.pro/'))4response = w3.provider.make_request("eth_estimateExecutionGas", [{"to":"0x6b175474e89094c44da98b954eedeac495271d0f","gas":"0x7a120","gasPrice":"0x0","value":"0x0","data":"0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"},"latest"])5print(response)
1import { createPublicClient, http } from 'viem'23async function main() {4const client = createPublicClient({5transport: http('https://docs-demo.optimism.quiknode.pro/')6})78const result = await client.request({9method: 'eth_estimateExecutionGas',10params: [11{12"to": "0x6b175474e89094c44da98b954eedeac495271d0f",13"gas": "0x7a120",14"gasPrice": "0x0",15"value": "0x0",16"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"17},18"latest"19]20})2122console.log(result)23}2425main()
1import { createPublicClient, http } from 'viem'23async function main() {4const client = createPublicClient({5transport: http('https://docs-demo.optimism.quiknode.pro/')6})78const result = await client.request({9method: 'eth_estimateExecutionGas',10params: [11{12"to": "0x6b175474e89094c44da98b954eedeac495271d0f",13"gas": "0x7a120",14"gasPrice": "0x0",15"value": "0x0",16"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"17},18"latest"19]20})2122console.log(result)23}2425main()
1import { QuicknodeSdk } from '@quicknode/sdk'23const qn = new QuicknodeSdk({})45const result = await qn.rpc.call(6'eth_estimateExecutionGas',7[8{9"to": "0x6b175474e89094c44da98b954eedeac495271d0f",10"gas": "0x7a120",11"gasPrice": "0x0",12"value": "0x0",13"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"14},15"latest"16],17undefined,18'https://docs-demo.optimism.quiknode.pro/'19)2021console.log(result)
1import { QuicknodeSdk } from '@quicknode/sdk'23const qn = new QuicknodeSdk({})45const result = await qn.rpc.call(6'eth_estimateExecutionGas',7[8{9"to": "0x6b175474e89094c44da98b954eedeac495271d0f",10"gas": "0x7a120",11"gasPrice": "0x0",12"value": "0x0",13"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"14},15"latest"16],17undefined,18'https://docs-demo.optimism.quiknode.pro/'19)2021console.log(result)
1import asyncio2from quicknode_sdk import QuicknodeSdk, SdkFullConfig34async def main():5qn = QuicknodeSdk(SdkFullConfig(api_key=None))6result = await qn.rpc.call(7"eth_estimateExecutionGas",8[9{10"to": "0x6b175474e89094c44da98b954eedeac495271d0f",11"gas": "0x7a120",12"gasPrice": "0x0",13"value": "0x0",14"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"15},16"latest"17],18endpoint_url="https://docs-demo.optimism.quiknode.pro/",19)20print(result)2122asyncio.run(main())
1import asyncio2from quicknode_sdk import QuicknodeSdk, SdkFullConfig34async def main():5qn = QuicknodeSdk(SdkFullConfig(api_key=None))6result = await qn.rpc.call(7"eth_estimateExecutionGas",8[9{10"to": "0x6b175474e89094c44da98b954eedeac495271d0f",11"gas": "0x7a120",12"gasPrice": "0x0",13"value": "0x0",14"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"15},16"latest"17],18endpoint_url="https://docs-demo.optimism.quiknode.pro/",19)20print(result)2122asyncio.run(main())
1require "quicknode_sdk"23qn = QuicknodeSdk::SDK.from_config(api_key: nil)45result = qn.rpc.call(6method: "eth_estimateExecutionGas",7params: [8{9"to" => "0x6b175474e89094c44da98b954eedeac495271d0f",10"gas" => "0x7a120",11"gasPrice" => "0x0",12"value" => "0x0",13"data" => "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"14},15"latest"16],17endpoint_url: "https://docs-demo.optimism.quiknode.pro/"18)1920puts result
1require "quicknode_sdk"23qn = QuicknodeSdk::SDK.from_config(api_key: nil)45result = qn.rpc.call(6method: "eth_estimateExecutionGas",7params: [8{9"to" => "0x6b175474e89094c44da98b954eedeac495271d0f",10"gas" => "0x7a120",11"gasPrice" => "0x0",12"value" => "0x0",13"data" => "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"14},15"latest"16],17endpoint_url: "https://docs-demo.optimism.quiknode.pro/"18)1920puts result
1use quicknode_sdk::{QuicknodeSdk, SdkFullConfig};23#[tokio::main]4async fn main() -> Result<(), Box<dyn std::error::Error>> {5let qn = QuicknodeSdk::new(&SdkFullConfig::keyless())?;6let result = qn7.rpc8.call(9"eth_estimateExecutionGas",10Some(serde_json::json!([11{12"to": "0x6b175474e89094c44da98b954eedeac495271d0f",13"gas": "0x7a120",14"gasPrice": "0x0",15"value": "0x0",16"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"17},18"latest"19])),20None,21Some("https://docs-demo.optimism.quiknode.pro/".into()),22)23.await?;2425println!("{result}");26Ok(())27}
1use quicknode_sdk::{QuicknodeSdk, SdkFullConfig};23#[tokio::main]4async fn main() -> Result<(), Box<dyn std::error::Error>> {5let qn = QuicknodeSdk::new(&SdkFullConfig::keyless())?;6let result = qn7.rpc8.call(9"eth_estimateExecutionGas",10Some(serde_json::json!([11{12"to": "0x6b175474e89094c44da98b954eedeac495271d0f",13"gas": "0x7a120",14"gasPrice": "0x0",15"value": "0x0",16"data": "0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"17},18"latest"19])),20None,21Some("https://docs-demo.optimism.quiknode.pro/".into()),22)23.await?;2425println!("{result}");26Ok(())27}
1const body = {2jsonrpc: '2.0',3method: 'eth_estimateExecutionGas',4params: [{"to":"0x6b175474e89094c44da98b954eedeac495271d0f","gas":"0x7a120","gasPrice":"0x0","value":"0x0","data":"0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"},"latest"],5id: 16}78async function main() {9const response = await fetch('https://docs-demo.optimism.quiknode.pro/', {10method: 'POST',11headers: {'Content-Type': 'application/json'},12body: JSON.stringify(body)13})14const data = await response.json()15console.log(data)16}1718main()
1const body = {2jsonrpc: '2.0',3method: 'eth_estimateExecutionGas',4params: [{"to":"0x6b175474e89094c44da98b954eedeac495271d0f","gas":"0x7a120","gasPrice":"0x0","value":"0x0","data":"0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"},"latest"],5id: 16}78async function main() {9const response = await fetch('https://docs-demo.optimism.quiknode.pro/', {10method: 'POST',11headers: {'Content-Type': 'application/json'},12body: JSON.stringify(body)13})14const data = await response.json()15console.log(data)16}1718main()
1import requests2import json34url = "https://docs-demo.optimism.quiknode.pro/"56payload = json.dumps(json.loads("{\"jsonrpc\":\"2.0\",\"method\":\"eth_estimateExecutionGas\",\"params\":[{\"to\":\"0x6b175474e89094c44da98b954eedeac495271d0f\",\"gas\":\"0x7a120\",\"gasPrice\":\"0x0\",\"value\":\"0x0\",\"data\":\"0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE\"},\"latest\"],\"id\":1}"))7headers = {8'Content-Type': 'application/json'9}1011response = requests.request("POST", url, headers=headers, data=payload)1213print(response.text)
1import requests2import json34url = "https://docs-demo.optimism.quiknode.pro/"56payload = json.dumps(json.loads("{\"jsonrpc\":\"2.0\",\"method\":\"eth_estimateExecutionGas\",\"params\":[{\"to\":\"0x6b175474e89094c44da98b954eedeac495271d0f\",\"gas\":\"0x7a120\",\"gasPrice\":\"0x0\",\"value\":\"0x0\",\"data\":\"0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE\"},\"latest\"],\"id\":1}"))7headers = {8'Content-Type': 'application/json'9}1011response = requests.request("POST", url, headers=headers, data=payload)1213print(response.text)
1require "uri"2require "json"3require "net/http"45uri = URI("https://docs-demo.optimism.quiknode.pro/")67payload = {8jsonrpc: "2.0",9id: 1,10method: "eth_estimateExecutionGas",11params: [{"to":"0x6b175474e89094c44da98b954eedeac495271d0f","gas":"0x7a120","gasPrice":"0x0","value":"0x0","data":"0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"},"latest"]12}1314request = Net::HTTP::Post.new(uri)15request["Content-Type"] = "application/json"16request.body = JSON.generate(payload)1718response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|19http.request(request)20end2122puts response.body
1require "uri"2require "json"3require "net/http"45uri = URI("https://docs-demo.optimism.quiknode.pro/")67payload = {8jsonrpc: "2.0",9id: 1,10method: "eth_estimateExecutionGas",11params: [{"to":"0x6b175474e89094c44da98b954eedeac495271d0f","gas":"0x7a120","gasPrice":"0x0","value":"0x0","data":"0x70a082310000000000000000000000006E0d01A76C3Cf4288372a29124A26D4353EE51BE"},"latest"]12}1314request = Net::HTTP::Post.new(uri)15request["Content-Type"] = "application/json"16request.body = JSON.generate(payload)1718response = Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|19http.request(request)20end2122puts response.body
1{2"jsonrpc": "2.0",3"id": 1,4"result": "0x5208"5}
1{2"jsonrpc": "2.0",3"id": 1,4"result": "0x5208"5}