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 User Operation to a Paymaster for off-chain verification. If approved, it will return the paymasterAndData and updated gas values which can be appended to the User Operation before signing.

If the Paymaster rejects the User Operation it should not return a result but a standard JSON-RPC error with the reason.

Parameters (in order)

  • UserOperation: This is a User Operation with a valid dummy signature.
  • entryPoint: The EntryPoint address that the User Operation 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 User Operations 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.

Try it here: pm_sponsorUserOperation

{
  "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, users can pay for gas using ERC-20 tokens. See the full list of ERC-20 tokens.

To use the ERC-20 token paymaster, simply add {"type": "erc20token", "token": "0x000..."} to the context field when making a request.

Try it here: pm_sponsorUserOperation

{
  "type": "erc20token",
  "token": "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 with the contract using your blockchain's block explorer.


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.

Try it here: pm_accounts

{
  "jsonrpc": "2.0",
  "id": 1,
  "method": "pm_accounts",
  "params": [
      entryPoint // string
  ]
}
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": [
    "0x..."
  ]
}