Skip to main content

Template: Consumer App

The consumer-app template shows that onchain onboarding can feel like a normal app: sign in with email or Google, get an embedded wallet, see a live PEPU balance and send native PEPU, with no seed phrase and no browser extension. It is the best first template and the base the other starters build on.

No sponsorship: the user pays gas in PEPU.

What it demonstrates​

PillarCovered
Google to walletYes: login (email, Google, or an existing wallet), server-side wallet provisioning, embedded wallet as the active account
Session keysNo
Sponsored transactionsNo. A permanent notice says sponsorship is not usable by this app, and there is no "gasless" badge
  • Signed out: a landing page with one sign-in button.
  • Signed in: provisions the wallet if the user has none, shows its address (copy button and a pepuscan link), its live PEPU balance and a form to send native PEPU with a pending state and a transaction link.
  • Gas notice: every send costs the user real PEPU, a fraction of a cent.

Scaffold​

npx create-pepu-app@latest my-app --template consumer-app

See create-pepu-app CLI for every flag.

SDK functions it uses​

JobSDK function (subpath)Where
Privy, react-query and wagmi providers, mainnet-only Privy config, active-wallet pinPepuPrivyWagmiProvider (/privy/wagmi), which uses createPepuPrivyConfig, pepuWagmiConfig and useActiveWalletPinapp/providers.tsx
Wallet provisioning (request, timeouts, refreshUser, retry)useEnsureWallet (/privy/react)WalletGate in components/signed-in-view.tsx
Server-side wallet creationcreateEnsureWalletRoute (/privy/server)app/api/wallet/ensure/route.ts
Embedded versus external walletuseEmbeddedWallet (/privy/react)components/wallet-card.tsx
Chain facts, explorer links, amount formattingpepuMainnet, explorerLinks, formatPepu (core)wallet card, send form, network badge
Env checkcheckPepuEnv (/doctor)scripts/doctor.mjs

Environment and Privy settings​

VariableRequiredNotes
NEXT_PUBLIC_PRIVY_APP_IDYesPublic by design.
PRIVY_APP_SECRETYesServer only. Used by app/api/wallet/ensure/route.ts.

No optional variables.

Privy dashboard checklist (the same list sits in the template's .env.example). Doctor requirements login-methods, allowed-origins, embedded-wallets:

  • Env: NEXT_PUBLIC_PRIVY_APP_ID (public) and PRIVY_APP_SECRET (secret, server only), both under Settings, Basics.
  • Allowed origins: the exact origin with the port, http://localhost:3000, plus your production domain.
  • Login methods: email, Google and external wallet, matching loginMethods in app/providers.tsx (enable what you list).
  • Embedded wallets: enable for Ethereum, create on login. WalletGate calls /api/wallet/ensure after login and creates the wallet server-side with the app secret if the dashboard setting is off, so both together is fine. TEE (user-controlled) mode is what the live tests used.
  • Smart Wallets: leave off. Not used here; enabling it is harmless.
  • Coinbase Wallet is pinned to eoaOnly in code because it does not support chain 97741.

Field by field: Dashboard Settings, Field by Field.

Run and check​

cd my-app
npm install
npm run doctor # ok or FAIL per key, no values printed
npm run dev # http://localhost:3000, the port must be free

Fund the wallet with a small amount of PEPU to send something. Mainnet gas costs a fraction of a cent.

Project structure​

app/ layout, providers (PepuPrivyWagmiProvider), page, api/wallet/ensure
components/ signed-out-view, signed-in-view, wallet-card, send-pepu-form, gas-notice, missing-config-notice
lib/format.ts address truncation
scripts/doctor.mjs
contracts/ foundry and hardhat projects with a trivial example contract

Limitations​

  • Sending PEPU is a standard wagmi send. Privy's pre-flight gas check is conservative at PEPU's base fee of about 12,500 gwei.
  • No sponsorship: the user pays gas in PEPU.

Privy runs two wallet architectures, and which one your Privy app uses changes what happens on login. The template README spells it out.

Customizing it​

  • Add your own panels to components/signed-in-view.tsx; keep WalletGate so a signed-in user always has a wallet.
  • To let an external wallet be the active account, pass pinEmbeddedWallet={false} to PepuPrivyWagmiProvider. The default is deliberate: the template's story depends on the embedded wallet being the sender.
  • Do not add a "Max" button: Privy's pre-flight balance check is over-conservative at PEPU's base fee. If you build one, size it with maxSendableAmount() from the SDK.
  • Do not add a gasless badge unless you wire real sponsorship (Sponsored Transactions).

Common failures​

SymptomCauseFix
Login hangs or returns 403The app is on port 3001, or the origin is not in Allowed originsFree port 3000, or add the exact origin to Privy.
Wallet never appearsAutomatic creation is off and the fallback route lacks the secretSet PRIVY_APP_SECRET and check the app/api/wallet/ensure route.
A different address sends the transactionA browser extension became the active wagmi accountKeep PepuPrivyWagmiProvider (it pins the embedded wallet).
Privy refuses a transfer the wallet can affordIts pre-flight gas check is conservative at the PEPU base feeSend a slightly smaller amount.
"Unable to fetch token price" in the consoleHarmless Privy noiseIgnore it.