eth_estimateGas RPC メソッド
なお、このRPCメソッドでは、ブロック番号が「pending」に設定されている場合、Polygon zkEVMはそれを最新のものとして扱いますのでご注意ください。
パラメータ
取引
オブジェクト
読み込み中...
出典:
文字列
読み込み中...
~へ
文字列
必須
読み込み中...
ガス
整数
読み込み中...
gasPrice
整数
読み込み中...
値
整数
読み込み中...
データ
文字列
読み込み中...
返品
数量
文字列
読み込み中...
リクエスト
1curl -X POST "https://docs-demo.peaq-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}11],12"id": 113}'
1curl -X POST "https://docs-demo.peaq-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}11],12"id": 113}'
1import { ethers } from "ethers";23async 関数 main() {4const プロバイダー = new ethers.JsonRpcProvider(「https://docs-demo.peaq-mainnet.quiknode.pro/」);5const response = await provider.send("eth_estimateGas", [6{7「from」: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",8「to」: "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"9}10]);11コンソール.log(レスポンス);12}1314メイン();
1import { ethers } from "ethers";23async 関数 main() {4const プロバイダー = new ethers.JsonRpcProvider(「https://docs-demo.peaq-mainnet.quiknode.pro/」);5const response = await provider.send("eth_estimateGas", [6{7「from」: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",8「to」: "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"9}10]);11コンソール.log(レスポンス);12}1314メイン();
1出典: web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.peaq-mainnet.quiknode.pro/'))3response = w3.provider.make_request("eth_estimateGas", [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"}])4印刷(レスポンス)
1出典: web3 import Web3, HTTPProvider2w3 = Web3(HTTPProvider('https://docs-demo.peaq-mainnet.quiknode.pro/'))3response = w3.provider.make_request("eth_estimateGas", [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"}])4印刷(レスポンス)
1import { createPublicClient, http } from 'viem'23async 関数 main() {4const クライアント = createPublicClient({5輸送: http('https://docs-demo.peaq-mainnet.quiknode.pro/')6})78const result = await client.リクエスト({9メソッド: 'eth_estimateGas',10params: [11{12「from」: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",13「to」: "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"14}15]16})1718コンソール.log(結果)19}2021メイン()
1import { createPublicClient, http } from 'viem'23async 関数 main() {4const クライアント = createPublicClient({5輸送: http('https://docs-demo.peaq-mainnet.quiknode.pro/')6})78const result = await client.リクエスト({9メソッド: 'eth_estimateGas',10params: [11{12「from」: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",13「to」: "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"14}15]16})1718コンソール.log(結果)19}2021メイン()
1import { Core } from '@quicknode/sdk'23const コア = new Core({4endpointUrl: "https://docs-demo.peaq-mainnet.quiknode.pro/",5})67コア.クライアント8.リクエスト({9メソッド: 'eth_estimateGas',10params: [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"}]11})12.その後(res => console.log(res))
1import { Core } from '@quicknode/sdk'23const コア = new Core({4endpointUrl: "https://docs-demo.peaq-mainnet.quiknode.pro/",5})67コア.クライアント8.リクエスト({9メソッド: 'eth_estimateGas',10params: [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"}]11})12.その後(res => console.log(res))
1const body = {2jsonrpc: '2.0',3メソッド: 'eth_estimateGas',4params: [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"}],5id: 16}78async 関数 main() {9const response = await fetch('https://docs-demo.peaq-mainnet.quiknode.pro/', {10メソッド: 'POST',11headers: {'Content-Type': 'application/json'},12本文: JSON.stringify(body)13})14const データ = await response.json()15コンソール.log(データ)16}1718メイン()
1const body = {2jsonrpc: '2.0',3メソッド: 'eth_estimateGas',4params: [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"}],5id: 16}78async 関数 main() {9const response = await fetch('https://docs-demo.peaq-mainnet.quiknode.pro/', {10メソッド: 'POST',11headers: {'Content-Type': 'application/json'},12本文: JSON.stringify(body)13})14const データ = await response.json()15コンソール.log(データ)16}1718メイン()
1import リクエスト2import json34url = "https://docs-demo.peaq-mainnet.quiknode.pro/"56ペイロード = json.dumps({7"jsonrpc": "2.0",8「メソッド」: "eth_estimateGas",9"params": [10{11「from」: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",12「to」: "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"13}14],15"id": 116})17ヘッダー = {18「Content-Type」: 'application/json'19}2021回答 = リクエスト.リクエスト("POST", url, headers=headers, データ=ペイロード)2223印刷(レスポンス.text)
1import リクエスト2import json34url = "https://docs-demo.peaq-mainnet.quiknode.pro/"56ペイロード = json.dumps({7"jsonrpc": "2.0",8「メソッド」: "eth_estimateGas",9"params": [10{11「from」: "0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4",12「to」: "0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"13}14],15"id": 116})17ヘッダー = {18「Content-Type」: 'application/json'19}2021回答 = リクエスト.リクエスト("POST", url, headers=headers, データ=ペイロード)2223印刷(レスポンス.text)
1require "uri"2require "json"3require "net/http"45uri = URI(「https://docs-demo.peaq-mainnet.quiknode.pro/」)67ペイロード = {8jsonrpc: "2.0",9id: 1,10メソッド: "eth_estimateGas",11params: [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"}]12}1314リクエスト = ネット::HTTP::POST.new(URI)15リクエスト["Content-Type"] = "application/json"16リクエスト.本文 = JSON.generate(ペイロード)1718回答 = ネット::HTTP.開始(uri.host, uri.port, use_ssl: true) do |http|19http.リクエスト(リクエスト)20終わり2122レスポンスを格納する。body
1require "uri"2require "json"3require "net/http"45uri = URI(「https://docs-demo.peaq-mainnet.quiknode.pro/」)67ペイロード = {8jsonrpc: "2.0",9id: 1,10メソッド: "eth_estimateGas",11params: [{"from":"0xB06c72C825FEEf32A1d5F4837e0972A9A1F628e4","to":"0x63Bc61A75F972140426b36Bb91281f2D1D11a05a"}]12}1314リクエスト = ネット::HTTP::POST.new(URI)15リクエスト["Content-Type"] = "application/json"16リクエスト.本文 = JSON.generate(ペイロード)1718回答 = ネット::HTTP.開始(uri.host, uri.port, use_ssl: true) do |http|19http.リクエスト(リクエスト)20終わり2122レスポンスを格納する。body
回答
1{2"jsonrpc": "2.0",3"id": 1,4"結果": "0x5208"5}
1{2"jsonrpc": "2.0",3"id": 1,4"結果": "0x5208"5}