This project implements a smart contract for time-based vesting of ERC20 tokens. It allows a payer to deposit tokens into the contract, which are then gradually unlocked for withdrawal by a designated receiver over a specified period.
- Single payer deposits ERC20 tokens
- Tokens are unlocked linearly over a specified number of days
- Receiver can withdraw unlocked tokens daily
- Immutable vesting schedule once deposit is made
- Prevents over-withdrawal of tokens
- Solidity 0.8.25
- OpenZeppelin Contracts library
- Foundry
-
Clone the repository:
git clone https://github.com/yourusername/erc20-vesting-contract.git
-
Install dependencies:
forge build
- Deploy the VestingContract to your chosen network.
- Call the
deposit
function as the payer to initiate the vesting schedule. - The receiver can call
withdraw
function to claim unlocked tokens.
Run the test suite:
forge test
- The contract has been designed with security best practices in mind.
- Follow CEI (Checks-Effects-Interactions) pattern to prevent reentrancy.
- Careful consideration has been given to prevent precision loss in calculations.
- Proper checks are implemented for amounts and time-based conditions.
Contributions are welcome! Please feel free to submit a Pull Request.
This smart contract is provided as-is. Users should conduct their own security audit before using it in a production environment.