eth_estimateGas RPC 方法
參數
交易
物件
載入中...
來自
字串
載入中...
至
字串
必填
載入中...
氣體
整數
載入中...
gasPrice
整數
載入中...
值
整數
載入中...
資料
字串
載入中...
區塊編號
字串
載入中...
退貨
結果
字串
載入中...
請求
1curl https://docs-demo.hype-mainnet.quiknode.pro/evm \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.hype-mainnet.quiknode.pro/evm \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 { 核心 } from '@quicknode/sdk'23const 核心 = new Core({4endpointUrl: "https://docs-demo.hype-mainnet.quiknode.pro/evm",5})67核心.客戶端8.estimateGas({9account,10to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',11value: parseEther('1')12})13.then(res => console.log(res))14
1import { 核心 } from '@quicknode/sdk'23const 核心 = new Core({4endpointUrl: "https://docs-demo.hype-mainnet.quiknode.pro/evm",5})67核心.客戶端8.estimateGas({9account,10to: '0x70997970c51812dc3a010c7d01b50e0d17dc79c8',11value: parseEther('1')12})13.then(res => console.log(res))14
1需要 'eth'23client = Eth::Client.create 'https://docs-demo.hype-mainnet.quiknode.pro/evm'4有效載荷 = {5"jsonrpc": "2.0",6"method": "eth_estimateGas",7"params": [{"from":"0x8D97689C9818892B700e27F316cc3E41e17fBeb9","to":"0xd3CdA913deB6f67967B99D67aCDFa1712C293601"}],8"id": "1"9}1011回應 = 客戶.傳送(有效載荷.to_json)12將回應
1需要 'eth'23client = Eth::Client.create 'https://docs-demo.hype-mainnet.quiknode.pro/evm'4有效載荷 = {5"jsonrpc": "2.0",6"method": "eth_estimateGas",7"params": [{"from":"0x8D97689C9818892B700e27F316cc3E41e17fBeb9","to":"0xd3CdA913deB6f67967B99D67aCDFa1712C293601"}],8"id": "1"9}1011回應 = 客戶.傳送(有效載荷.to_json)12將回應
1import { ethers } from "ethers";2(async () => {3const provider = new ethers.JsonRpcProvider("https://docs-demo.hype-mainnet.quiknode.pro/evm");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.hype-mainnet.quiknode.pro/evm");4const estimate = await provider.estimateGas({5"from": "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",6"to": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601",7});8console.log(estimate);9})();10
1var myHeaders = new Headers();2myHeaders.追加("Content-Type", "application/json");34var raw = JSON.stringify({5「方法」: "eth_estimateGas",6"params": [7{8「來自」: "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",9"到": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"10}11],12"id": 1,13"jsonrpc": "2.0"14});1516var requestOptions = {17方法: 'POST',18標題: myHeaders,19正文: 原始,20redirect: 'follow'21};2223fetch("https://docs-demo.hype-mainnet.quiknode.pro/evm", requestOptions)24.then(response => response.text())25.then(result => console.log(result))26.catch(error => console.log('error', error));
1var myHeaders = new Headers();2myHeaders.追加("Content-Type", "application/json");34var raw = JSON.stringify({5「方法」: "eth_estimateGas",6"params": [7{8「來自」: "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",9"到": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"10}11],12"id": 1,13"jsonrpc": "2.0"14});1516var requestOptions = {17方法: 'POST',18標題: myHeaders,19正文: 原始,20redirect: 'follow'21};2223fetch("https://docs-demo.hype-mainnet.quiknode.pro/evm", requestOptions)24.then(response => response.text())25.then(result => console.log(result))26.catch(error => console.log('error', error));
1匯入 請求2import json34url = "https://docs-demo.hype-mainnet.quiknode.pro/evm"56有效載荷 = json.dumps({7「方法」: "eth_estimateGas",8"params": [9{10「來自」: "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",11"到": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"12}13],14"id": 1,15"jsonrpc": "2.0"16})17標題 = {18「Content-Type」: 'application/json'19}2021回應 = 請求.請求("POST", url, headers=headers, data=有效載荷)2223列印(回應.text)24
1匯入 請求2import json34url = "https://docs-demo.hype-mainnet.quiknode.pro/evm"56有效載荷 = json.dumps({7「方法」: "eth_estimateGas",8"params": [9{10「來自」: "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",11"到": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"12}13],14"id": 1,15"jsonrpc": "2.0"16})17標題 = {18「Content-Type」: 'application/json'19}2021回應 = 請求.請求("POST", url, headers=headers, data=有效載荷)2223列印(回應.text)24
1需要 "uri"2require "json"3需要 "net/http"45url = URI("https://docs-demo.hype-mainnet.quiknode.pro/evm")67https = 網::HTTP.new(url.主機, url.port)8https.use_ssl = true910請求 = 淨::HTTP::POST.new(網址)11請求["Content-Type"] = "application/json"12請求。正文 = JSON.dump({13「方法」: "eth_estimateGas",14"params": [15{16「來自」: "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",17"到": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"18}19],20"id": 1,21"jsonrpc": "2.0"22})2324回應 = https.請求(請求)25將回應。read_body26
1需要 "uri"2require "json"3需要 "net/http"45url = URI("https://docs-demo.hype-mainnet.quiknode.pro/evm")67https = 網::HTTP.new(url.主機, url.port)8https.use_ssl = true910請求 = 淨::HTTP::POST.new(網址)11請求["Content-Type"] = "application/json"12請求。正文 = JSON.dump({13「方法」: "eth_estimateGas",14"params": [15{16「來自」: "0x8D97689C9818892B700e27F316cc3E41e17fBeb9",17"到": "0xd3CdA913deB6f67967B99D67aCDFa1712C293601"18}19],20"id": 1,21"jsonrpc": "2.0"22})2324回應 = https.請求(請求)25將回應。read_body26
1出自 web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.hype-mainnet.quiknode.pro/evm'))3estimate = w3.eth.estimate_gas({"from":"0x8D97689C9818892B700e27F316cc3E41e17fBeb9","to":"0xd3CdA913deB6f67967B99D67aCDFa1712C293601"})4print(estimate)
1出自 web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.hype-mainnet.quiknode.pro/evm'))3estimate = w3.eth.estimate_gas({"from":"0x8D97689C9818892B700e27F316cc3E41e17fBeb9","to":"0xd3CdA913deB6f67967B99D67aCDFa1712C293601"})4print(estimate)