Vesting Smart Contract
Blockchain DevelopmentERC20FoundrySmart Contract
Thursday, July 25, 2024
Vesting Contract: Secure Token Vesting with Role-Based Access Control
Objective:
Developed a robust vesting contract on the blockchain with specific roles and vesting schedules, using Solidity for smart contract development and Foundry for testing and deployment.
Technical Skills and Tools Used:
- Languages: Solidity
- Frameworks/Libraries: OpenZeppelin Contracts, Forge-Std
- Technologies: Ethereum, Foundry, ERC20
Technical Details:
Smart Contract Implementation:
- Solidity: Utilized Solidity to develop the vesting contract, ensuring security and efficiency.
- OpenZeppelin: Leveraged OpenZeppelin's ERC20 and Ownable contracts for token handling and ownership management.
- Foundry: Used Foundry for testing and deployment, ensuring robust contract functionality.
API and Integration:
- Token Transfers: Integrated ERC20 token transfers for claiming vested tokens.
- Event Logging: Implemented event logging for transparency and tracking of vesting activities.

Functionality Overview:
Role-Based Vesting:
Implemented a token vesting system with distinct schedules for three roles: User, Partner, and Team.
- User: Receives 50% of allocated tokens with a 10-month cliff and a 2-year vesting period.
- Partners: Receive 25% of allocated tokens with a 2-month cliff and a 1-year vesting period.
- Team: Receives 25% of allocated tokens with a 2-month cliff and a 1-year vesting period.
Vesting Mechanism:
- Start Vesting: The contract owner can initiate the vesting process.
- Add Beneficiaries: Beneficiaries for each role can be added before vesting starts.
- Token Claiming: Beneficiaries can claim their vested tokens according to their respective schedules.
- Event Tracking: Emits events for vesting start, beneficiary addition, and token withdrawal.


Testing and Validation:
Comprehensive Testing:
Conducted extensive testing using Foundry to ensure the correct implementation of vesting schedules, proper token claiming, and accurate calculation of vested tokens based on cliff and duration.
Test Scenarios:
- Vesting Schedule Creation: Verified the correct creation of vesting schedules by the admin.
- Token Claiming: Ensured beneficiaries could claim tokens according to their schedules.
- Double Claiming Prevention: Implemented checks to prevent beneficiaries from claiming more tokens than allocated.
Project Insights and Achievements:
- Security: Ensured the contract's security by implementing role-based access control and thorough testing.
- Efficiency: Demonstrated efficiency in developing and deploying a complex vesting mechanism on the blockchain.
- Interoperability: Achieved seamless interoperability through a helper configuration that enables deployment to mainnet, testnet, and local environments.
- Streamlined Deployment: Included a Makefile to streamline the deployment process across different networks.

Detailed Breakdown:
Smart Contract Features:
- Role-Based Access Control: Secure management of beneficiaries and token distribution.
- Token Vesting Schedules: Precise implementation of vesting schedules with cliffs and durations.
- Event Emission: Transparent tracking of key contract events.
Testing and Deployment:
- Foundry Testing: Utilized Foundry for comprehensive testing and validation.
- Deployment: Deployed the contract on local and test networks using Foundry.
Overall, the Vesting Contract project provided valuable learning experiences and equipped me with the skills to excel in blockchain software development.