Setup Contract Development
Complete guide to set up your local ink! development environment
Prerequisites
Before starting, ensure you have the following installed on your system.
Install Node.js v22
We recommend using nvm (Node Version Manager) for easy version management:
# Install nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
# Install Node.js v22
nvm install 22
nvm use 22
# Install nvm-windows from:
# https://github.com/coreybutler/nvm-windows
# Then install Node.js v22
nvm install 22.0.0
nvm use 22.0.0
Install Bun
Bun is our package manager of choice for its speed and reliability:
bash curl -fsSL https://bun.sh/install | bash
powershell powershell -c "irm bun.sh/install.ps1 | iex"
Verify installation:
bun --version
Install Rust & cargo-contract
Install Rust and the ink! contract build tool:
# Install Rust
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add wasm32 target
rustup target add wasm32-unknown-unknown
# Install cargo-contract v6 (alpha)
cargo install cargo-contract@6.0.0-alpha --locked
Install Pop CLI
Pop CLI provides enhanced developer experience for ink! contracts:
bash brew install r0gue-io/pop/pop
bash wget -q -O - https://sh.pop.r0gue.io/ | bash
bash cargo install --git https://github.com/r0gue-io/pop --branch main
Install ink-node
Download and install the local development node:
# Download the latest release
# Visit: https://github.com/use-ink/ink-node/releases
# Example for macOS (adjust for your platform)
curl -L https://github.com/use-ink/ink-node/releases/latest/download/ink-node-mac-universal.tar.gz | tar xz
# Move to global bin directory
sudo mv ink-node /usr/local/bin/
# Verify installation
ink-node --version
Project Setup
Create New Project
Use the inkathon CLI to scaffold your project:
bunx create-inkathon-app@latest
# Follow the prompts:
# ✔ Project name: my-dapp
# ✔ Initialize git? Yes
# ✔ Install dependencies? Yes
cd my-dapp
Project Structure
Your new project has the following structure:
my-dapp/
├── frontend/ # Next.js application
├── contracts/ # ink! smart contracts
├── docs/ # Documentation
├── package.json # Root package configuration
└── bun.lock # Lock file
Running the Development Environment
Start the Local Node
Open a terminal and run the local ink-node:
# From project root
bun run node
# Or from contracts directory
cd contracts && bun run node
The node will start at ws://127.0.0.1:9944
Build & Deploy Contracts
In a new terminal, build and deploy the example contract:
# Build contracts
bun run -F contracts build
# Generate TypeScript types
bun run codegen
# Deploy to local node
CHAIN=dev bun run -F contracts deploy
Configure Frontend
Update the frontend to connect to your local node:
- Open
frontend/src/lib/reactive-dot/config.ts
- Uncomment the
dev
chain configuration - Open
frontend/src/lib/inkathon/deployments.ts
- Uncomment the
dev
imports and exports
Start Frontend Development
# From project root
bun run dev
# Or run both frontend and node together
bun run dev-and-node
Visit http://localhost:3000 to see your dApp!
Verifying Your Setup
Check Contract Deployment
- Open the frontend at http://localhost:3000
- Connect your wallet (or use development accounts)
- Select "Local Development" network
- You should see the deployed Flipper contract
Test Contract Interaction
- Click on the Flipper contract card
- Read the current value
- Click "Flip" to change the value
- Verify the value changed
Troubleshooting
Next Steps
Now that your local environment is set up:
- Add a custom network to deploy on testnets
- Create a new contract beyond the flipper example
- Explore the frontend components for building your UI
Development Tips
- Use separate terminals: One for the node, one for the frontend
- Watch mode: The frontend auto-reloads on changes
- Check logs: Both node and frontend provide detailed logs
- Use development accounts: Alice, Bob, etc. are pre-funded
- Reset node data: Delete
.node-data
folder to start fresh