Skip to main content

Project Structure

The template follows Next.js App Router conventions with a clean separation of concerns.

Core Files Explained

app/layout.tsx

The root layout wraps your entire app with the wallet provider:

app/page.tsx

The main page composes all components:

utils/constants.ts

Contains program IDs, PDA derivation, and helper functions:

Key Helper Functions

getAllowancePda

Derives the allowance PDA for a handle and wallet:

extractHandle

Extracts the encrypted handle from account data:
The offset 72-88 is specific to the Inco Token program’s IncoAccount structure. Adjust the offset based on your program’s account layout.

fetchUserMint

Finds the user’s mint account:

fetchUserTokenAccount

Finds the user’s token account for a specific mint:

getProgram

Creates an Anchor program instance:

Next Steps

Learn how to set up Wallet Integration for your dApp.