Paymaster RPC Methods
JSON-RPC API reference for Stackup's Verifying Paymaster service.
All of Stackup's Paymaster API endpoints are listed here. pm
is the paymaster namespace used by Stackup and implements the proposed interface outlined here.
pm_sponsorUserOperation
This methods sends a UserOperation to a paymaster for off-chain verification. If approved, it will return the paymasterAndData and updated gas values which can be appended to the UserOperation before signing.
If the paymaster rejects the UserOperation it should not return a result but a standard JSON-RPC error with the reason.
Parameters (in order)
- UserOperation: This is a UserOperation with a valid dummy signature.
- entryPoint: The EntryPoint address that the UserOperation is intended for.
- context: This argument contains information about the specific paymaster implementation you are using.
{
"jsonrpc": "2.0",
"id": 1,
"method": "pm_sponsorUserOperation",
"params": [
{
sender, // address
nonce, // uint256
initCode, // bytes
callData, // bytes
callGasLimit, // uint256
verificationGasLimit, // uint256
preVerificationGas, // uint256
maxFeePerGas, // uint256
maxPriorityFeePerGas, // uint256
paymasterAndData, // bytes
signature, // Can be a valid dummy value
},
"0x0576a174D229E3cFA37253523E645A78A0C91B57",
{ /* PM specific data here... */ }
]
}
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"paymasterAndData": "0x1234...5678",
"preVerificationGas": "0x...",
"verificationGasLimit": "0x...",
"callGasLimit": "0x...",
}
}
{
"jsonrpc": "2.0",
"id": 1,
"error": {
"message": "Error reason here.",
"code": -32601
}
}
Sponsored transactions
Stackup's pay-as-you-go paymaster (PAYG) allows you to sponsor UserOperations for users directly. Your Stackup account will be billed at the end of the month. To use this paymaster, simply add { "type": "payg" }
to the context field when making a request:
{
"type": "payg"
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "pm_sponsorUserOperation",
"params": [
{
sender, // address
nonce, // uint256
initCode, // bytes
callData, // bytes
callGasLimit, // uint256
verificationGasLimit, // uint256
preVerificationGas, // uint256
maxFeePerGas, // uint256
maxPriorityFeePerGas, // uint256
paymasterAndData, // bytes
signature, // Can be a valid dummy value
},
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
{
"type": "payg"
}
]
}
ERC-20 transactions
Similarly, you can use ERC-20 tokens for gas payment. For now Stackup accepts USDC for mainnet transactions and test ERC-20 tokens for testnet transactions.
To use this paymaster, simply add {"type": "erc20token", "token": "0x000..."}
to the context field when making a request.
{
"type": "erc20token",
"token": "USDC_ADDRESS" | "TEST_TOKEN_ADDRESS"
}
{
"jsonrpc": "2.0",
"id": 1,
"method": "pm_sponsorUserOperation",
"params": [
{
sender, // address
nonce, // uint256
initCode, // bytes
callData, // bytes
callGasLimit, // uint256
verificationGasLimit, // uint256
preVerificationGas, // uint256
maxFeePerGas, // uint256
maxPriorityFeePerGas, // uint256
paymasterAndData, // bytes
signature, // Can be a valid dummy value
},
"0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789",
{
"type": "erc20token",
"token": "0x3870419Ba2BBf0127060bCB37f69A1b1C090992B" // testnet token
}
]
}
The testnet ERC-20 token address is 0x3870419Ba2BBf0127060bCB37f69A1b1C090992B
. You may mint up to 1 ETH of test tokens at a time using the block scanner interface.
pm_accounts
This method allows clients to get all the paymaster addresses associated with an EntryPoint that’s owned by this service. The first address in the returned array is the preferred paymaster contract.
This is useful for use cases where a client application is required to know the paymaster address to create certain transactions like an ERC-20 approve.
{
"jsonrpc": "2.0",
"id": 1,
"method": "pm_accounts",
"params": [
entryPoint // string
]
}
{
"jsonrpc": "2.0",
"id": 1,
"result": [
"0x..."
]
}
Updated about 1 month ago