Skip to main content

Template: Sponsored Demo

The sponsored-demo template is a minimal browser demo of gas sponsorship end to end on PEPU. A user signs in with Privy, gets a Kernel smart account holding zero PEPU, clicks one button to send a sponsored TapScore.tap() UserOperation, and watches the paymaster's own EntryPoint deposit drop. The drop, not the transaction alone, is the evidence of who paid.

To make this demo sponsor with your own Privy app you must bring a project: claim it, set targets and limits, deposit, and use its token (below). It uses the hosted bundler (https://bundler.pepeunchained.com) and paymaster (https://paymaster.pepeunchained.com). The free tier is not reachable from this demo: it needs a verified Privy token from PEPU's own Privy app, and the Privy Smart Wallets dashboard URL is static and cannot attach a token.

What it demonstrates​

PillarCovered
Google to walletYes: the embedded wallet is the owner (signer) of the smart account
Session keysNo
Sponsored transactionsYes, over the Privy Smart Wallets transport

It is a demo, not a production starter: no wagmi, no external-wallet connect, one screen, no retry or backoff. A failed tap shows a typed error and lets you press again.

Two addresses​

Sign-in produces two addresses and the demo shows the second:

  • The embedded wallet is an EOA that only acts as the signer (owner) of the smart account.
  • The Kernel smart account is a separate contract account with its own address. It holds 0 PEPU, sends the UserOperation and appears as the sender on pepuscan.

Do not expect them to match and do not send funds to one expecting them in the other. See The Two-Address Model.

Scaffold​

npx create-pepu-app@latest my-app --template sponsored-demo

SDK functions it uses​

JobSDK function (subpath)Where
Privy provider with Smart Wallets nested insidePepuPrivyProvider, composeProviders (/privy/react)app/providers.tsx
Provision the owner walletcreateEnsureWalletRoute (/privy/server), useEnsureWallet (/privy/react)app/api/wallet/ensure/route.ts, WalletGate
The sponsored senduseSponsoredSend({ transport: "privy-smart-wallets" }) (/aa/react), no ZeroDev packages (needs permissionless, which Privy's smart-wallets module requires)components/sponsored-tap-demo.tsx
The Kernel smart account addressusePepuSmartAccount (/aa/react)same
The paymaster deposit before and aftergetPaymasterDeposit (/aa)same
Readable failuresdescribeUserOpFailure (/aa, applied inside useSponsoredSend)same
Is a bundler and paymaster configuredusePepuSponsorship (/aa/react), wrapping checkSponsorshipsame
Chain facts, explorer linksgetContract, isDeployed, pepuMainnet, explorerLinks (core)components

lib/tapscore.ts is the only template-specific code: the hardcoded target (TapScore at 0x261eA5971B93237a56990206A46Bc80318e4d078) and its ABI.

Environment and Privy settings​

VariableRequiredNotes
NEXT_PUBLIC_PRIVY_APP_IDYesPublic.
PRIVY_APP_SECRETYesServer only. Used to provision the owner wallet.
NEXT_PUBLIC_PAYMASTER_CONTRACT_ADDRESSNoPublic on-chain address. Defaults to the deployed v2 paymaster 0xdb28528C9399C33c9A0297E8A62F39145acbC30D (the v1 paymaster is retired). The demo reads its EntryPoint deposit to show the before and after.

Sponsorship is configured entirely in the Privy dashboard, not in the app. Settings, Wallet infrastructure, Smart wallets:

SettingValue
Chain97741
ProviderKernel
Bundler URLhttps://bundler.pepeunchained.com (local default for your own: http://localhost:4337)
Paymaster URLhttps://paymaster.pepeunchained.com/v2/paymaster/<project token> (local default for your own: http://localhost:8788; the token is a credential)

Use your project's client token (ppt_) with your app's origins set as the project's allowed origins, because Privy calls the paymaster from the browser. Never use the server key (ppk_) in the dashboard.

Also required (doctor requirements login-methods, allowed-origins, embedded-wallets, smart-wallets):

  • Env: NEXT_PUBLIC_PRIVY_APP_ID (public) and PRIVY_APP_SECRET (secret, server only), both under Settings, Basics.
  • Allowed origins: http://localhost:3000 (exact port) plus your production domain.
  • Login methods: Google and email, matching loginMethods in app/providers.tsx.
  • Embedded wallets: Ethereum, create on login. WalletGate and /api/wallet/ensure provision the owner wallet server-side as a fallback. TEE (user-controlled) mode is what the live tests used.
  • Smart Wallets: required, with provider Kernel (ZeroDev) v3.1 and the custom chain PEPU, chain id 97741, RPC https://rpc-pepu-v2-mainnet-0.t.conduit.xyz. If it is off, the page spins forever on "Setting up your smart wallet..." and the app cannot work around it. Old dashboards may still hold temporary development bundler or paymaster URLs (tunnels): replace them with the hosted ones in the table above.
  • Paymaster credential: the project client token (ppt_) inside the dashboard paymaster URL, with your app's origins allowed. Never use the server key (ppk_) there. The free tier cannot be used on this path (a static URL carries no per-user Privy token), so a funded project is required.

What you must configure to sponsor with your own project​

The demo does not sponsor out of the box for a third-party app. In order:

  1. Sign in with Ethereum to the policy service (/v2/auth/nonce, /v2/auth/login).
  2. Verify your Privy app: POST /v2/projects/verify with the Privy app id and secret (used for one request, never stored).
  3. Claim the project (claimProject): immediate if the project is empty, pending 48 hours if someone already funded it.
  4. Set the targets and limits: setTargets (include TapScore), setDailyLimit, setSenderDailyLimit.
  5. Deposit PEPU (depositFor). Deposits are one-way, so deposit only what your project needs.
  6. Register the project to get the client token and the server key, then set allowed origins for the client token.
  7. Enter the token in the Privy dashboard paymaster URL above.

The steps are in Sponsorship Tiers and Deposit and Claim a Paymaster Project.

The paymaster only sponsors allowlisted destinations. TapScore must be in the project's targets. See Paymaster Overview and Bundler Overview.

Run and check​

cd my-app
npm install
npm run doctor
npm run dev # http://localhost:3000 only

Run on port 3000 only. Privy's allowed origins match the exact origin including the port, and Next.js silently falls back to 3001 when 3000 is taken.

What you see: sign in, wait for the wallet and then the smart wallet to be set up, see the Kernel address with 0 PEPU, click Sponsor a tap, then a transaction link and a before, after and drop panel for the paymaster deposit. A nonzero drop from a wallet that paid nothing shows the paymaster paid.

Project structure​

app/ layout, providers (PepuPrivyProvider plus SmartWalletsProvider), page, api/wallet/ensure
components/ signed-in-view (WalletGate), sponsored-tap-demo (the whole sponsored path)
lib/ tapscore.ts (target and ABI), env.ts
scripts/doctor.mjs

Limitations​

  • Using this demo with your own Privy app needs your own claimed and funded project and its token, plus the dashboard setup above.
  • The free tier is not reachable from this demo.
  • Each tap spends real paymaster deposit.

Idempotency: one tap is one UserOperation, a retry builds a fresh operation with the next nonce and never replays, and wallet provisioning looks for an existing wallet first.

Customizing it​

  • Change the target in lib/tapscore.ts and add the new contract to the paymaster's allowlist and your app's allowed destinations.
  • For a browser flow with a session key and no popups, use sponsored-session-app. This template keeps the Privy Smart Wallets transport: /aa/react never resolves @zerodev/*, and permissionless (required by Privy's smart-wallets module) is the only extra package it needs.
  • Treat the paymaster URL as a secret and keep it out of the browser where you can.

Common failures​

code or symptomMeaningFix
Spinner on "Setting up your smart wallet"Smart Wallets is off, or the bundler or paymaster URL is missing in the dashboardSet chain 97741, provider Kernel, both URLs.
PAYMASTER_DESTINATION_NOT_ALLOWEDThe call targets a contract not on the allowlistAdd TapScore to the global allowlist and your app's allowed destinations.
PAYMASTER_ORIGIN_NOT_ALLOWEDThe page origin is not allowedAllow the exact origin including the port.
PAYMASTER_DENIED (also AA32 to AA34)The credential or sender was rejected, or the policy signer does not match the paymaster contractCheck the app key in the paymaster URL and that the smart account belongs to the signed-in user.
PAYMASTER_NO_BALANCE (also AA31)The paymaster's EntryPoint deposit cannot cover the operationDeposit PEPU to the paymaster contract.
PAYMASTER_CAPA daily, per-sender or per-operation cap was hitWait for the window to reset, or raise the limits.
BUNDLER_AA_FAILED (AA25)Invalid nonce: another operation from this account is pendingWait for it to confirm, then retry.
BUNDLER_UNREACHABLEThe bundler or paymaster URL is unset or wrongFix the dashboard values.
The failure box says "not configured" but the dashboard is rightWith this transport the working URLs live in Privy, not envTreat that line as a hint. Export the env vars too if you want the probe to agree.