eth_estimateGas RPC 方法
参数
交易
对象
必填
正在加载...
来自
字符串
正在加载...
到
字符串
必填
正在加载...
气体
整数
正在加载...
gasPrice
整数
正在加载...
值
整数
正在加载...
数据
字符串
正在加载...
blockNumber
字符串
正在加载...
退货
数量
字符串
正在加载...
请求
1curl https://docs-demo.ault-mainnet.quiknode.pro/ \2-X POST \3-H "Content-Type: application/json" \4--data '{"method":"eth_estimateGas","params":[{"to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","data":"0x70a08231000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}],"id":1,"jsonrpc":"2.0"}'
1curl https://docs-demo.ault-mainnet.quiknode.pro/ \2-X POST \3-H "Content-Type: application/json" \4--data '{"method":"eth_estimateGas","params":[{"to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","data":"0x70a08231000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}],"id":1,"jsonrpc":"2.0"}'
1require 'eth'23客户 = Eth::客户.创建 'https://docs-demo.ault-mainnet.quiknode.pro/'4有效载荷 = {5“jsonrpc”: "2.0",6“方法”: "eth_estimateGas",7"params":[{"to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","data":"0x70a08231000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}],8"id": "1"9}1011回复 = 客户端.发送(有效载荷.to_json)12返回响应
1require 'eth'23客户 = Eth::客户.创建 'https://docs-demo.ault-mainnet.quiknode.pro/'4有效载荷 = {5“jsonrpc”: "2.0",6“方法”: "eth_estimateGas",7"params":[{"to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","data":"0x70a08231000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}],8"id": "1"9}1011回复 = 客户端.发送(有效载荷.to_json)12返回响应
1import { ethers } from "ethers";2(async () => {3const provider = new ethers.JsonRpcProvider(“https://docs-demo.ault-mainnet.quiknode.pro/”);4const response = await provider.estimateGas({5"from": "0xd9275Eb8276E14b9e28d5f9B12e90dDAAF3586Ef",6"to": "0xD2374e67cf81135c220f3E806afdCd7Cab6515f2",7});8控制台.log(响应);9})();
1import { ethers } from "ethers";2(async () => {3const provider = new ethers.JsonRpcProvider(“https://docs-demo.ault-mainnet.quiknode.pro/”);4const response = await provider.estimateGas({5"from": "0xd9275Eb8276E14b9e28d5f9B12e90dDAAF3586Ef",6"to": "0xD2374e67cf81135c220f3E806afdCd7Cab6515f2",7});8控制台.log(响应);9})();
1var myHeaders = new Headers();2myHeaders.追加("Content-Type", "application/json");34var raw = JSON.stringify({5“方法”: "eth_estimateGas",6"params":[{"to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","data":"0x70a08231000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}],7"id": 1,8“jsonrpc”: "2.0"9});1011var requestOptions = {12方法: 'POST',13标题: myHeaders,14正文: raw,15重定向: 'follow'16};1718fetch(“https://docs-demo.ault-mainnet.quiknode.pro/”, requestOptions)19.然后(响应 => 响应.text())20.然后(结果 => 控制台.log(result))21.catch(error => 控制台.log('error', error));
1var myHeaders = new Headers();2myHeaders.追加("Content-Type", "application/json");34var raw = JSON.stringify({5“方法”: "eth_estimateGas",6"params":[{"to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","data":"0x70a08231000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}],7"id": 1,8“jsonrpc”: "2.0"9});1011var requestOptions = {12方法: 'POST',13标题: myHeaders,14正文: raw,15重定向: 'follow'16};1718fetch(“https://docs-demo.ault-mainnet.quiknode.pro/”, requestOptions)19.然后(响应 => 响应.text())20.然后(结果 => 控制台.log(result))21.catch(error => 控制台.log('error', error));
1导入 请求2import json34url = "https://docs-demo.ault-mainnet.quiknode.pro/"56有效载荷 = json.dumps({7“方法”: "eth_estimateGas",8"params":[{"to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","data":"0x70a08231000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}],9"id": 1,10“jsonrpc”: "2.0"11})12标题 = {13“Content-Type”: 'application/json'14}1516回复 = 请求.请求("POST", url, headers=headers, data=有效载荷)1718打印(响应.text)19
1导入 请求2import json34url = "https://docs-demo.ault-mainnet.quiknode.pro/"56有效载荷 = json.dumps({7“方法”: "eth_estimateGas",8"params":[{"to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","data":"0x70a08231000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}],9"id": 1,10“jsonrpc”: "2.0"11})12标题 = {13“Content-Type”: 'application/json'14}1516回复 = 请求.请求("POST", url, headers=headers, data=有效载荷)1718打印(响应.text)19
1require "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.ault-mainnet.quiknode.pro/")67https = Net::HTTP.new(url.主机, url.端口)8https.use_ssl = true910请求 = Net::HTTP::POST.new(url)11请求["Content-Type"] = "application/json"12请求.请求体 = JSON.dump({13“方法”: "eth_estimateGas",14"params":[{"to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","data":"0x70a08231000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}],15"id": 1,16“jsonrpc”: "2.0"17})1819回复 = https.请求(请求)20返回响应.read_body21
1require "uri"2require "json"3require "net/http"45url = URI("https://docs-demo.ault-mainnet.quiknode.pro/")67https = Net::HTTP.new(url.主机, url.端口)8https.use_ssl = true910请求 = Net::HTTP::POST.new(url)11请求["Content-Type"] = "application/json"12请求.请求体 = JSON.dump({13“方法”: "eth_estimateGas",14"params":[{"to":"0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2","data":"0x70a08231000000000000000000000000a0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"}],15"id": 1,16“jsonrpc”: "2.0"17})1819回复 = https.请求(请求)20返回响应.read_body21
1来源 web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.ault-mainnet.quiknode.pro/'))3estimate = w3.eth.estimate_gas({"from":"0xd9275Eb8276E14b9e28d5f9B12e90dDAAF3586Ef","to":"0xD2374e67cf81135c220f3E806afdCd7Cab6515f2"})4print(estimate)
1来源 web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.ault-mainnet.quiknode.pro/'))3estimate = w3.eth.estimate_gas({"from":"0xd9275Eb8276E14b9e28d5f9B12e90dDAAF3586Ef","to":"0xD2374e67cf81135c220f3E806afdCd7Cab6515f2"})4print(estimate)