eth_estimateGas RPC 方法
请注意,对于此 RPC 方法,如果区块号设置为“待定”,Polygon 会将其视为最新区块号。
参数
交易
对象
正在加载...
来自
字符串
正在加载...
到
字符串
必填
正在加载...
气体
整数
正在加载...
gasPrice
整数
正在加载...
值
整数
正在加载...
数据
字符串
正在加载...
退货
数量
字符串
正在加载...
请求
1curl -X POST "https://docs-demo.abstract-mainnet.quiknode.pro/" \2-H "Content-Type: application/json" \3-d '{4"jsonrpc": "2.0",5"method": "eth_estimateGas",6"params": [7{8"from": "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",9"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",10"gas": "0x0",11"gasPrice": "0x0",12"value": "0x0"13}14],15"id": 116}'
1curl -X POST "https://docs-demo.abstract-mainnet.quiknode.pro/" \2-H "Content-Type: application/json" \3-d '{4"jsonrpc": "2.0",5"method": "eth_estimateGas",6"params": [7{8"from": "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",9"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",10"gas": "0x0",11"gasPrice": "0x0",12"value": "0x0"13}14],15"id": 116}'
1import { ethers } from "ethers";23async 函数 main() {4const provider = new ethers.JsonRpcProvider("https://docs-demo.abstract-mainnet.quiknode.pro/");5const 响应 = await provider.send("eth_estimateGas", [6{7“来自”: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",8"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",9"gas": "0x0",10"gasPrice": "0x0",11“value”: "0x0"12}13]);14控制台.日志(响应);15}1617主();
1import { ethers } from "ethers";23async 函数 main() {4const provider = new ethers.JsonRpcProvider("https://docs-demo.abstract-mainnet.quiknode.pro/");5const 响应 = await provider.send("eth_estimateGas", [6{7“来自”: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",8"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",9"gas": "0x0",10"gasPrice": "0x0",11“value”: "0x0"12}13]);14控制台.日志(响应);15}1617主();
1来源 web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.abstract-mainnet.quiknode.pro/'))3response = w3.provider.make_request("eth_estimateGas", [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a","gas":"0x0","gasPrice":"0x0","value":"0x0"}])4打印(响应)
1来源 web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.abstract-mainnet.quiknode.pro/'))3response = w3.provider.make_request("eth_estimateGas", [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a","gas":"0x0","gasPrice":"0x0","value":"0x0"}])4打印(响应)
1import { createPublicClient, http } 来自 'viem'23async 函数 main() {4const 客户端 = createPublicClient({5transport: http('https://docs-demo.abstract-mainnet.quiknode.pro/')6})78const 结果 = await client.request({9方法: 'eth_estimateGas',10参数: [11{12“来自”: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",13"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",14"gas": "0x0",15"gasPrice": "0x0",16"value": "0x0"17}18]19})2021控制台.日志(结果)22}2324主()
1import { createPublicClient, http } 来自 'viem'23async 函数 main() {4const 客户端 = createPublicClient({5transport: http('https://docs-demo.abstract-mainnet.quiknode.pro/')6})78const 结果 = await client.request({9方法: 'eth_estimateGas',10参数: [11{12“来自”: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",13"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",14"gas": "0x0",15"gasPrice": "0x0",16"value": "0x0"17}18]19})2021控制台.日志(结果)22}2324主()
1import { QuicknodeSdk } from '@quicknode/sdk'23const qn = new QuicknodeSdk({})45const result = await qn.rpc.call(6'eth_estimateGas',7[8{9"from": "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",10"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",11"gas": "0x0",12"gasPrice": "0x0",13"value": "0x0"14}15],16undefined,17'https://docs-demo.abstract-mainnet.quiknode.pro/'18)1920console.log(result)
1import { QuicknodeSdk } from '@quicknode/sdk'23const qn = new QuicknodeSdk({})45const result = await qn.rpc.call(6'eth_estimateGas',7[8{9"from": "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",10"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",11"gas": "0x0",12"gasPrice": "0x0",13"value": "0x0"14}15],16undefined,17'https://docs-demo.abstract-mainnet.quiknode.pro/'18)1920console.log(result)
1import asyncio2from quicknode_sdk import QuicknodeSdk, SdkFullConfig34async def main():5qn = QuicknodeSdk(SdkFullConfig(api_key=None))6result = await qn.rpc.call(7"eth_estimateGas",8[9{10"from": "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",11"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",12"gas": "0x0",13"gasPrice": "0x0",14"value": "0x0"15}16],17endpoint_url="https://docs-demo.abstract-mainnet.quiknode.pro/",18)19print(result)2021asyncio.run(main())
1import asyncio2from quicknode_sdk import QuicknodeSdk, SdkFullConfig34async def main():5qn = QuicknodeSdk(SdkFullConfig(api_key=None))6result = await qn.rpc.call(7"eth_estimateGas",8[9{10"from": "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",11"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",12"gas": "0x0",13"gasPrice": "0x0",14"value": "0x0"15}16],17endpoint_url="https://docs-demo.abstract-mainnet.quiknode.pro/",18)19print(result)2021asyncio.run(main())
1require "quicknode_sdk"23qn = QuicknodeSdk::SDK.from_config(api_key: nil)45result = qn.rpc.call(6方法: "eth_estimateGas",7params: [8{9"from" => "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",10"to" => "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",11"gas" => "0x0",12"gasPrice" => "0x0",13"value" => "0x0"14}15],16endpoint_url: "https://docs-demo.abstract-mainnet.quiknode.pro/"17)1819puts result
1require "quicknode_sdk"23qn = QuicknodeSdk::SDK.from_config(api_key: nil)45result = qn.rpc.call(6方法: "eth_estimateGas",7params: [8{9"from" => "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",10"to" => "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",11"gas" => "0x0",12"gasPrice" => "0x0",13"value" => "0x0"14}15],16endpoint_url: "https://docs-demo.abstract-mainnet.quiknode.pro/"17)1819puts 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_estimateGas",10Some(serde_json::json!([11{12“来自”: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",13"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",14"gas": "0x0",15"gasPrice": "0x0",16“value”: "0x0"17}18])),19None,20Some("https://docs-demo.abstract-mainnet.quiknode.pro/".into()),21)22.await?;2324println!("{result}");25好的(())26}
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_estimateGas",10Some(serde_json::json!([11{12“来自”: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",13"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",14"gas": "0x0",15"gasPrice": "0x0",16“value”: "0x0"17}18])),19None,20Some("https://docs-demo.abstract-mainnet.quiknode.pro/".into()),21)22.await?;2324println!("{result}");25好的(())26}
1const body = {2jsonrpc: '2.0',3方法: 'eth_estimateGas',4params: [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a","gas":"0x0","gasPrice":"0x0","value":"0x0"}],5id: 16}78async 函数 main() {9const response = await fetch('https://docs-demo.abstract-mainnet.quiknode.pro/', {10方法: 'POST',11headers: {'Content-Type': 'application/json'},12正文: JSON.stringify(body)13})14const 数据 = await 响应.json()15控制台.日志(数据)16}1718主()
1const body = {2jsonrpc: '2.0',3方法: 'eth_estimateGas',4params: [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a","gas":"0x0","gasPrice":"0x0","value":"0x0"}],5id: 16}78async 函数 main() {9const response = await fetch('https://docs-demo.abstract-mainnet.quiknode.pro/', {10方法: 'POST',11headers: {'Content-Type': 'application/json'},12正文: JSON.stringify(body)13})14const 数据 = await 响应.json()15控制台.日志(数据)16}1718主()
1导入 请求2导入 json34url = "https://docs-demo.abstract-mainnet.quiknode.pro/"56有效载荷 = json.dumps({7"jsonrpc": "2.0",8“方法”: "eth_estimateGas",9“params”: [10{11“来自”: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",12"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",13"gas": "0x0",14"gasPrice": "0x0",15"value": "0x0"16}17],18"id": 119})20标题 = {21“Content-Type”: 'application/json'22}2324回复 = 请求.请求("POST", url, headers=headers, 数据=有效载荷)2526打印(响应.text)
1导入 请求2导入 json34url = "https://docs-demo.abstract-mainnet.quiknode.pro/"56有效载荷 = json.dumps({7"jsonrpc": "2.0",8“方法”: "eth_estimateGas",9“params”: [10{11“来自”: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",12"to": "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a",13"gas": "0x0",14"gasPrice": "0x0",15"value": "0x0"16}17],18"id": 119})20标题 = {21“Content-Type”: 'application/json'22}2324回复 = 请求.请求("POST", url, headers=headers, 数据=有效载荷)2526打印(响应.text)
1require "uri"2require "json"3require "net/http"45uri = URI("https://docs-demo.abstract-mainnet.quiknode.pro/")67有效载荷 = {8jsonrpc: "2.0",9id: 1,10方法: "eth_estimateGas",11params: [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a","gas":"0x0","gasPrice":"0x0","value":"0x0"}]12}1314请求 = Net::HTTP::POST.new(URI)15请求["Content-Type"] = "application/json"16请求.请求正文 = JSON.生成(有效载荷)1718回复 = 净::HTTP.开始(uri.主机, uri.端口, use_ssl: true) 执行 |http|19http.请求(请求)20结束2122返回响应。正文
1require "uri"2require "json"3require "net/http"45uri = URI("https://docs-demo.abstract-mainnet.quiknode.pro/")67有效载荷 = {8jsonrpc: "2.0",9id: 1,10方法: "eth_estimateGas",11params: [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a","gas":"0x0","gasPrice":"0x0","value":"0x0"}]12}1314请求 = Net::HTTP::POST.new(URI)15请求["Content-Type"] = "application/json"16请求.请求正文 = JSON.生成(有效载荷)1718回复 = 净::HTTP.开始(uri.主机, uri.端口, use_ssl: true) 执行 |http|19http.请求(请求)20结束2122返回响应。正文
回复
1{2"jsonrpc": "2.0",3"id": 1,4“结果”: "0x5208"5}
1{2"jsonrpc": "2.0",3"id": 1,4“结果”: "0x5208"5}