A comprehensive smart contract ecosystem for the Built By DAO, featuring upgradeable governance, token economics, and membership management with a complete proxy upgrade system.
The BLTBY ecosystem consists of several interconnected contracts designed for upgradeability, governance, and membership management:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β BLTBY DAO Ecosystem β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π Core Governance Layer β
β βββ Governance (Upgradeable) β Controls proposal system β
β βββ BLTBYToken (Upgradeable) β Voting power & utility β
β βββ TreasuryAndReserve β Treasury management β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β π« Membership & Access Layer β
β βββ GeneralMembershipNFT β Basic membership β
β βββ LeadershipCouncilNFT β Leadership roles β
β βββ AngelNFT β Early investor access β
β βββ VentureOneNFT β Round 1 investors β
β βββ TrustNFT β Institutional access β
β βββ FramerNFT β Early contributor rewards β
β βββ UmbrellaAccessToken β Sub-contract management β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β βοΈ Infrastructure Layer β
β βββ MigrationUpgradeProxy β Upgrade management β
β βββ CustomTransparentProxy β Proxy implementation β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
The system uses OpenZeppelin's transparent proxy pattern with a custom management layer:
Central contract for managing all upgradeable contracts:
- Deploys and manages multiple proxy contracts
- Handles upgrades through ProxyAdmin pattern
- Provides centralized upgrade control
- Maintains proxy and admin mappings
Custom proxy implementation that:
- Accepts admin address directly (avoiding double ProxyAdmin creation)
- Implements transparent proxy pattern correctly
- Ensures proper upgrade mechanism functionality
// 1. Deploy the upgrade management system
MigrationAndUpgradeProxy migrationProxy = new MigrationAndUpgradeProxy(owner);
// 2. Deploy implementation contracts
BLTBYToken implementation = new BLTBYToken();
// 3. Deploy via proxy with initialization
migrationProxy.deployProxy(
address(implementation),
abi.encodeWithSignature("initialize(address)", owner),
"BLTBYToken"
);
// 4. Get proxy address and interact with contract
address proxyAddress = migrationProxy.getProxyAddress("BLTBYToken");
BLTBYToken token = BLTBYToken(proxyAddress);
// 5. Later: Upgrade to new implementation
BLTBYTokenV2 newImplementation = new BLTBYTokenV2();
migrationProxy.upgradeProxy("BLTBYToken", address(newImplementation));Purpose: Core utility and governance token
- Supply: 2.5B total, 100M initial circulation
- Features: Mintable (yearly cap), burnable, pausable, role-based access
- Governance: Used for proposal staking and voting weight
- Upgradeability: Full proxy support with state preservation
Purpose: Decentralized proposal and voting system
- Proposal Types: 3 categories with different approval thresholds (50%, 60%, 65%)
- Voting Power: Based on NFT ownership (membership + investor NFTs)
- Staking Requirement: 2 BLTBY tokens to create proposals
- Leadership Control: Founder directors can veto proposals
- Upgradeability: Maintains proposal history across upgrades
Purpose: Treasury management and token buybacks
- Supported Stablecoins: USDC, USDT, PYUSD
- Functions: Buyback execution, treasury transfers, emergency minting
- Access Control: Owner-only operations
βββ GeneralMembershipNFT (Base tier)
βββ LeadershipCouncilNFT (Leadership roles)
βββ AngelNFT (Early investors)
βββ VentureOneNFT (Round 1 investors)
βββ TrustNFT (Institutional access)
βββ FramerNFT (Early contributors)
- Uniform Interface: All NFTs inherit similar burning/admin patterns
- Role-Based Minting: Specific roles can mint each NFT type
- Governance Integration: NFTs provide voting rights in governance
- Metadata Support: URI-based metadata for each NFT type
Purpose: Factory for creating sub-contract access tokens
- Clone Pattern: Uses OpenZeppelin Clones for gas efficiency
- Approval System: Two-step creation and approval process
- Sub-Contract Types: Gym, Event, Seminar access tokens
- Verification: Built-in validation for sub-contract legitimacy
# Install dependencies
forge install
# Verify compilation
forge build
# Run tests
forge test- Deploy Infrastructure
// Deploy upgrade management
MigrationAndUpgradeProxy migrationProxy = new MigrationAndUpgradeProxy(deployer);- Deploy Core Contracts
// Deploy token
BLTBYToken tokenImpl = new BLTBYToken();
migrationProxy.deployProxy(
address(tokenImpl),
abi.encodeWithSignature("initialize(address)", owner),
"BLTBYToken"
);
// Deploy governance
Governance govImpl = new Governance();
migrationProxy.deployProxy(
address(govImpl),
abi.encodeWithSignature("initialize(address,address,address,address)",
tokenAddress, membershipNFT, investorNFT, owner),
"Governance"
);- Deploy Supporting Contracts
// Deploy NFT contracts
GeneralMembershipNFT membership = new GeneralMembershipNFT(owner);
// ... other NFTs
// Deploy treasury
TreasuryAndReserve treasury = new TreasuryAndReserve(
owner, tokenAddress, usdcAddress, usdtAddress, pyusdAddress
);// 1. Deploy new implementation
BLTBYTokenV2 newImplementation = new BLTBYTokenV2();
// 2. Upgrade via migration proxy
migrationProxy.upgradeProxy("BLTBYToken", address(newImplementation));
// 3. State is automatically preserved// For upgrades requiring additional setup
bytes memory upgradeData = abi.encodeWithSignature("reinitialize(uint256)", newVersion);
migrationProxy.upgradeProxyAndCall("BLTBYToken", address(newImplementation), upgradeData);// 1. Stake required BLTBY tokens (2 BLTBY)
token.approve(governance, 2 * 10**18);
// 2. Create proposal (requires PROPOSER_ROLE)
governance.createProposal("Proposal description", 7 days, categoryType);// Vote using NFT ownership (1 = support, 0 = oppose)
governance.vote(proposalId, nftId, voteChoice);// After voting period + leadership quorum met
governance.resolveProposal(proposalId);The project includes comprehensive test coverage:
- Unit Tests: Individual contract functionality
- Integration Tests: Cross-contract interactions
- Upgrade Tests: Proxy upgrade mechanisms
- Access Control Tests: Permission validation
# Run all tests
forge test
# Run with gas reporting
forge test --gas-report
# Run specific test suite
forge test --match-contract BLTBYTokenTest- Role-based permissions using OpenZeppelin AccessControl
- Multi-signature requirements for critical operations
- Emergency pause functionality for token operations
- Initializer protection prevents double initialization
- Storage gaps reserved for future variables
- State preservation across all upgrades
- Admin controls for upgrade authorization
- Proposal staking prevents spam proposals
- Leadership quorum ensures informed decisions
- Veto powers for founder oversight
- Mint caps prevent inflation attacks
- Clone pattern for sub-contract creation (UmbrellaAccessToken)
- Efficient storage layout in upgradeable contracts
- Minimal proxy overhead with custom implementation
- Batch operations where applicable
$ forge build$ forge test$ forge fmt$ forge snapshot$ anvil$ forge script script/Deploy.s.sol --rpc-url <your_rpc_url> --private-key <your_private_key>$ cast <subcommand>$ forge --help
$ anvil --help
$ cast --help- Fork the repository
- Create feature branch (
git checkout -b feature/amazing-feature) - Write tests for new functionality
- Ensure all tests pass (
forge test) - Submit pull request
This project is licensed under the MIT License - see the LICENSE file for details.
Built by the BLTBY DAO Community ποΈ