Initialize App

Step-by-step setup for building an appchain-backed app, modeled after Adrift

Getting Started

This guide will help you set up a new appchain backed project, following the structure of Adrift. You'll create a monorepo with a Next.js frontend, a Ponder indexer, a Bun-powered backend, and Foundry contracts.

Quick Start

1. Install Bun & Foundry

Bun is a fast, modern JavaScript/TypeScript package manager and runtime, used in Adrift for installing dependencies, running scripts, and executing backend jobs. Foundry is a powerful toolkit for developing, testing, and deploying Solidity smart contracts, chosen for its speed and developer experience.

Follow the official instructions for your platform to install both tools before proceeding.

2. Create Your Project Structure

Adrift uses a monorepo structure to keep the frontend, indexer, backend, and contracts organized in one place. This makes development, dependency management, and deployment easier for complex, multi-component apps.

mkdir my-appchain-project && cd my-appchain-project
mkdir -p apps/site apps/indexer apps/cron contracts

3. Scaffold the Frontend (Next.js + Bun)

Next.js is a popular React framework for building fast, modern web apps. In Adrift, it powers the user interface and client-side logic. Bun is used here for dependency management and running the app.

bun create next ./apps/site
cd apps/site
bun install

4. Scaffold the Indexer (Ponder)

Ponder is a TypeScript-first, developer-friendly tool for indexing blockchain events and syncing onchain data to a local database. Adrift uses Ponder to track game and player state, making it easy to build real-time, onchain-powered UIs.

cd ../../apps/indexer
bun init
bun add ponder
# Add your ponder.config.ts and ponder.schema.ts (see Adrift for examples)

5. Scaffold the Contracts (Foundry)

Foundry is used for all smart contract development in Adrift. It provides fast compilation, testing, and deployment for Solidity contracts, and is widely adopted in the Ethereum ecosystem.

cd ../../contracts
forge init
# Add your contracts and scripts (see Adrift for factory pattern)

Project Structure

This structure keeps each part of your appchain project modular and maintainable, following the Adrift example.

my-appchain-project/
  apps/
    site/      # Next.js frontend
    indexer/   # Ponder indexer
    cron/      # Backend/cron jobs
  contracts/   # Solidity contracts (Foundry)
  bun.lock     # Bun lockfile

Install Dependencies

cd apps/site && bun install
cd ../indexer && bun install
cd ../cron && bun install
cd ../../contracts && forge install

Running the Apps

  • Frontend (Next.js + Bun):
    cd apps/site
    bun run dev
  • Indexer (Ponder):
    cd apps/indexer
    bun run dev
  • Contracts:
    cd contracts
    forge build
    forge test
    # Deploy: forge script script/Deploy.s.sol:DeployFactories --rpc-url <your_rpc_url>

Next Steps

  • Configure your chain connection in apps/site/utils/chain.ts
  • Set up wallet integration with Wagmi and Para in the frontend
  • Define your Ponder schema and event handlers in the indexer
  • Implement your contract logic and deployment scripts in contracts/
  • Build your UI and hooks for game logic, player state, and randomness

For more details, see the Adrift repo and the deeper guides on contracts, wallet setup, sequencing, indexer, and game logic.

On this page