Template: NFT Mint
The nft-mint template is an ERC-721 mint page: connect, see the collection's live mint price and supply, mint with a real transaction and list the tokens the wallet owns. It ships the PepuNft contract twice, for Foundry and for Hardhat. Use it as the base for a mint page for your own collection.
There is no pre-deployed collection: you deploy PepuNft yourself before the app runs. Minting is a real transaction and the user pays gas.
What it demonstrates
| Pillar | Covered |
|---|---|
| Google to wallet | Yes |
| Session keys | No |
| Sponsored transactions | No. Even a zero-price mint costs the caller gas, and there is no gasless badge |
- Collection read in one batched Multicall3 call: name, symbol, mint price, total supply,
MAX_SUPPLY. - A Mint button that sends a real transaction.
- The owned token ids, from a second batched read using
ERC721Enumerable.
Scaffold
npx create-pepu-app@latest my-app --template nft-mint
Deploy the contract first
Pick one toolchain, each in contracts/:
contracts/foundry(Foundry,forgeandcast)contracts/hardhat(Hardhat with TypeScript)
Both deploy the same PepuNft: OpenZeppelin Contracts v5.7.0 ERC721, ERC721Enumerable and Ownable, with MAX_SUPPLY = 1000, token ids from 1, and a payable mint() whose price the deployer sets. Neither project is wired into the Next.js build. If foundry-zksync is installed, the forge on your PATH may be the wrong fork for an Arbitrum Orbit chain: run forge --version and confirm it does not mention zksync. Verification and deployment: Deploy and Verify a Contract.
Then set NEXT_PUBLIC_NFT_CONTRACT_ADDRESS to the deployed address.
SDK functions it uses
| Job | SDK function (subpath) | Where |
|---|---|---|
| Providers, mainnet-only Privy config, active-wallet pin | PepuPrivyWagmiProvider (/privy/wagmi) | app/providers.tsx |
| Wallet provisioning | useEnsureWallet (/privy/react), createEnsureWalletRoute (/privy/server) | WalletGate, app/api/wallet/ensure/route.ts |
| Embedded versus external wallet | useEmbeddedWallet (/privy/react) | components/wallet-card.tsx |
| Batched collection reads | pepuMulticall (core), pinned to PEPU's Multicall3 | components/mint-panel.tsx |
| Owned tokens | wagmi useReadContracts, routed through the same Multicall3 because pepuMainnet carries contracts.multicall3 | components/owned-tokens.tsx |
| Chain facts, explorer links, amount formatting | pepuMainnet, explorerLinks, formatPepu (core) | wallet card, mint panel |
| Env check | checkPepuEnv (/doctor) | scripts/doctor.mjs |
The contract ABI is the template's own (lib/nft-abi.ts), covering only the functions the app calls.
Environment and Privy settings
| Variable | Required | Notes |
|---|---|---|
NEXT_PUBLIC_PRIVY_APP_ID | Yes | Public. |
PRIVY_APP_SECRET | Yes | Server only. |
NEXT_PUBLIC_NFT_CONTRACT_ADDRESS | Yes | Blank on purpose. Until set, a setup screen shows the exact steps. |
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) andPRIVY_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
loginMethodsinapp/providers.tsx(enable what you list). - Embedded wallets: enable for Ethereum, create on login.
WalletGatecalls/api/wallet/ensureafter 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
eoaOnlyin code because it does not support chain97741.
Field by field: Dashboard Settings, Field by Field.
Run and check
cd my-app
# deploy the contract first (contracts/foundry or contracts/hardhat)
npm install
npm run doctor
npm run dev # http://localhost:3000
Fund the wallet with a little PEPU: a mint needs gas, plus the mint price if it is above zero.
Project structure
app/ layout, providers, page (behind SetupGate), api/wallet/ensure
components/ signed-out-view, signed-in-view, wallet-card, mint-panel, owned-tokens, gas-notice, setup-gate, missing-config-notice
lib/ env.ts, nft-abi.ts, format.ts
scripts/doctor.mjs
contracts/ foundry/ and hardhat/ (PepuNft)
Limitations
- No pre-deployed collection: deploy
PepuNftyourself and setNEXT_PUBLIC_NFT_CONTRACT_ADDRESS. - No sponsorship: the user pays gas.
Customizing it
- Change the supply, price or metadata in
contracts/, redeploy and update the address andlib/nft-abi.ts. - To list a collection somewhere, note that being listed (for example on PepuSwap) is a third-party decision and is not automatic from deploying.
- For a gasless mint you would need real sponsorship (Sponsored Transactions), which this template does not include.
Common failures
| Symptom | Cause | Fix |
|---|---|---|
| Setup screen with deployment steps | NEXT_PUBLIC_NFT_CONTRACT_ADDRESS is blank | Deploy PepuNft and set the address. |
| Deploy goes wrong or produces odd output | forge is the foundry-zksync fork | Install upstream Foundry and recheck forge --version. |
| Mint transaction fails | Not enough PEPU for gas plus the price, or supply is exhausted | Fund the wallet, or check totalSupply against MAX_SUPPLY. |