-
2.2 Rationale
2.3 Technology Stack
-
3.3 Upgradability
-
4.1 Smart Contract Specifications
4.3 Gas Optimization
-
5.1 User Roles
5.2 Utility Provided
The Vault Hill Token (VHT) project represents a significant evolution in blockchain-based utility tokens, designed to surpass the limitations of its predecessor, the VHC token. While the VHC token was primarily focused on the Vault Hill City metaverse, VHT expands its utility to encompass a broader ecosystem of decentralized applications and services.
Key Improvements and Features:
-
Enhanced Flexibility: VHT is engineered to be a versatile utility token, capable of seamlessly integrating with various decentralized platforms beyond just the metaverse context. This increased adaptability opens up new use cases and potential partnerships.
-
Advanced Token Economics: Leveraging cutting-edge smart contract capabilities, VHT introduces dynamic minting and burning mechanisms. These features allow for more sophisticated token supply management, potentially leading to better value stability and growth opportunities.
-
Improved Scalability: Built on the Thirdweb framework, VHT incorporates state-of-the-art scalability solutions, ensuring lower transaction costs and faster processing times compared to its predecessor.
-
Enhanced Security: VHT employs the latest in smart contract security practices, including upgradability features that allow for continuous improvement and rapid response to potential vulnerabilities or changing market conditions.
-
Expanded Utility: Beyond basic transfer and storage of value, VHT introduces advanced features such as delegated transfers, batch transactions (multicall capabilities), and metadata management, enhancing its utility in complex DeFi and Web3 ecosystems.
-
Governance Ready: While maintaining centralized control for initial stability, VHT's architecture is designed with future decentralization in mind, potentially allowing token holders to participate in ecosystem governance.
-
Cross-Platform Compatibility: Unlike the VHC token, VHT is designed with cross-chain functionality in mind, paving the way for interoperability with various blockchain networks and expanding its reach beyond a single ecosystem.
-
Improved Developer Experience: With comprehensive documentation and standardized interfaces, VHT makes it easier for developers to integrate the token into new projects and applications, fostering a growing ecosystem of VHT-powered solutions.
By leveraging the Thirdweb framework and incorporating various extensions, VHT aims to position itself as a next-generation utility token. It not only addresses the limitations of the VHC token but also sets a new standard for flexibility, security, and functionality in the rapidly evolving blockchain space.
The primary goals of this project are:
- Implement a secure and standards-compliant ERC20 token with advanced features
- Provide sophisticated minting and burning capabilities for dynamic supply management
- Ensure upgradability to accommodate future improvements and market demands
- Optimize for gas efficiency and user experience across various blockchain environments
- Implement robust security measures to protect user assets and maintain trust
- Create a token ecosystem that extends far beyond the original metaverse use case, opening up new opportunities for users, developers, and partners
The project consists of three main contracts:
-
VHTContractBase:
- Implements the ERC20 standard
- Handles basic token functionalities:
- Balance management
- Allowance system
- Token metadata (name, symbol, decimals)
-
VHTContractImpl:
- Extends VHTContractBase
- Implements additional functionalities:
- Minting tokens
- Burning tokens
- Incorporates Upgradeable and Initializable patterns
-
VHTContractProxy:
- Acts as a proxy for the implementation contract
- Enables upgradability without state loss
- Delegates calls to the implementation contract
The chosen architecture offers several benefits:
- Upgradability: The proxy pattern allows for contract upgrades without requiring users to migrate to a new contract address.
- Separation of Concerns: By separating the logic (VHTContractImpl) from the state (VHTContractProxy), the system becomes more modular and easier to maintain.
- Extensibility: The use of Thirdweb's extensions provides built-in functionalities that can be easily integrated and expanded upon.
- Standards Compliance: Adhering to the ERC20 standard ensures compatibility with existing wallets and exchanges.
- Solidity: The primary language for smart contract development
- Thirdweb Framework: Provides pre-built contract extensions and development tools
- OpenZeppelin: Offers secure, tested, and community-audited smart contract components
- Forge: Development environment for compiling, testing, and deploying smart contracts
- Ethers.js: JavaScript library for interacting with the Ethereum blockchain
-
Token Metadata:
- Name: Vault Hill Token
- Symbol: VHT
- Decimals: 18
-
Basic ERC20 Functions:
balanceOf(address account)
: Returns the token balance of an accounttransfer(address recipient, uint256 amount)
: Transfers tokens to a specified addressapprove(address spender, uint256 amount)
: Approves an address to spend tokens on behalf of the ownertransferFrom(address sender, address recipient, uint256 amount)
: Transfers tokens on behalf of an approved spendertotalSupply()
: Returns the total supply of tokens
-
Minting:
mintTo(address to, uint256 amount)
: Mints new tokens to a specified address- Restricted to authorized minters
-
Burning:
burn(uint256 amount)
: Burns tokens from the caller's balanceburnFrom(address account, uint256 amount)
: Burns tokens from a specified account (requires approval)
-
Ownership Management:
transferOwnership(address newOwner)
: Transfers contract ownershiprenounceOwnership()
: Renounces contract ownership
-
Metadata Management:
setContractURI(string memory _uri)
: Sets the contract metadata URI
-
Role Management:
grantRole(bytes32 role, address account)
: Grants a role to an accountrevokeRole(bytes32 role, address account)
: Revokes a role from an account
- Proxy Upgrade:
upgradeTo(address newImplementation)
: Upgrades the implementation contractupgradeToAndCall(address newImplementation, bytes memory data)
: Upgrades the implementation and calls a function
- Solidity Version: ^0.8.0
- EVM Compatibility: Ethereum mainnet and compatible sidechains/L2 solutions
- Contract Size: Must not exceed 24KB (Ethereum contract size limit)
- State Variables: Minimize the number of storage variables to reduce gas costs
- Access Control: Implement role-based access control for administrative functions
- Integer Overflow/Underflow: Utilize Solidity 0.8.x's built-in overflow checks
- Event Emission: Emit events for all state-changing functions to facilitate off-chain tracking
- Efficient Storage: Use appropriate data types to minimize storage costs
- Batched Operations: Implement multicall functionality for gas-efficient batch transactions
- Minimize External Calls: Reduce the number of external contract calls to save gas
- Token Holders: Users who own and transact with VHT tokens
- Contract Administrators: Users with privileged access to manage the contract
- Minters: Authorized addresses that can mint new tokens
- Token Transactions: Transfer and receive VHT tokens
- Supply Management: Mint new tokens or burn existing ones
- Allowance System: Approve other addresses to spend tokens on behalf of the owner
- Metadata Access: Retrieve token and contract metadata
-
Minting:
- Function:
mintTo(address to, uint256 amount)
- Description: Mints a specified amount of tokens to the given address
- Function:
-
Burning:
- Function:
burn(uint256 amount)
- Description: Burns a specified amount of tokens from the caller's balance
- Function:
-
Transfer:
- Function:
transfer(address to, uint256 amount)
- Description: Transfers tokens from the caller's address to another address
- Function:
-
Allowance Management:
- Functions:
approve(address spender, uint256 amount)
transferFrom(address from, address to, uint256 amount)
- Description: Allows users to approve another address to spend tokens on their behalf
- Functions:
-
Multicall:
- Function:
multicall(bytes[] calldata data)
- Description: Executes multiple function calls in a single transaction
- Function:
- Unit Testing: Comprehensive test suite covering all contract functions
- Integration Testing: Tests for interaction between different contract components
- Gas Consumption Analysis: Monitoring and optimization of gas usage for all functions
- Security Audits: Third-party security audit to identify and mitigate vulnerabilities
- Formal Verification: Consider formal verification of critical contract components
-
Deployment Process:
-
Step 1: Deploy
VHTContractBase
-
Step 2: Deploy
VHTContractImpl
withVHTContractBase
as the base -
Step 3: Deploy
VHTContractProxy
with the implementation address ofVHTContractImpl
-
Step 4: Initialize the proxy contract with token parameters
Commands:
npm run deploy <thirdweb-secret-key> # or yarn deploy <thirdweb-secret-key>
-
-
Upgrade Process:
- Deploy new implementation contract
- Call
upgradeTo
on the proxy contract
-
Release Process:
- Description: To release a version of the contracts publicly, use one of the following commands:
- Commands:
npm run release # or yarn release
This technical and functional requirements document outlines the comprehensive plan for developing the Vault Hill Token (VHT) smart contract system. By adhering to these specifications, the project aims to deliver a secure, efficient, and flexible token solution that meets the needs of users and administrators while maintaining the ability to adapt to future blockchain developments.