A Bun-first scaffold for Ethereum projects
A pure Bun-native monorepo template for building Ethereum-based applications. Replace scaffold-eth-2's Node/React stack with a modern, TypeScript-first approach using Bun, Elysia, and Foundry.
- π₯ Contract Hot Reload - Your frontend auto-adapts to your smart contracts as you deploy them
- π£ Custom Hooks - Type-safe React hooks for reading, writing, and watching contracts (
@bun-eth/hooks) - π§± Web3 Components - Pre-built UI components for addresses, balances, inputs, and more (
@bun-eth/components) - π° Burner Wallet - Ephemeral wallets for instant testing without MetaMask
- π° Local Faucet - Built-in faucet for quick testing on Anvil
- π RainbowKit - Beautiful wallet connection UI with multi-wallet support
- π Bun-Native - 100% Bun, no Node.js required - lightning fast builds
- β‘ Elysia Backend - Fast, TypeScript-first web framework for REST API
- π¨ Next.js Frontend - Modern React framework with shadcn/ui components
- π¨ Foundry Contracts - Blazing fast Rust-based smart contract framework (Forge + Anvil)
- π³ Docker Compose - Complete local development environment
- π¦ Clean Monorepo - Well-architected packages with clear separation of concerns
- π§ͺ Comprehensive Testing - Multi-layer E2E testing (visual regression, accessibility, performance, responsive), Bun tests for TypeScript, Foundry tests for Solidity
- π¨ Biome Linting - Fast, Bun-native linting and formatting (10-100x faster than ESLint)
- π§ Forge Formatting - Built-in Solidity formatting and linting
- π Taskfile - Powerful command orchestration
- π Full TypeScript - Type safety from contracts to UI
bunx create-bun-eth@latest my-dapp
cd my-dapp
task setupThe CLI will:
- Download the latest template (without git history)
- Let you choose between Full-Stack or Backend-Only
- Set up your project name
- Initialize a fresh git repository
Click the "Use this template" button at the top of the repository to create your own copy.
Then:
git clone https://github.com/YOUR_USERNAME/your-project.git
cd your-project
task setupgit clone https://github.com/Bun-Eth-Community/bun-eth.git my-dapp
cd my-dapp
task setupThe setup task will:
- Create
.envfrom.env.example - Install all dependencies
- Compile smart contracts
- Run all tests to verify everything works
- Bun >= 1.1.0
- Foundry (for smart contracts)
- Docker (for local Ethereum node)
- Task (optional, for orchestration)
# macOS
brew install go-task
# Linux
sh -c "$(curl --location https://taskfile.dev/install.sh)" -- -d -b ~/.local/bin
# Or use bunx
bunx @go-task/clibun-eth/
βββ apps/
β βββ api/ # Elysia backend API
β β βββ src/
β β β βββ index.ts # API entry point
β β β βββ config.ts # Configuration
β β β βββ provider.ts # Ethereum provider setup
β β β βββ routes/ # API routes
β β βββ Dockerfile
β βββ web/ # Next.js frontend
β βββ src/
β β βββ app/ # App router pages
β β βββ components/ # Local components
β β βββ lib/ # Utilities & wagmi config
β βββ package.json
βββ packages/
β βββ contracts/ # Smart contracts (Foundry)
β β βββ contracts/ # Solidity files
β β βββ script/ # Deploy scripts
β β βββ test/ # Foundry tests
β β βββ deployedContracts.ts # π₯ Auto-generated (hot reload!)
β β βββ foundry.toml
β βββ hooks/ # π£ React hooks for Web3
β β βββ src/
β β βββ useScaffoldContract.ts
β β βββ useScaffoldReadContract.ts
β β βββ useScaffoldWriteContract.ts
β β βββ ... # 10+ hooks
β βββ components/ # π§± Web3 UI components
β β βββ src/
β β βββ Address.tsx
β β βββ Balance.tsx
β β βββ Faucet.tsx
β β βββ ... # 10+ components
β βββ foundry-deployer/ # π₯ Hot reload system
β β βββ src/
β β βββ generator.ts # Generates deployedContracts.ts
β β βββ cli.ts # CLI tool
β βββ core/ # Shared utilities
β βββ sdk/ # TypeScript SDK for API
β βββ create-bun-eth/ # Scaffolding CLI
βββ tooling/
β βββ task/
β βββ Taskfile.yml # Task definitions
βββ docker/
βββ docker-compose.yml # Anvil + API + Web
task dev:upThis starts:
- Anvil local Ethereum node on
http://localhost:3002 - Bun-Eth API on
http://localhost:3001
task web:devThis starts the Next.js frontend on http://localhost:3000
task dev:down# All services
task dev:logs
# API only
task dev:logs:api
# Anvil node only
task dev:logs:anviltask contracts:compile# Deploy to local network
task contracts:deploy
# Deploy to Sepolia
task contracts:deploy:sepoliatask contracts:testBase URL: http://localhost:3001
GET /healthResponse:
{
"status": "ok",
"timestamp": 1234567890,
"version": "0.1.0",
"network": {
"chainId": 31337,
"blockNumber": 42
}
}GET /wallet/:addressResponse:
{
"address": "0x...",
"balance": "10.5",
"nonce": 5
}POST /wallet/send
Content-Type: application/json
{
"to": "0x...",
"value": "1.0",
"data": "0x..."
}POST /contract/call
Content-Type: application/json
{
"contractAddress": "0x...",
"method": "retrieve",
"args": []
}POST /contract/send
Content-Type: application/json
{
"contractAddress": "0x...",
"method": "store",
"args": [42],
"value": "0"
}The Next.js frontend includes:
- shadcn/ui - Beautiful, accessible components built on Radix UI
- wagmi - React Hooks for Ethereum
- viem - TypeScript Ethereum library
- Tailwind CSS - Utility-first CSS framework
# Start development server
task web:dev
# Build for production
task web:build
# Start production server
task web:startThe frontend supports:
- MetaMask and other injected wallets
- WalletConnect for mobile wallets
- Automatic network switching
- Real-time blockchain data updates
task test# Contract tests
task test:contracts
# API tests
task test:api
# SDK tests
task test:sdk
# Core tests
task test:coreThe template includes a comprehensive E2E testing suite covering multiple quality dimensions:
# Run complete E2E test suite (all layers)
task test:e2e:complete
# View results
cd apps/web && bunx playwright show-report# Visual regression testing (screenshot comparison)
task test:e2e:visual
# Accessibility testing (WCAG 2.1 AA compliance)
task test:e2e:accessibility
# Performance testing (load times, bundle sizes)
task test:e2e:performance
# Responsive design testing (multiple viewports)
task test:e2e:responsive
# Generate UI screenshots for documentation
task test:e2e:screenshots# Web app e2e tests (with webServer)
task test:e2e
# Run e2e tests in UI mode
task test:e2e:ui
# Template creation e2e tests (validates the entire CLI workflow)
task test:e2e:template
# Run all tests (unit + contracts + e2e + template e2e)
task test:all- Visual Regression - Automatic screenshot comparison to detect UI changes
- Accessibility - WCAG 2.1 AA compliance testing with axe-core
- Performance - Load time metrics, bundle size analysis, LCP/FCP tracking
- Responsive Design - Cross-device testing (mobile, tablet, desktop)
- RPC Mocking - Test contract states without real transactions
- Time Manipulation - Test time-dependent contracts with Anvil
Test Results:
- Screenshots saved to
docs/screenshots/ - Test reports saved to
docs/test-results/ - Accessibility violations logged with actionable fixes
- Performance metrics tracked over time
Documentation:
- See docs/E2E_TESTING_GUIDE.md for detailed guide
- Examples of all test types included
- Integration with CI/CD pipelines
task test:watchtask test:coverageThe project uses Biome for TypeScript/JavaScript linting and Forge for Solidity formatting.
Biome is a fast, Bun-native linter and formatter that replaces ESLint and Prettier:
- β‘ 10-100x faster than ESLint
- π¦ Rust-based - Native performance
- π― Zero config - Works out of the box
- π§ Auto-fix - Automatically fixes issues
- π¦ Single tool - Replaces ESLint + Prettier
# Lint all packages (TypeScript + Solidity)
task lint
# Lint and auto-fix TypeScript issues
task lint:fix
# Lint Solidity contracts
task contracts:lint
# Format Solidity contracts
task contracts:format# Lint specific package
cd packages/core
bun run lint
# Auto-fix issues
bunx biome check --write .
# Unsafe auto-fix (includes recommended changes)
bunx biome check --write --unsafe .# Check Solidity formatting
cd packages/contracts
forge fmt --check
# Format Solidity files
forge fmtAll linting is enforced in GitHub Actions:
- Biome checks all TypeScript/JavaScript files
- Forge checks all Solidity files
- Pull requests must pass linting to merge
- Biome:
biome.jsonat project root - Forge:
packages/contracts/foundry.toml(see[fmt]section)
Install in your project:
bun add @bun-eth/sdkUsage:
import { createClient } from "@bun-eth/sdk";
const client = createClient({
baseUrl: "http://localhost:3001",
timeout: 30000,
});
// Check health
const health = await client.health();
// Get wallet info
const wallet = await client.getWallet("0x...");
// Send transaction
const tx = await client.sendTransaction({
to: "0x...",
value: "1.0",
});
// Call contract
const result = await client.contractCall({
contractAddress: "0x...",
method: "retrieve",
args: [],
});Copy .env.example to .env and configure:
# Port Configuration (consecutive ports for easy management)
WEB_PORT=3000
API_PORT=3001
ANVIL_PORT=3002
# API Configuration
PORT=3001
NODE_ENV=development
# Ethereum Node
ANVIL_NODE=http://localhost:3002
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
# Network Configuration
CHAIN_ID=31337
# Frontend (Optional)
NEXT_PUBLIC_WC_PROJECT_ID= # WalletConnect Project IDEdit packages/contracts/foundry.toml:
[rpc_endpoints]
localhost = "http://127.0.0.1:8545"
sepolia = "${SEPOLIA_RPC_URL}"After running task dev:up and task contracts:deploy, use the new packages:
// In your component
import { useScaffoldReadContract, useScaffoldWriteContract } from "@bun-eth/hooks";
import { Address, Balance, FaucetButton, BurnerWalletInfo } from "@bun-eth/components";
import { useAccount } from "wagmi";
function MyDApp() {
const { address } = useAccount();
// Read contract state - auto-refreshes on new blocks
const { data: value } = useScaffoldReadContract({
contractName: "SimpleStorage",
functionName: "retrieve",
watch: true,
});
// Write to contract - includes notifications
const { writeContractAsync, isMining } = useScaffoldWriteContract("SimpleStorage");
const handleStore = async () => {
await writeContractAsync("store", [42]);
};
return (
<div>
{/* Show burner wallet info if using burner */}
<BurnerWalletInfo />
{/* Display address with ENS */}
<Address address={address} format="short" />
{/* Balance with USD toggle */}
<Balance address={address} usdMode />
{/* Faucet for test ETH */}
<FaucetButton />
{/* Contract interaction */}
<p>Stored Value: {value?.toString()}</p>
<button onClick={handleStore} disabled={isMining}>
{isMining ? "Mining..." : "Store 42"}
</button>
</div>
);
}Run task --list to see all available commands.
# Setup - Complete local setup with tests
task setup
# Start - Quick start dev stack (install, compile, start services)
task start
# Development
task dev:up # Start local development stack (Anvil + API + Web)
task dev:down # Stop local development stack
task dev:logs # View logs from all services
# Frontend
task web:dev # Start Next.js dev server
task web:build # Build Next.js for production
task web:start # Start Next.js production server
# Contracts
task contracts:compile # Compile smart contracts
task contracts:deploy # Deploy to local network + generate types (π₯ hot reload)
task contracts:generate # Generate TypeScript from deployed contracts
task contracts:test # Run contract tests
task contracts:lint # Check Solidity formatting
task contracts:format # Format Solidity files
# Testing
task test # Run all tests
task test:core # Run core utility tests only
task test:sdk # Run SDK tests only
task test:contracts # Run contract tests only
# Code Quality
task lint # Lint all packages (TypeScript + Solidity)
task lint:fix # Lint and auto-fix TypeScript issues
# Other
task clean # Clean build artifacts
task status # Show development stack status
task check:health # Check API healthSee DEPLOYMENT_GUIDE.md for detailed instructions.
Quick start for Sepolia:
- Configure
.env:
cp .env.example .env
# Add SEPOLIA_RPC_URL, PRIVATE_KEY, and ETHERSCAN_API_KEY- Deploy:
task contracts:deploy:sepoliaBuild and run with Docker:
docker build -f apps/api/Dockerfile -t bun-eth-api .
docker run -p 3001:3001 --env-file .env bun-eth-apiContributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Commit your changes:
git commit -m 'feat: add my feature' - Push to the branch:
git push origin feature/my-feature - Open a Pull Request
- E2E_TESTING_GUIDE.md - Comprehensive E2E testing guide
- IMPROVEMENTS_SUMMARY.md - Latest improvements and features
- DEPLOYMENT_GUIDE.md - Deploy to testnets and mainnet
- FEATURES.md - Complete feature list and comparisons
- ARCHITECTURE.md - System design and architecture
- packages/hooks/README.md - Custom hooks documentation
- packages/components/README.md - UI components guide
- packages/foundry-deployer/README.md - Hot reload system
- packages/burner-connector/README.md - Burner wallet connector
- Foundry Book - Learn Foundry
- Viem Docs - TypeScript Ethereum library
- Wagmi Docs - React Hooks for Ethereum
- RainbowKit Docs - Wallet connection UI
- Scaffold-ETH 2 - Original inspiration
MIT License - see LICENSE file for details
- Bun - The blazingly fast JavaScript runtime
- Elysia - Fast and ergonomic TypeScript web framework
- Foundry - Blazing fast Ethereum development toolkit
- scaffold-eth-2 - Inspiration for features
- wagmi + viem - Modern Ethereum libraries
- RainbowKit - Beautiful wallet UX
- π Documentation
- π Issue Tracker
- π¬ Discussions
Built with β‘ by the Bun-Eth community