Skip to main content

Components

This guide walks you through the key components that handle encryption, minting, and balance display.

EncryptedInput Component

This component handles:
  1. Taking user input
  2. Encrypting the value with Inco SDK
  3. Creating mint and token accounts if needed
  4. Minting confidential tokens

Full Implementation

Key Steps Explained

1. Encrypt the Value

2. Create Accounts if Needed

First-time users need a mint and token account:

3. Simulate to Get Handle

Before minting, simulate to extract the handle:

4. Derive Allowance PDA and Mint


Balance Component

This component displays and decrypts the user’s confidential token balance.

Full Implementation

Key Steps Explained

1. Fetch Account Data

2. Extract Handle

The offset in extractHandle is specific to the Inco Token program. Adjust based on your program’s account layout.

3. Decrypt with Wallet Signature

The signMessage function is required for attested reveal. The wallet will prompt the user to sign a message that proves ownership of the address.

Component Communication

Components communicate via custom events:
This ensures the balance display updates after minting new tokens.

Summary

You now have a complete understanding of how to build a confidential token dApp with Next.js!