This proposal outlines recommended changes to improve the bun-eth repository based on optimizations made in eth-crowdsale, and suggests migrating from a cloning-based approach to GitHub's native template repository feature for create-bun-eth.
Current Issues:
- Contains legacy
HARDHAT_NODEreference - Missing detailed comments for configuration options
- Less organized structure
Proposed Changes:
# From eth-crowdsale/.env.example
# Private Key Configuration
# For local development: Use Anvil's default private key (safe to commit)
# For testnet/mainnet: Replace with your own private key (⚠️ NEVER commit!)
PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
# Foundry Configuration
FOUNDRY_DISABLE_NIGHTLY_WARNING=true
# Sepolia Testnet Configuration (for deployment)
# Get RPC URL from: https://infura.io or https://alchemy.com
SEPOLIA_RPC_URL=
# Get from: https://etherscan.io/myapikey
ETHERSCAN_API_KEY=
# Optional: Multi-chain deployment
BASESCAN_API_KEY=
ARBISCAN_API_KEY=Benefits:
- Clearer documentation for developers
- Better security warnings
- Organized by deployment context
- Removes legacy Hardhat references
Current Version (bun-eth):
contracts:deploy:sepolia:
desc: Deploy contracts to Sepolia testnet
dir: packages/contracts
cmds:
- forge script script/Deploy.s.sol:DeployScript --rpc-url ${SEPOLIA_RPC_URL} --broadcast --verifyProposed Version (from eth-crowdsale):
contracts:deploy:sepolia:
desc: Deploy contracts to Sepolia testnet
dir: packages/contracts
cmds:
- |
if [ -z "$SEPOLIA_RPC_URL" ]; then
echo "❌ Error: SEPOLIA_RPC_URL not set"
echo ""
echo "Quick setup:"
echo " 1. cp .env.example .env"
echo " 2. Add SEPOLIA_RPC_URL to .env"
echo " 3. Add PRIVATE_KEY to .env"
echo ""
echo "See docs/DEPLOYMENT_GUIDE.md for detailed instructions"
exit 1
fi
- |
if [ -z "$PRIVATE_KEY" ]; then
echo "❌ Error: PRIVATE_KEY not set"
echo ""
echo "Add your wallet private key to .env file"
echo "See docs/DEPLOYMENT_GUIDE.md for instructions"
exit 1
fi
- FOUNDRY_DISABLE_NIGHTLY_WARNING=true forge script script/Deploy.s.sol:DeployScript --rpc-url $SEPOLIA_RPC_URL --private-key $PRIVATE_KEY --broadcast --verify --etherscan-api-key ${ETHERSCAN_API_KEY:-}Benefits:
- Prevents cryptic errors when env vars are missing
- Provides helpful setup instructions
- Better developer experience
- Explicit private key usage (more secure)
Files to Update:
apps/api/src/config.ts- Removeprocess.env.HARDHAT_NODEfallback.env.example- RemoveHARDHAT_NODEreference- Documentation - Update all references to use Anvil terminology
Current (bun-eth/apps/api/src/config.ts):
ethNode: process.env.ANVIL_NODE || process.env.HARDHAT_NODE || `http://localhost:${process.env.ANVIL_PORT || "3002"}`,Proposed:
ethNode: process.env.ANVIL_NODE || `http://localhost:${process.env.ANVIL_PORT || "3002"}`,Benefits:
- Clearer that bun-eth is Foundry-first
- Reduces confusion for new developers
- Cleaner codebase
Current Version (bun-eth):
test:watch:
desc: Run tests in watch mode
cmds:
- bun test --watchProposed Version:
test:watch:
desc: Run tests in watch mode
cmds:
- bun test --watch packages/core packages/sdkBenefits:
- More explicit about what's being tested
- Faster feedback during development
- Consistent with main
testtask
Current Issues with Cloning:
-
Brings unnecessary artifacts:
.changeset/directory and configurationCHANGELOG.mdfiles in all packages.task/directory with log files- Template-specific documentation
- Publishing-related files
-
Git history pollution:
- Even with
--depth 1, still brings in initial history - Requires removal of
.gitdirectory - Extra step to initialize new repo
- Even with
-
Slower initialization:
- Full clone even with shallow depth
- More data to download
- Additional cleanup steps required
-
Maintenance overhead:
- Need to manually clean up artifacts
- Risk of leaving template-specific files
- Complex removal logic in CLI
Advantages:
-
Clean slate:
- No git history at all
- Only includes relevant files
- No cleanup needed
-
Native GitHub integration:
- "Use this template" button in UI
- Can work with
create-bun-ethCLI - Better GitHub ecosystem integration
-
Explicit exclusions:
.gitattributescontrols what's templated- Cleaner starting point for users
- Less confusion
-
Faster initialization:
- No git history to download
- Smaller payload
- Quicker setup
Create .gitattributes in bun-eth root:
# Template Configuration
# Files/directories to exclude when using "Use this template"
# Development artifacts
.changeset/** export-ignore
.task/** export-ignore
*.log export-ignore
# Package changelogs (template shouldn't have history)
**/CHANGELOG.md export-ignore
# Publishing & contribution docs (template-specific)
docs/PUBLISHING.md export-ignore
CONTRIBUTING.md export-ignore
# Example-specific documentation (remove project-specific docs)
docs/screenshots/** export-ignore
docs/CROWDSALE_*.md export-ignore
docs/SCREENSHOTS.md export-ignore
docs/STATUS_INDICATORS.md export-ignore
docs/CSS_FIXES.md export-ignore
docs/E2E_TESTS.md export-ignore
docs/DEPLOYMENT_GUIDE.md export-ignore
# Keep these core docs
# docs/ARCHITECTURE.md
# docs/FEATURES.md
# docs/QUICKSTART.md
# README.md- Go to repository settings
- Check "Template repository" option
- Users can now click "Use this template"
Current Approach:
// Clone the template repository
await $`git clone --depth 1 ${REPO_URL} ${targetDir}`;
// Remove .git directory
await $`rm -rf ${join(targetDir, ".git")}`;Proposed Approach:
import { Octokit } from "@octokit/rest";
// Use GitHub's template API
const octokit = new Octokit();
// Generate repository from template
const response = await octokit.repos.createUsingTemplate({
template_owner: "Bun-Eth-Community",
template_repo: "bun-eth",
owner: "user", // or organization
name: projectName,
description: `${typeLabel} - Built with Bun-Eth`,
private: false,
});
// Clone the newly created repo
await $`git clone ${response.data.clone_url} ${targetDir}`;Alternative Simpler Approach (No GitHub API):
// Use degit for template cloning (no git history)
// Install: bun add degit
import degit from "degit";
const emitter = degit("Bun-Eth-Community/bun-eth", {
cache: false,
force: true,
});
await emitter.clone(targetDir);
// Initialize fresh git repo
await $`cd ${targetDir} && git init`;
await $`cd ${targetDir} && git add .`;
await $`cd ${targetDir} && git commit -m "feat: initialize bun-eth project"`;Benefits of degit approach:
- No GitHub API authentication needed
- Respects
.gitattributesexport-ignore - No git history downloaded
- Faster and simpler
- Works offline with cache
.changeset/
.task/
*.log
**/CHANGELOG.md
CONTRIBUTING.md
docs/PUBLISHING.md
# If bun-eth has example-specific docs
docs/screenshots/
docs/*_GUIDE.md (deployment guides for specific examples)
docs/CROWDSALE_*.md (crowdsale-specific docs)
README.md
docs/ARCHITECTURE.md
docs/FEATURES.md
docs/QUICKSTART.md
LICENSE
Consider offering two template variants:
-
Full Template (Current)
- All packages included
- Full documentation
- Example contracts and UI
-
Minimal Template (New)
- Only essential packages
- Minimal documentation
- Empty contracts folder with just basic setup
- Ideal for starting from scratch
Create a README.template.md that replaces README.md when template is used:
# {{PROJECT_NAME}}
> Built with [Bun-Eth](https://github.com/Bun-Eth-Community/bun-eth)
## Quick Start
\`\`\`bash
task setup
task dev:up
task contracts:deploy
\`\`\`
## Documentation
See [Bun-Eth documentation](https://github.com/Bun-Eth-Community/bun-eth) for full details.The improved deployment error handling references docs/DEPLOYMENT_GUIDE.md.
Consider creating this guide in bun-eth with:
- Step-by-step Sepolia deployment
- How to get RPC URLs (Infura, Alchemy)
- How to get Etherscan API keys
- Funding your deployer address
- Verifying contracts
- Multi-chain deployment guide
- Update
.env.examplewith better documentation - Improve
contracts:deploy:sepoliatask with error handling - Remove Hardhat legacy references
- Update
test:watchcommand - Add
DEPLOYMENT_GUIDE.md
- Create
.gitattributeswith export-ignore rules - Enable template repository in GitHub settings
- Test "Use this template" functionality
- Verify excluded files are not copied
- Add
degitdependency - Replace git clone with degit approach
- Update CLI documentation
- Test with both full-stack and backend-only modes
- Verify .gitattributes exclusions work
- Update main README with template approach
- Create migration guide for existing projects
- Update CLI help text
- Publish new version of create-bun-eth
- Announce changes to community
For projects already created with the old approach, provide a migration script:
#!/bin/bash
# scripts/cleanup-template-artifacts.sh
echo "Cleaning up template-specific artifacts..."
# Remove changesets
rm -rf .changeset
echo "✓ Removed .changeset"
# Remove changelogs
find . -name "CHANGELOG.md" -not -path "./node_modules/*" -delete
echo "✓ Removed CHANGELOG.md files"
# Remove task artifacts
rm -rf .task
echo "✓ Removed .task directory"
# Remove publishing docs
rm -f docs/PUBLISHING.md
echo "✓ Removed publishing docs"
echo ""
echo "Cleanup complete!"
echo "Your project is now cleaner and ready for development."- Faster setup: 30-50% faster initialization
- Less confusion: No template artifacts in project
- Clearer errors: Better error messages for deployment
- Better docs: Improved .env and deployment documentation
- Easier updates: Template changes automatically reflected
- Less code: Remove cleanup logic from CLI
- Better structure: Clear separation of template vs. project concerns
- Lower barrier to entry: "Use this template" button
- Professional appearance: Cleaner starting point
- Better adoption: Faster, cleaner setup encourages use
Pros: Less change to existing system Cons: Still downloads unnecessary data, requires maintenance
Pros: Could offer more template variants Cons: More complex to maintain, confusing structure
Pros: Full control over templating Cons: Infrastructure overhead, maintenance burden
Conclusion: GitHub templates + degit provides the best balance of simplicity, speed, and maintainability.
- Review this proposal with maintainers and community
- Create issues for each improvement
- Implement in phases to allow testing and feedback
- Document changes thoroughly
- Communicate updates to existing users
cd packages/create-bun-eth
bun add degit# Test degit approach
bunx degit ../bun-eth test-project
cd test-project
task setup# Check what would be exported
git archive HEAD | tar -tDocument Version: 1.0 Date: 2025-10-09 Author: Bun-Eth Community Status: Proposal - Pending Review