Build an ERC20 dapp with Typink and ink! v6
In this tutorial, we'll guide you through building a complete ERC20 token dapp using Typink with ink! v6 on PolkaVM (pallet-revive). You'll learn how to create, deploy, and interact with an ERC20 token contract, including transfers and real-time event notifications.
What We'll Build:
ERC20 token contract using ink! v6
Token transfer interface with real-time balance updates
Transaction notifications with txToaster
Live Transfer event monitoring with toast notifications
Technologies:
Typink - React hooks for contract interactions
ink! v6 - Latest ink! on PolkaVM (pallet-revive)
POP CLI - Contract development tool
Next.js 15 - Frontend framework
Prerequisites
Node.js v20 or higher
pnpm (or npm/yarn/bun)
Rust and cargo-contract (for contract compilation)
Step 1: Create New Typink Project
Let's start by creating a new project using the Typink CLI:
Follow the interactive prompts:
Project name:
erc20-dappContract type: Select
Ink! v6 (PolkaVM, pallet-revive)Networks: Select
Passet Hub
The CLI will:
Create the project structure
Install dependencies
Setup TypinkProvider with Passet Hub
Initialize git repository
Navigate to your project:
Step 2: Create ERC20 Contract with POP CLI
We'll use POP CLI to create our ERC20 contract. First, install POP CLI if you haven't:
Create a new contract using POP CLI:
When prompted:
Template type:
ERCSelect contract:
erc20Project name:
erc20
This creates an erc20 folder with the ERC20 contract template.
Step 3: Compile the Contract
Navigate to the contract directory and build it:
After successful compilation, you'll find the artifacts in target/ink/:
erc20.contract- Bundle file (metadata + wasm)erc20.json- Contract metadataerc20.wasm- Contract bytecode
Copy these files to your project's contracts folder:
Step 4: Get Testnet Tokens
Before deploying, you'll need PAS testnet tokens on Passet Hub:
Get PAS on Passet Hub:
Request PAS tokens for your Passet Hub wallet address
Step 5: Deploy Contract via ui.use.ink
Now let's deploy the ERC20 contract:
Visit ui.use.ink
Connect Your Wallet:
Click "Connect Wallet"
Select SubWallet, Talisman, or PolkadotJS
Select Network:
Choose "Paseo Asset Hub" from the network dropdown
Upload Contract:
Click "Add New Contract"
Select "Upload New Contract Code"
Upload
erc20.contractfile
Deploy Contract:
Constructor:
newtotal_supply: Enter1000000000000000000000000(1M tokens with 18 decimals)Click "Deploy"
Sign the transaction
Save Contract Address:
After successful deployment, copy the contract address
Example:
0x1234...5678
Step 6: Register Contract Deployment
Update src/contracts/deployments.ts to register your ERC20 contract:
Step 7: Generate TypeScript Bindings
The project includes a pre-configured typegen script. Run it to generate type-safe bindings:
This generates TypeScript types in src/contracts/types/erc20/ including the Erc20ContractApi interface.
Step 8: Display Token Information
Create a new component src/components/erc20-board.tsx:
Update src/app/page.tsx to use the new component:
Start the development server:
Visit http://localhost:3000 and connect your wallet to see your token balance!

Step 9: Create Transfer Form
Now let's add a transfer form. Update src/components/erc20-board.tsx:
The form will look like below:

Step 10: Watch Transfer Events
Let's add real-time Transfer event monitoring with toast notifications. Update src/components/erc20-board.tsx:
The notification appears when the contract emits a Transfer event.

Final Result
Congratulations! You've built a complete ERC20 token dapp with:
✅ Real-time Balance Display - Auto-updates on new blocks
✅ Token Transfer Form - Send tokens to any address
✅ Transaction Notifications - Real-time progress with txToaster
✅ Event Monitoring - Live Transfer event notifications
✅ Type-Safe Interactions - Full TypeScript support
Features Demonstrated
Contract Queries:
useContractQuerywithwatch: truefor real-time updatesAuto-refresh balance after transactions
Contract Transactions:
useContractTxfor sending transferstxToasterfor transaction progress trackingError handling and validation
Event Watching:
useWatchContractEventfor Transfer eventsFiltered notifications for user-relevant events
Real-time balance refresh on events
Resources
Happy Building! 🎉
Last updated
Was this helpful?