Chakoo is a Web3 application starter template that combines a complete frontend development setup with smart contract tooling. It lets you skip the tedious configuration process and focus directly on building your application.
[!IMPORTANT] This project uses the
pnpm workspace
feature to manage the monorepo. Please do not use other tools like npm or yarn.
# Clone the repository
git clone https://github.com/EvaLLLLL/chakoo
# Install dependencies (use pnpm)
pnpm install
# Start development server
pnpm run dev
.vscode/ # VSCode recommended extensions
app/ # Frontend application
└─ src/
└─ components/
├─ WalletConnection.tsx # Connect/disconnect wallet and switch chains
├─ TokenTransaction.tsx # Request tokens from faucet
└─ StorageCURD.tsx # On-chain storage operations
└─ hooks/
└─ contracts/ # Auto-generated contract hooks
├─ token.ts
├─ faucet.ts
└─ storage.ts
contracts/ # Smart contracts
├─ contracts/
│ ├─ Token.sol # Simple token contract
│ ├─ Faucet.sol # Faucet contract
│ ├─ Storage.sol # Storage contract
│ └─ Lock.sol # Hardhat sample contract
├─ ignition/ # Hardhat deployment scripts
└─ test/ # Contract tests
packages/ # Shared packages
├─ lib/ # Shared utilities
├─ typescript-config/ # Shared tsconfig
├─ eslint-config/ # Shared ESLint and Prettier config
├─ tailwind-config/ # Shared Tailwind CSS config
└─ ui/ # Shared UI component library
cd contracts
# Start local blockchain
npx hardhat node
# Test contracts
npx hardhat test
# Deploy contracts
pnpm run deploy
cd app
# Generate React hooks from contract ABIs
pnpm run generate-hooks
import { useReadTokenBalanceOf, useWriteTokenTransfer } from "@/hooks/contracts/token";
export function TokenBalance({ address }: { address: string }) {
// Read hook
const { data: balance } = useReadTokenBalanceOf({
args: [address]
});
// Write hook
const { write: transfer } = useWriteTokenTransfer();
return (
<div>
<p>Balance: {balance}</p>
<button onClick={() => transfer({
args: [recipientAddress, amount]
})}>
Transfer
</button>
</div>
);
}
# Build production
docker compose build --no-cache
# Start in detached mode
docker-compose -f docker-compose.yml up -d
Chakoo's auto-generated React hooks from smart contract ABIs are a key feature. This feature offers:
The generator creates several types of hooks for each contract:
useReadTokenBalanceOf
)useWriteTokenTransfer
)useWatchTokenTransferEvent
)The hook generation is configured in app/wagmi.config.ts
:
import { defineConfig } from '@wagmi/cli'
import { react } from '@wagmi/cli/plugins'
export async function generateConfig() {
// Automatically compile contracts and extract ABIs
execSync('pnpm run compile', { cwd: contractsDir })
const artifactsDir = path.join(contractsDir, 'artifacts/contracts')
const abiInfo: { [key: string]: Abi } = {}
// Generate hooks for each contract
return Object.entries(abiInfo).map(([contractName, abi]) => ({
out: `src/hooks/contracts/${contractName.toLowerCase()}.ts`,
contracts: [
{
name: contractName,
abi: abi
}
],
plugins: [react()]
}))
}
MIT License. See LICENSE for details.