Paymaster API
The Paymaster API signs paymasterAndData for your ERC-4337 UserOperations. It exposes both an ERC-7677-compliant JSON-RPC surface and a thin REST surface.
Authentication
Section titled “Authentication”Authorization: Bearer sk_live_...All endpoints accept either a sk_live_* server key or a publishable pmc_* key (REST only, with origin allowlisting).
Base URLs
Section titled “Base URLs”| Env | URL |
|---|---|
| Production | https://api.stablecoinx.com |
| Sandbox | https://api.sandbox.stablecoinx.com |
POST /v1/paymaster/sign
Section titled “POST /v1/paymaster/sign”Sign paymasterAndData for a UserOperation.
Body
| Field | Type | Required | Description |
|---|---|---|---|
userOp | UserOperation | yes | The unsigned UserOp |
mode | "sponsor" | "user_pays" | no | Override project default |
chain | string | yes | e.g. base, arbitrum |
policyKey | string | no | Named per-sender policy |
Response
{ "paymasterAndData": "0x...", "preVerificationGas": "0x...", "verificationGasLimit": "0x...", "callGasLimit": "0x..."}GET /v1/paymaster/info
Section titled “GET /v1/paymaster/info”Returns paymaster metadata for the calling project.
{ "contracts": { "base": "0xPaymaster...", "arbitrum": "0xPaymaster...", "optimism": "0xPaymaster...", "ethereum": "0xPaymaster..." }, "supportedAssets": ["USDe", "USDC"], "modesEnabled": ["sponsor", "user_pays"], "limits": { "sponsorBudgetRemaining": "100.00", "perSenderDailyCap": "10.00" }}POST /v1/paymaster/policies
Section titled “POST /v1/paymaster/policies”Create or update a per-sender policy.
{ "name": "vip-users", "senders": ["0xabc...", "0xdef..."], "mode": "sponsor", "dailyCap": "5.00", "monthlyCap": "100.00"}JSON-RPC (ERC-7677)
Section titled “JSON-RPC (ERC-7677)”Endpoint: POST https://api.stablecoinx.com/v1/paymaster/rpc
pm_getPaymasterStubData
Section titled “pm_getPaymasterStubData”Returns dummy paymaster data for gas estimation.
{ "jsonrpc": "2.0", "id": 1, "method": "pm_getPaymasterStubData", "params": [ { /* UserOperation */ }, "0xEntryPoint", "0x2105", { "mode": "sponsor" } ]}pm_getPaymasterData
Section titled “pm_getPaymasterData”Returns signed paymaster data ready to submit.
{ "jsonrpc": "2.0", "id": 2, "method": "pm_getPaymasterData", "params": [ /* same shape */ ]}Errors
Section titled “Errors”| HTTP | Code | Meaning |
|---|---|---|
| 400 | invalid_userop | UserOp failed schema validation |
| 401 | unauthorized | Missing or invalid key |
| 402 | sponsor_budget_exhausted | Daily or monthly sponsor cap hit |
| 403 | sender_not_allowed | Sender outside the active policy |
| 422 | unsupported_chain | chain not enabled for this project |
| 429 | rate_limited | Retry after Retry-After |
import { Paymaster } from "@stablecoinx/sdk";
const pm = new Paymaster({ apiKey: process.env.STABLECOINX_KEY! });
const { paymasterAndData } = await pm.sign({ userOp, mode: "user_pays", chain: "base",});