Skip to main content
In this guide, you will learn how to create and deploy both the Anchor program and UI for a basic on-chain Favorites dApp. This dApp will allow users to store their favorite number, color, and hobbies through on-chain transactions.

What you will learn

  • Setting up your development environment
  • Using npx create-soon-app
  • Understanding Anchor program structure
  • Creating and using Program Derived Addresses (PDAs)
  • Connecting an Anchor program to a Next.js UI

Prerequisites

For this guide, you will need:
  • Node.js and pnpm installed
  • Rust and Cargo
  • Anchor CLI
  • A SOON compatible wallet

Setting up the project

Create a new project using:
This will set up a complete project with:
  • Next.js frontend
  • Anchor program
  • Tailwind CSS
  • Jupiter wallet adapter integration
  • SOON testnet configuration

Understanding the Anchor Program

The Anchor program is located in anchor-program/programs/favorites/src/lib.rs. Let’s break down its key components:

Program State

This structure defines what we’ll store on-chain:
  • A favorite number (u64)
  • A favorite color (string up to 50 chars)
  • A list of hobbies (up to 5 hobbies, each up to 50 chars)

Instruction Handler

Frontend Integration

The frontend is a Next.js application that uses:
  • Jupiter wallet adapter for SOON testnet
  • Anchor for program interaction
  • Tailwind CSS for styling

Key Components

  1. Wallet Connection:
  1. State Management:
  1. Transaction Handling:

Testing the dApp

  1. Connect your SOON wallet
  2. Input your favorites:
    • Enter a favorite number
    • Choose a favorite color
    • Add up to 5 hobbies
  3. Click “Save Favorites” to store on-chain
  4. View the transaction on SOON Explorer

Resources