@the-better-collective/hardhat-template
v2.0.4
Published
A comprehensive Hardhat template with TypeScript, multi-network deployment, example contracts, and complete testing setup for VeChain development
Maintainers
Readme
TBC Hardhat Template Creator
A comprehensive CLI tool for creating new Hardhat projects with The Better Collective's (TBC) template. This tool quickly sets up a complete VeChain development environment with TypeScript, multi-network deployment, example contracts, and comprehensive testing.
✨ Features
- 🚀 Quick project initialization with customizable settings
- 📦 Complete TypeScript setup with proper configurations
- 🌐 Multi-network deployment (Local, Testnet, Mainnet)
- 📝 Example smart contract with comprehensive tests
- 🔧 Environment management with detailed .env.example
- 🧪 Full testing suite with coverage reports
- 📚 OpenZeppelin integration for secure development
- 🎯 VeChain-optimized configurations and scripts
- 📖 Comprehensive documentation and usage examples
Quick Start
Using npx (Recommended)
- Create a new project:
npx @the-better-collective/hardhat-template <project-name>- The tool will automatically:
- Create a new directory with your project name
- Copy all template files to the new project
- Update package.json with your project details
- Create a .env file from the template
Example Usage
# Create a new project called "my-vechain-dapp"
npx @the-better-collective/hardhat-template my-vechain-dapp
# Create a project with spaces (will be normalized to kebab-case)
npx @the-better-collective/hardhat-template "My VeChain DApp"Post-Setup Steps
- Navigate to your project directory:
cd your-project-name- Install dependencies:
npm install
# or
yarn install- Set up environment variables:
# The .env file is already created, just update it with your settings
# Edit .env with your mnemonic and other settings- Start developing:
# Compile contracts
npm run compile
# Run tests
npm run test
# Deploy to local network
npm run deploy:local
# Deploy to testnet
npm run deploy:testnet📁 Project Structure
The template includes a complete, production-ready structure:
your-project/
├── contracts/ # Smart contracts
│ ├── SimpleStorage.sol # Example contract with comprehensive features
│ ├── openzeppelin/ # OpenZeppelin contracts library
│ └── openzeppelin-upgradeable/ # Upgradeable contracts
├── scripts/ # Deployment and utility scripts
│ ├── init/
│ │ └── deploy.ts # Multi-network deployment script
│ └── utils/ # Deployment utilities
├── test/ # Comprehensive test suite
│ └── SimpleStorage.test.ts # Example contract tests
├── hardhat.config.ts # VeChain-optimized Hardhat config
├── tsconfig.json # TypeScript configuration
├── package.json # Scripts and dependencies
├── .env # Environment variables (auto-created)
├── .env.example # Environment variables template
└── README.md # Detailed project documentation⚙️ Configuration
Hardhat Configuration
The template includes a VeChain-optimized hardhat.config.ts with:
- TypeScript support with proper type generation
- Multi-network configurations (Local, Testnet, Mainnet)
- VeChain SDK integration for native VeChain development
- Gas optimization and compiler settings
- OpenZeppelin upgrades plugin support
Environment Variables
The env.example template includes:
MNEMONIC: 12-word mnemonic phrase for wallet derivation- Optional custom RPC endpoints
- Development and debugging settings
- Security guidelines and examples
Pre-configured Networks
- hardhat: Local development network
- vechain_testnet: VeChain Thor Testnet
- vechain_mainnet: VeChain Thor Mainnet
🛠 Available Scripts
Development
npm run compile: Compile smart contractsnpm run test: Run comprehensive test suitenpm run coverage: Generate test coverage reportsnpm run clean: Clean artifacts and generated types
Deployment
npm run deploy:local: Deploy to local Hardhat networknpm run deploy:testnet: Deploy to VeChain Testnetnpm run deploy:mainnet: Deploy to VeChain Mainnet
Network Interaction
npm run node: Start local Hardhat nodenpm run console:local: Interactive console (local)npm run console:testnet: Interactive console (testnet)npm run console:mainnet: Interactive console (mainnet)
📝 Example Contract: SimpleStorage
The template includes a comprehensive SimpleStorage contract that demonstrates:
- State management with private and public variables
- Access control using OpenZeppelin's
Ownable - Events for transparency and off-chain monitoring
- Mappings for user-specific data storage
- Multiple function types (external, view, owner-only)
- Constructor parameters for initialization
- NatSpec documentation for professional code quality
Contract Features
// Store and retrieve values
function storeValue(uint256 _value) external
function getStoredValue() external view returns (uint256)
// Owner-only message management
function updateMessage(string memory _newMessage) external onlyOwner
// User-specific value tracking
function getUserValue(address _user) external view returns (uint256)
// Comprehensive contract information
function getContractInfo() external view returns (uint256, string memory, address)🧪 Testing
The template includes a comprehensive test suite with:
- 143 lines of tests covering all contract functionality
- Event emission testing for proper event handling
- Access control testing for security validation
- Multiple user scenarios for real-world usage
- Edge cases and error conditions for robustness
- TypeScript support with proper type checking
🆕 What's New in v2.0
- ✅ Multi-network deployment with safety warnings
- ✅ Complete example contract with comprehensive tests
- ✅ TypeScript configuration for better development experience
- ✅ Enhanced documentation with step-by-step guides
- ✅ Network-specific scripts for easy deployment
- ✅ Interactive console support for all networks
- ✅ Environment template with security guidelines
- ✅ Production-ready project structure
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
License
This project is licensed under the MIT License - see the LICENSE file for details.
🌟 About The Better Collective (TBC)
The Better Collective is a team of blockchain developers specializing in building secure and scalable smart contract solutions. We focus on creating tools and templates that make blockchain development more accessible and efficient.
📦 Version History
- v2.0.0: Complete overhaul with multi-network deployment, example contracts, comprehensive testing, and enhanced documentation
- v1.0.x: Initial release with basic Hardhat template
🛟 Support
- 📚 Check the generated project's README for detailed usage instructions
- 🐛 Report issues on GitHub
- 💬 Join our community discussions
- 📧 Contact us for enterprise support
🙏 Acknowledgments
- Hardhat for the excellent development framework
- OpenZeppelin for secure smart contract standards
- VeChain for the blockchain platform and tooling
- The blockchain development community for inspiration and feedback
