Bundler API
estimateUserOperationGas
Learn how to use the estimateUserOperationGas JSON-RPC method.
POST
/
#eth_estimateUserOperationGas
estimateUserOperationGas
curl --request POST \
--url 'https://bundler.particle.network/#eth_estimateUserOperationGas' \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 1,
"chainId": 80001,
"method": "eth_estimateUserOperationGas",
"params": [
{
"sender": "0xSenderAddress",
"nonce": "0x1",
"initCode": "0xInitCode",
"callData": "0xCallData",
"signature": "0xSignature"
}
]
}
'import requests
url = "https://bundler.particle.network/#eth_estimateUserOperationGas"
payload = {
"jsonrpc": "2.0",
"id": 1,
"chainId": 80001,
"method": "eth_estimateUserOperationGas",
"params": [
{
"sender": "0xSenderAddress",
"nonce": "0x1",
"initCode": "0xInitCode",
"callData": "0xCallData",
"signature": "0xSignature"
}
]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
chainId: 80001,
method: 'eth_estimateUserOperationGas',
params: [
{
sender: '0xSenderAddress',
nonce: '0x1',
initCode: '0xInitCode',
callData: '0xCallData',
signature: '0xSignature'
}
]
})
};
fetch('https://bundler.particle.network/#eth_estimateUserOperationGas', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://bundler.particle.network/#eth_estimateUserOperationGas",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'id' => 1,
'chainId' => 80001,
'method' => 'eth_estimateUserOperationGas',
'params' => [
[
'sender' => '0xSenderAddress',
'nonce' => '0x1',
'initCode' => '0xInitCode',
'callData' => '0xCallData',
'signature' => '0xSignature'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://bundler.particle.network/#eth_estimateUserOperationGas"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"chainId\": 80001,\n \"method\": \"eth_estimateUserOperationGas\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"signature\": \"0xSignature\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://bundler.particle.network/#eth_estimateUserOperationGas")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"chainId\": 80001,\n \"method\": \"eth_estimateUserOperationGas\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"signature\": \"0xSignature\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://bundler.particle.network/#eth_estimateUserOperationGas")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"chainId\": 80001,\n \"method\": \"eth_estimateUserOperationGas\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"signature\": \"0xSignature\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 1,
"chainId": 80001,
"result": {
"maxFeePerGas": "0x3B9ACA00",
"maxPriorityFeePerGas": "0x3B9ACA00",
"preVerificationGas": "0x5208",
"verificationGas": "0x5208",
"verificationGasLimit": "0x5208",
"callGasLimit": "0x5208"
}
}Understanding estimateUserOperationGas
estimateUserOperationGastakes a partial UserOperation object and returns detailed gas estimates to be used in continued UserOperation construction. It takes:- Partial user operation object:
sender- string.nonce- string.initCode- string.callData- string.signature- string.signaturecan be a dummy string, such as0xfffffffffffffffffffffffffffffff0000000000000000000000000000000007aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa1c.entrypointAddress- string.
- Partial user operation object:
Query example
JSON
{
"method": "eth_estimateUserOperationGas",
"params": [
// partial user operation
{
"sender": "0x8fb859e944561678be40cdd2db16551396c0b074",
"nonce": "0x0152",
"initCode": "0x",
"callData": "0x9e5d4c49000000000000000000000000329a7f8b91ce7479035cb1b5d62ab41845830ce8000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000",
"signature": "0x73c3ac716c487ca34bb858247b5ccf1dc354fbaabdd089af3b2ac8e78ba85a4959a2d76250325bd67c11771c31fccda87c33ceec17cc0de912690521bb95ffcb1b"
},
"0x5ff137d4b0fdcd49dca30c7cf57e578a026d2789"
],
"id": 1695717515,
"jsonrpc": "2.0",
"chainId": 80001
}
Body
application/json
Request to estimate the gas cost of a user operation.
Version of the JSON-RPC protocol, should be 2.0.
Example:
"2.0"
The request identifier.
Example:
1
The chain ID.
Example:
80001
API method being called.
Available options:
eth_estimateUserOperationGas Parameters for gas estimation.
Show child attributes
Show child attributes
Response
200 - application/json
Successful response with gas estimation.
Was this page helpful?
⌘I
estimateUserOperationGas
curl --request POST \
--url 'https://bundler.particle.network/#eth_estimateUserOperationGas' \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 1,
"chainId": 80001,
"method": "eth_estimateUserOperationGas",
"params": [
{
"sender": "0xSenderAddress",
"nonce": "0x1",
"initCode": "0xInitCode",
"callData": "0xCallData",
"signature": "0xSignature"
}
]
}
'import requests
url = "https://bundler.particle.network/#eth_estimateUserOperationGas"
payload = {
"jsonrpc": "2.0",
"id": 1,
"chainId": 80001,
"method": "eth_estimateUserOperationGas",
"params": [
{
"sender": "0xSenderAddress",
"nonce": "0x1",
"initCode": "0xInitCode",
"callData": "0xCallData",
"signature": "0xSignature"
}
]
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify({
jsonrpc: '2.0',
id: 1,
chainId: 80001,
method: 'eth_estimateUserOperationGas',
params: [
{
sender: '0xSenderAddress',
nonce: '0x1',
initCode: '0xInitCode',
callData: '0xCallData',
signature: '0xSignature'
}
]
})
};
fetch('https://bundler.particle.network/#eth_estimateUserOperationGas', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://bundler.particle.network/#eth_estimateUserOperationGas",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'jsonrpc' => '2.0',
'id' => 1,
'chainId' => 80001,
'method' => 'eth_estimateUserOperationGas',
'params' => [
[
'sender' => '0xSenderAddress',
'nonce' => '0x1',
'initCode' => '0xInitCode',
'callData' => '0xCallData',
'signature' => '0xSignature'
]
]
]),
CURLOPT_HTTPHEADER => [
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://bundler.particle.network/#eth_estimateUserOperationGas"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"chainId\": 80001,\n \"method\": \"eth_estimateUserOperationGas\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"signature\": \"0xSignature\"\n }\n ]\n}")
req, _ := http.NewRequest("POST", url, payload)
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://bundler.particle.network/#eth_estimateUserOperationGas")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"chainId\": 80001,\n \"method\": \"eth_estimateUserOperationGas\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"signature\": \"0xSignature\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://bundler.particle.network/#eth_estimateUserOperationGas")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
request["Content-Type"] = 'application/json'
request.body = "{\n \"jsonrpc\": \"2.0\",\n \"id\": 1,\n \"chainId\": 80001,\n \"method\": \"eth_estimateUserOperationGas\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"signature\": \"0xSignature\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 1,
"chainId": 80001,
"result": {
"maxFeePerGas": "0x3B9ACA00",
"maxPriorityFeePerGas": "0x3B9ACA00",
"preVerificationGas": "0x5208",
"verificationGas": "0x5208",
"verificationGasLimit": "0x5208",
"callGasLimit": "0x5208"
}
}