A fully integrated Avalanche C-Chain development starter built on Scaffold-ETH 2, powered by the Tether Wallet Development Kit (WDK). This starter provides a complete development environment for building dApps on Avalanche Local, Fuji Testnet, and Mainnet.
- β WDK-First Architecture: All blockchain interactions use WDK exclusively (no wagmi/viem/ethers for runtime operations)
- ποΈ Full Avalanche Support: Local node, Fuji Testnet (43113), and Mainnet (43114)
- π Secure Seed Management: Encrypted seed phrase storage with IndexedDB and WebCrypto (AES-GCM)
- π Network Switching: Seamless switching between Local, Fuji, and Mainnet
- πΌ Modern Wallet UI: Beautiful wallet interface with seed export and lock/unlock features
- π― Auto-Unlock in Dev: Automatically unlocks wallet in development mode for better DX
- π Smart Contract Tools: Debug, deploy, and interact with contracts on all networks
- π₯ Hot Reload: Frontend auto-adapts to smart contract changes
- π§± Web3 Components: Pre-built components for Address, Balance, and more
Before you begin, install the following:
- Node.js (>= v20.18.3)
- Yarn v3
- Git
- For Local Node:
- Avalanche CLI (recommended)
- OR Docker (fallback)
macOS:
brew install ava-labs/tap/avalanche-cliLinux:
curl -sSfL https://raw.githubusercontent.com/ava-labs/avalanche-cli/main/scripts/install.sh | sh -syarn installyarn avalanche:upThis will start a local Avalanche C-Chain node at http://127.0.0.1:9650/ext/bc/C/rpc with Chain ID 1337.
Check node status:
yarn avalanche:statusDeploy to local network:
yarn deploy:localDeploy to Fuji testnet:
yarn deploy:fujiNote: For detailed testnet deployment instructions, see the Deploying Smart Contracts to Testnet section below.
Deploy to Mainnet (be careful!):
yarn deploy:mainnetWarning: Only deploy to mainnet after thorough testing on local and testnet environments.
yarn startVisit http://localhost:3000 and navigate to the Avalanche Wallet page to create or import a wallet.
- Go to
/walletpage - Click "Create New Wallet"
- IMPORTANT: Save your seed phrase securely offline
- Check "I have securely saved my seed phrase"
- Your wallet is now active!
- Go to
/walletpage - Click "Import Existing Wallet"
- Enter your 12 or 24-word seed phrase
- Your wallet will be restored
- Use the network dropdown in the header or wallet page
- Switch between Local, Fuji Testnet, and Mainnet
- Your wallet persists across network switches
To test your dApp on Fuji Testnet, you'll need testnet AVAX tokens. Here are the available faucets:
- URL: https://build.avax.network/console/primary-network/faucet
- Requirements: Have an Avax Builder Hub Account
- URL: https://faucets.chain.link/fuji
- Requirements: GitHub or Google account
- Amount: Variable
- URL: https://faucet.quicknode.com/avalanche/fuji
- Requirements: 0.001 ETH on Ethereum Mainnet
- Limit: One drip per network every 12 hours
Note: Testnet AVAX has no monetary value and is only for testing purposes.
Follow these steps to deploy your smart contracts to Avalanche Fuji Testnet:
- Start the frontend application:
yarn start
- Navigate to
http://localhost:3000/walletin your browser - Make sure your wallet is unlocked (create one if you haven't already)
- Click the "Show Private Key" button
- Read the warning message and click "Show Private Key" to confirm
- Copy the private key that appears on the screen
β οΈ Important: Keep this private key secure and never share it with anyone- This private key gives full access to your wallet and funds
Why Step 1? You need the private key to import your WDK wallet account into Hardhat for contract deployment.
- On the
/walletpage, copy your wallet address (displayed at the top of the wallet card) - Switch the network to Fuji Testnet using the network dropdown (if not already on Fuji)
- Visit one of the testnet faucets listed above (e.g., Chainlink Faucet)
- Paste your wallet address and request testnet AVAX tokens
- Wait for the transaction to confirm (usually takes a few minutes)
- Verify you received the tokens by checking your wallet balance on the
/walletpage
Tip: You'll need at least 0.01 AVAX to cover gas fees for contract deployment.
- Open your terminal in the project root directory
- Run the account import command:
yarn account:import
- When prompted, paste your private key (the one you copied from Step 1)
- Create and confirm a password to encrypt your private key
β οΈ Remember this password - you'll need it in Step 4 to deploy
- The encrypted private key will be saved to
packages/hardhat/.envasDEPLOYER_PRIVATE_KEY_ENCRYPTED
Security Note: The private key is encrypted and stored locally. Never commit the
.envfile to version control.
- Make sure your contracts are compiled:
yarn compile
- Deploy to Fuji testnet:
yarn deploy:fuji
- When prompted, enter the password you created in Step 3
- Wait for the deployment to complete
- The script will output the deployed contract address and transaction hash
You can verify your deployment in two ways:
- Copy the transaction hash from the deployment output
- Visit https://subnets-test.avax.network/c-chain
- Paste the transaction hash in the search bar
- View the transaction details, contract address, and verify the deployment
- Go to your
/walletpage in the application - Switch to Fuji Testnet if not already on it
- Your wallet balance should reflect the gas spent on deployment
- You can also check the transaction hash in the explorer to see full deployment details
Error: "insufficient funds for gas"
- Make sure you have enough testnet AVAX in your account (at least 0.01 AVAX)
- Request more tokens from the faucet if needed
Error: "Failed to decrypt private key"
- Make sure you're using the correct password created during
yarn account:import - If you forgot the password, you'll need to re-import the account
Deployment takes too long
- Testnet transactions can sometimes be slow. Wait a few minutes and check the explorer
- If the transaction fails, check the error message and try again
- Seed phrases are encrypted using AES-GCM 256-bit encryption
- Encryption key is stored separately in IndexedDB
- Auto-unlock in development (NODE_ENV=development)
- Manual unlock in production for security
- Export seed phrase with confirmation modal
| Command | Description |
|---|---|
yarn avalanche:up |
Start local Avalanche C-Chain node |
yarn avalanche:down |
Stop local node |
yarn avalanche:status |
Check node status |
yarn avalanche:restart |
Restart local node |
yarn avalanche:clean |
Remove all node data |
| Command | Description |
|---|---|
yarn compile |
Compile smart contracts |
yarn deploy:local |
Deploy to local Avalanche |
yarn deploy:fuji |
Deploy to Fuji testnet |
yarn deploy:mainnet |
Deploy to mainnet |
yarn test |
Run contract tests |
| Command | Description |
|---|---|
yarn start |
Start Next.js dev server |
yarn build |
Build for production |
yarn format |
Format code |
yarn lint |
Lint code |
This starter uses WDK exclusively for all blockchain interactions:
- Wallet Creation:
WDK.getRandomSeedPhrase()andnew WDK(seedPhrase) - Account Management:
wdk.getAccount(chain, index) - Transactions:
account.sendTransaction() - Balance Queries:
account.getBalance() - Contract Interactions: WDK provider + ethers.js for ABI encoding
avax-tether-wdk-starter/
βββ packages/
β βββ hardhat/ # Smart contract development
β β βββ contracts/ # Solidity contracts
β β βββ deploy/ # Deployment scripts
β β βββ scripts/ # Utility scripts
β β βββ test/ # Contract tests
β β
β βββ nextjs/ # Frontend application
β βββ app/ # Next.js pages
β βββ components/ # React components
β β βββ WalletManager.tsx # Main wallet UI
β βββ contexts/ # React contexts
β β βββ WdkContext.tsx # WDK provider
β βββ hooks/ # Custom React hooks
β β βββ scaffold-eth/ # WDK-based hooks
β βββ config/ # Network configurations
β β βββ networks.ts # Avalanche networks
β βββ services/ # Utility services
β β βββ seedVault.ts # Seed encryption
β βββ utils/ # Helper utilities
β
βββ docker-compose.yml # Docker fallback for local node
βββ README.md # This file
import {
useWdkAccount, // Get current account
useWdkSigner, // Get signer for transactions
useWdkNetwork, // Get/switch networks
useWdkBalance, // Get account balance
useWdkProvider // Get raw WDK instance
} from "~~/hooks/scaffold-eth";import {
useScaffoldReadContract, // Read contract state
useScaffoldWriteContract, // Write to contracts
useScaffoldEventHistory // Query contract events
} from "~~/hooks/scaffold-eth";// Read from contract
const { data: greeting } = useScaffoldReadContract({
contractName: "YourContract",
functionName: "greeting",
});
// Write to contract
const { writeContractAsync } = useScaffoldWriteContract({
contractName: "YourContract",
});
await writeContractAsync({
functionName: "setGreeting",
args: ["Hello Avalanche!"],
});Networks are configured in packages/nextjs/config/networks.ts:
{
local: {
chainId: 1337,
rpcUrl: "http://127.0.0.1:9650/ext/bc/C/rpc"
},
fuji: {
chainId: 43113,
rpcUrl: "https://api.avax-test.network/ext/bc/C/rpc"
},
mainnet: {
chainId: 43114,
rpcUrl: "https://api.avax.network/ext/bc/C/rpc"
}
}- Never commit seed phrases or private keys
- Always use test networks for development
- Test thoroughly before deploying to mainnet
- Keep your seed phrase backed up offline
- Use strong passphrases for seed encryption (future feature)
- Verify contract deployments on block explorers
- Encrypted with WebCrypto AES-GCM 256-bit
- Device-specific encryption key in IndexedDB
- Separate storage for encrypted seed and key
- Auto-unlock in dev mode only
- Export requires explicit user confirmation
cd packages/hardhat
yarn testcd packages/nextjs
yarn testCreate a .env.local file in packages/nextjs/:
# Default network (local, fuji, mainnet)
NEXT_PUBLIC_NETWORK=local
# Deployer seed phrase (for contract deployment)
# NEVER commit real seed phrases!
DEPLOYER_SEED_PHRASE=your_test_seed_phrase_hereDeploy to Vercel:
yarn vercel# Compile contracts
yarn compile
# Deploy to Fuji testnet
yarn deploy:fuji
# See the "Deploying Smart Contracts to Testnet" section for detailed steps
# Deploy to Mainnet (requires funded account)
yarn deploy:mainnet
# β οΈ Only use after thorough testing on testnet!For step-by-step testnet deployment instructions, refer to the Deploying Smart Contracts to Testnet section above.
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License.
This starter kit is built with love by Dojo Coding and stands on the shoulders of amazing open source projects:
- Scaffold-ETH 2 - The foundation of this starter kit, created by BuidlGuidl. An incredible toolkit for Ethereum development that we've adapted for Avalanche.
- Tether WDK - The Wallet Development Kit that powers all blockchain interactions in this starter.
- Avalanche - The blazing fast L1 blockchain platform this starter is built for.
We're grateful to the open source community for making projects like this possible. Special thanks to BuidlGuidl for creating Scaffold-ETH 2 and fostering a culture of building in public.
Happy Building on Avalanche! ποΈ