Paymaster API
sponsorUserOperation
Learn how to use the sponsorUserOperation JSON-RPC method.
POST
/
#pm_sponsorUserOperation
sponsorUserOperation
curl --request POST \
--url 'https://paymaster.particle.network/#pm_sponsorUserOperation' \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 0,
"method": "pm_sponsorUserOperation",
"params": [
{
"sender": "0xSenderAddress",
"nonce": "0x1",
"initCode": "0xInitCode",
"callData": "0xCallData",
"maxFeePerGas": "0x3B9ACA00",
"maxPriorityFeePerGas": "0x3B9ACA00",
"paymasterAndData": "0xPaymasterData",
"signature": "0xSignature",
"preVerificationGas": "0x5208",
"verificationGasLimit": "0x5208",
"callGasLimit": "0x5208"
}
]
}
'import requests
url = "https://paymaster.particle.network/#pm_sponsorUserOperation"
payload = {
"jsonrpc": "2.0",
"id": 0,
"method": "pm_sponsorUserOperation",
"params": [
{
"sender": "0xSenderAddress",
"nonce": "0x1",
"initCode": "0xInitCode",
"callData": "0xCallData",
"maxFeePerGas": "0x3B9ACA00",
"maxPriorityFeePerGas": "0x3B9ACA00",
"paymasterAndData": "0xPaymasterData",
"signature": "0xSignature",
"preVerificationGas": "0x5208",
"verificationGasLimit": "0x5208",
"callGasLimit": "0x5208"
}
]
}
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: 0,
method: 'pm_sponsorUserOperation',
params: [
{
sender: '0xSenderAddress',
nonce: '0x1',
initCode: '0xInitCode',
callData: '0xCallData',
maxFeePerGas: '0x3B9ACA00',
maxPriorityFeePerGas: '0x3B9ACA00',
paymasterAndData: '0xPaymasterData',
signature: '0xSignature',
preVerificationGas: '0x5208',
verificationGasLimit: '0x5208',
callGasLimit: '0x5208'
}
]
})
};
fetch('https://paymaster.particle.network/#pm_sponsorUserOperation', 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://paymaster.particle.network/#pm_sponsorUserOperation",
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' => 0,
'method' => 'pm_sponsorUserOperation',
'params' => [
[
'sender' => '0xSenderAddress',
'nonce' => '0x1',
'initCode' => '0xInitCode',
'callData' => '0xCallData',
'maxFeePerGas' => '0x3B9ACA00',
'maxPriorityFeePerGas' => '0x3B9ACA00',
'paymasterAndData' => '0xPaymasterData',
'signature' => '0xSignature',
'preVerificationGas' => '0x5208',
'verificationGasLimit' => '0x5208',
'callGasLimit' => '0x5208'
]
]
]),
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://paymaster.particle.network/#pm_sponsorUserOperation"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 0,\n \"method\": \"pm_sponsorUserOperation\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"maxFeePerGas\": \"0x3B9ACA00\",\n \"maxPriorityFeePerGas\": \"0x3B9ACA00\",\n \"paymasterAndData\": \"0xPaymasterData\",\n \"signature\": \"0xSignature\",\n \"preVerificationGas\": \"0x5208\",\n \"verificationGasLimit\": \"0x5208\",\n \"callGasLimit\": \"0x5208\"\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://paymaster.particle.network/#pm_sponsorUserOperation")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 0,\n \"method\": \"pm_sponsorUserOperation\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"maxFeePerGas\": \"0x3B9ACA00\",\n \"maxPriorityFeePerGas\": \"0x3B9ACA00\",\n \"paymasterAndData\": \"0xPaymasterData\",\n \"signature\": \"0xSignature\",\n \"preVerificationGas\": \"0x5208\",\n \"verificationGasLimit\": \"0x5208\",\n \"callGasLimit\": \"0x5208\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://paymaster.particle.network/#pm_sponsorUserOperation")
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\": 0,\n \"method\": \"pm_sponsorUserOperation\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"maxFeePerGas\": \"0x3B9ACA00\",\n \"maxPriorityFeePerGas\": \"0x3B9ACA00\",\n \"paymasterAndData\": \"0xPaymasterData\",\n \"signature\": \"0xSignature\",\n \"preVerificationGas\": \"0x5208\",\n \"verificationGasLimit\": \"0x5208\",\n \"callGasLimit\": \"0x5208\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 0,
"result": {
"paymasterAndData": "0xPaymasterData"
}
}Contextualizing sponsorUserOperation
sponsorUserOperationreturns a Paymaster signature to sponsor a given UserOperation, pulling from the USDT balance of the Paymaster. It takes:- UserOperation object.
entrypointAddress- string.
Query example
JavaScript
import Axios from "axios";
const chainId = 11155111;
const projectUuid = "Your project uuid";
const projectKey = "Your project client key or server key";
const entryPoint = "0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789";
const userOp = {
sender: "0xfE71795B01d2c36FD5a001fe9D47EAec0da77e59",
nonce: "0x00",
initCode:
"0x9406cc6185a346906296840746125a0e449764545fbfb9cf0000000000000000000000009a8c05c7ac9acecc1185d5a624eb185e63dde9c20000000000000000000000000000000000000000000000000000000000000000",
callData:
"0xb61d27f6000000000000000000000000aae0de40f94469761b797920a46f223d0fffd013000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000",
maxFeePerGas: "0x5e18a0d2",
maxPriorityFeePerGas: "0x5de29812",
paymasterAndData: "0x",
signature: "0x",
preVerificationGas: "0xc954",
verificationGasLimit: "0x066c12",
callGasLimit: "0xf2a0",
};
const paymasterUrl = "https://paymaster.particle.network";
(async () => {
const response = await Axios.post(
paymasterUrl,
{
method: "pm_sponsorUserOperation",
params: [userOp, entryPoint],
},
{
params: {
chainId,
projectUuid,
projectKey,
},
}
);
console.log(response.data);
})();
Body
application/json
Request to sponsor a user operation.
Version of the JSON-RPC protocol, should be 2.0.
Example:
"2.0"
The request identifier.
Example:
0
API method being called.
Available options:
pm_sponsorUserOperation Parameters for sponsoring a user operation.
Show child attributes
Show child attributes
Was this page helpful?
⌘I
sponsorUserOperation
curl --request POST \
--url 'https://paymaster.particle.network/#pm_sponsorUserOperation' \
--header 'Content-Type: application/json' \
--data '
{
"jsonrpc": "2.0",
"id": 0,
"method": "pm_sponsorUserOperation",
"params": [
{
"sender": "0xSenderAddress",
"nonce": "0x1",
"initCode": "0xInitCode",
"callData": "0xCallData",
"maxFeePerGas": "0x3B9ACA00",
"maxPriorityFeePerGas": "0x3B9ACA00",
"paymasterAndData": "0xPaymasterData",
"signature": "0xSignature",
"preVerificationGas": "0x5208",
"verificationGasLimit": "0x5208",
"callGasLimit": "0x5208"
}
]
}
'import requests
url = "https://paymaster.particle.network/#pm_sponsorUserOperation"
payload = {
"jsonrpc": "2.0",
"id": 0,
"method": "pm_sponsorUserOperation",
"params": [
{
"sender": "0xSenderAddress",
"nonce": "0x1",
"initCode": "0xInitCode",
"callData": "0xCallData",
"maxFeePerGas": "0x3B9ACA00",
"maxPriorityFeePerGas": "0x3B9ACA00",
"paymasterAndData": "0xPaymasterData",
"signature": "0xSignature",
"preVerificationGas": "0x5208",
"verificationGasLimit": "0x5208",
"callGasLimit": "0x5208"
}
]
}
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: 0,
method: 'pm_sponsorUserOperation',
params: [
{
sender: '0xSenderAddress',
nonce: '0x1',
initCode: '0xInitCode',
callData: '0xCallData',
maxFeePerGas: '0x3B9ACA00',
maxPriorityFeePerGas: '0x3B9ACA00',
paymasterAndData: '0xPaymasterData',
signature: '0xSignature',
preVerificationGas: '0x5208',
verificationGasLimit: '0x5208',
callGasLimit: '0x5208'
}
]
})
};
fetch('https://paymaster.particle.network/#pm_sponsorUserOperation', 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://paymaster.particle.network/#pm_sponsorUserOperation",
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' => 0,
'method' => 'pm_sponsorUserOperation',
'params' => [
[
'sender' => '0xSenderAddress',
'nonce' => '0x1',
'initCode' => '0xInitCode',
'callData' => '0xCallData',
'maxFeePerGas' => '0x3B9ACA00',
'maxPriorityFeePerGas' => '0x3B9ACA00',
'paymasterAndData' => '0xPaymasterData',
'signature' => '0xSignature',
'preVerificationGas' => '0x5208',
'verificationGasLimit' => '0x5208',
'callGasLimit' => '0x5208'
]
]
]),
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://paymaster.particle.network/#pm_sponsorUserOperation"
payload := strings.NewReader("{\n \"jsonrpc\": \"2.0\",\n \"id\": 0,\n \"method\": \"pm_sponsorUserOperation\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"maxFeePerGas\": \"0x3B9ACA00\",\n \"maxPriorityFeePerGas\": \"0x3B9ACA00\",\n \"paymasterAndData\": \"0xPaymasterData\",\n \"signature\": \"0xSignature\",\n \"preVerificationGas\": \"0x5208\",\n \"verificationGasLimit\": \"0x5208\",\n \"callGasLimit\": \"0x5208\"\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://paymaster.particle.network/#pm_sponsorUserOperation")
.header("Content-Type", "application/json")
.body("{\n \"jsonrpc\": \"2.0\",\n \"id\": 0,\n \"method\": \"pm_sponsorUserOperation\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"maxFeePerGas\": \"0x3B9ACA00\",\n \"maxPriorityFeePerGas\": \"0x3B9ACA00\",\n \"paymasterAndData\": \"0xPaymasterData\",\n \"signature\": \"0xSignature\",\n \"preVerificationGas\": \"0x5208\",\n \"verificationGasLimit\": \"0x5208\",\n \"callGasLimit\": \"0x5208\"\n }\n ]\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://paymaster.particle.network/#pm_sponsorUserOperation")
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\": 0,\n \"method\": \"pm_sponsorUserOperation\",\n \"params\": [\n {\n \"sender\": \"0xSenderAddress\",\n \"nonce\": \"0x1\",\n \"initCode\": \"0xInitCode\",\n \"callData\": \"0xCallData\",\n \"maxFeePerGas\": \"0x3B9ACA00\",\n \"maxPriorityFeePerGas\": \"0x3B9ACA00\",\n \"paymasterAndData\": \"0xPaymasterData\",\n \"signature\": \"0xSignature\",\n \"preVerificationGas\": \"0x5208\",\n \"verificationGasLimit\": \"0x5208\",\n \"callGasLimit\": \"0x5208\"\n }\n ]\n}"
response = http.request(request)
puts response.read_body{
"jsonrpc": "2.0",
"id": 0,
"result": {
"paymasterAndData": "0xPaymasterData"
}
}