Skip to main content

Paymaster REST API v1

Reference for the v1 policy service: GET /health, POST /sponsor, POST /paymaster/:appToken and the admin circuit-breaker reset. It decides whether to sign a sponsorship for PepuVerifyingPaymasterV7 and says exactly why when it refuses. Read this if you run or call the v1 service.

The v1 paymaster is retired and this API is documented for reference only. Its EntryPoint deposit has been withdrawn, so it cannot sponsor anything. For new work use REST API v2 at https://paymaster.pepeunchained.com. Local default: http://localhost:8788 (the service's own code default port is 8787).

Routes​

Method and pathAuthPurpose
GET /healthNoneLiveness probe. Returns {"status":"ok"}
POST /sponsorAuthorization: Bearer <Privy access token> and X-Api-Key: <app key>Evaluate a sponsorship request directly (your own frontend or backend calls this)
POST /paymaster/:appTokenThe app key in the URLERC-7677 JSON-RPC. What Privy's smart-wallet client calls. See ERC-7677 Methods
OPTIONS /paymaster/:appTokenNoneCORS preflight, answers 204
POST /admin/circuit-breaker/resetX-Admin-Token equal to ADMIN_TOKENClear the global circuit breaker. Disabled (not served) when ADMIN_TOKEN is unset

The SDK client for these is createPaymasterApi().v1 (sponsor, health, erc7677Url) from @pepu-chain/sdk/paymaster.

POST /sponsor​

Headers:

HeaderValue
AuthorizationBearer <Privy access token>. Verified against Privy's JWKS
X-Api-KeyThe app's raw API key. The service stores only sha256(key) and compares in constant time
Content-Typeapplication/json

Body: { "userOp": { ... } } with the v0.7 unpacked fields, numeric fields as 0x hex:

{
"userOp": {
"sender": "0x…",
"nonce": "0x0",
"factory": "0x…",
"factoryData": "0x…",
"callData": "0x…",
"callGasLimit": "0x…",
"verificationGasLimit": "0x…",
"preVerificationGas": "0x…",
"maxFeePerGas": "0x…",
"maxPriorityFeePerGas": "0x…"
}
}

factory and factoryData are present only when the operation deploys the user's smart account.

Approved (HTTP 200):

{
"status": "approved",
"chainId": 97741,
"paymaster": "0x2B6FED323bFA24f0475f4e1Dd3C7F6Cc1f3ae8B0",
"paymasterVerificationGasLimit": "0x…",
"paymasterPostOpGasLimit": "0x…",
"paymasterData": "0x…",
"validUntil": 0,
"validAfter": 0,
"userOpHash": "0x…"
}

Denied (4xx or 5xx):

{ "status": "denied", "reason": "invalid_or_expired_token", "message": "The Privy access token is missing, expired, or does not verify." }

A missing bearer token returns 401 invalid_or_expired_token ("Missing or empty Authorization bearer token."). An invalid bearer token returns the same status after a round trip to Privy's JWKS endpoint.

POST /paymaster/:appToken​

<appToken> is the app's raw API key, the same value as X-Api-Key, carried in the path because Privy's dashboard field is a bare URL. Treat the full URL as a secret. Methods and shapes are on ERC-7677 Methods.

The trade-off, stated plainly: Privy calls this URL straight from the end user's browser with no Privy access token. So the /sponsor ownership check (the smart wallet must belong to the authenticated Privy user) is not available here. The app token is the only per-caller credential. Every other check still runs (allowlist, per-app budget, circuit breaker), but per-"user" caps are keyed on the UserOperation's sender address, not a verified identity. That opens a sybil path (fresh Kernel accounts each get fresh per-sender caps), which the per-app caps, the destination allowlist and the global circuit breaker bound. Worst case is denial of sponsorship, never fund theft, because every sponsored call must still clear the allowlist. See Policy, Caps and the Circuit Breaker.

Status and reason table​

HTTP statuses for a denial come from the reason. Every *_cap_exceeded reason is a 429.

ReasonHTTPMeaning
invalid_or_expired_token401Missing, expired or unverifiable Privy token
unknown_or_invalid_app_credential401The API key (header or URL) is not a registered app
sender_not_owned_by_token_user403/sponsor only: the sender smart wallet is not owned by the token's Privy user, or the check failed (fail closed)
destination_not_globally_allowed403A decoded target is not on the global allowlist
destination_not_allowed_for_app403A decoded target is not on this app's own list
calldata_decode_failed400Not a Kernel v3 execute single or batch call (static-call or delegatecall flavours are always denied)
malformed_request400Body failed validation
user_hourly_count_cap_exceeded, user_daily_count_cap_exceeded, user_lifetime_count_cap_exceeded429Per-user count caps
user_hourly_spend_cap_exceeded, user_daily_spend_cap_exceeded, user_lifetime_spend_cap_exceeded429Per-user worst-case spend caps
app_daily_spend_cap_exceeded, app_lifetime_spend_cap_exceeded429Per-app spend caps
global_circuit_breaker_tripped503Aggregate daily ceiling reached; clear with the admin reset

On the ERC-7677 route the same reasons arrive as JSON-RPC -32000 with error.data.reason.

Caps​

All are environment variables of the service with defaults in src/config.ts; caps are booked at the worst-case cost (all five gas limits times maxFeePerGas) when the approval is signed.

CapCode defaultHosted deployment
Per-user count: hourly, daily, lifetime20, 100, 2,000same
Per-user spend: hourly, daily, lifetime25, 100, 1,000 PEPUsame
Per-app daily and lifetime spendper app in config/apps.json; null lifetime means uncappedthe demo app: 200 PEPU a day
Global daily ceiling1,000 PEPU500 PEPU a day
Validity window90 secondssame

Per-user caps use a trailing window (no resetting by waiting for midnight); per-app and global use calendar-day UTC. Detail is on Policy, Caps and the Circuit Breaker.

Rate limiting and proxying​

There is no built-in per-IP rate limiting in v1. For a hosted deployment, put a reverse proxy with rate limits in front, set PAYMASTER_RPC_ALLOWED_ORIGINS once frontend origins are known and keep the per-app URL secret.

What to expect​

  • A sponsored first transaction costs about 12 PEPU of worst-case reservation (it deploys the account), later ones about 3 PEPU.
  • A denial never consumes budget.
  • State is a SQLite file (DB_PATH); spend accounting assumes a single process.

Common failures​

SymptomCauseFix
401 invalid_or_expired_tokenNo or stale Privy tokenFetch a fresh access token and retry
401 unknown_or_invalid_app_credentialWrong or revoked keyCheck X-Api-Key or the URL; ask the operator to register or rotate
403 sender_not_owned_by_token_userSmart Wallets not enabled in the Privy Dashboard, or the sender belongs to someone elseEnable Smart Wallets (Kernel, chain 97741); see Dashboard Settings
403 destination_not_globally_allowedThe call goes to a contract not on config/allowlist.jsonAdd the contract (operator action)
429 user_hourly_spend_cap_exceeded on a first transactionCap is below the ~12 PEPU account deploymentRaise the per-user caps above the deployment cost
503 global_circuit_breaker_trippedDaily ceiling hitWait for UTC rollover, or POST /admin/circuit-breaker/reset