A complete decentralized application (DApp) for creating and managing linear token vesting schedules. This project provides a fully automated pipeline encompassing smart contract compilation, automated deployment, frontend configuration injection, and an intuitive UI dashboard.
- Frontend: Vanilla JavaScript (ES6+), HTML5, CSS3. Fully documented using JSDocs standards in
app.jsfor precise variable mapping and async definitions. - Smart Contracts: Solidity
^0.8.20. Follows CEI (Checks-Effects-Interactions) patterns and employs NatSpec standard documentation. - Backend Framework: Foundry (Forge, Anvil, Cast).
- Libraries: OpenZeppelin Contracts (Security, ERC20, Ownable, ReentrancyGuard). Installed natively using the upgraded
--no-gitforge command in the Makefile. - Testing: 100% coverage with 15 Foundry tests encompassing math validations, temporal logic, and reverts.
Copy the environment template and populate it if needed (not strictly required for local Anvil development).
cp .env.example .envInstall local node modules and Foundry submodules. This resolves missing OpenZeppelin dependencies utilizing the corrected forge install --no-git command.
make setupRun a local Anvil node. This simulates a real blockchain environment with a 1-second block time. Keep this running in a dedicated terminal.
make local-nodeIn a separate terminal, deploy the smart contracts to your local Anvil node. This step automatically compiles the contracts, deploys them, extracts the deployed addresses, and generates a config.js file for the frontend!
make deploy-anvilLaunch the frontend using the localized server:
make serveVisit the displayed localhost URL in your web browser. Make sure you have a Web3 Wallet (like MetaMask) configured to connect to your local Anvil network (http://127.0.0.1:8545, Chain ID: 31337).
This repository features comprehensive, 100% gas-optimized Foundry testing, including math validations for linear vesting fractions, cliff timelines, and deep edge-case revert testing.
To run the entire test suite (15 exhaustive tests):
cd contracts && forge testtest_InitialSupplyMintedToDeployer(): Validates that 1,000,000 VTT tokens are properly minted to the deployer.test_TokenMetadata(): Ensures the ERC20 token correctly binds the name "Vesting Test Token" and symbol "VTT".
- Mathematical Bound Checks: Tests
ClaimTokensExactlyAtCliff(),ClaimTokensHalfway(),ClaimTokensFullDuration(), and incrementalMultipleClaims()leveraging the VM'swarptime-travel feature to test to-the-second accuracy. - Revert Checkpoints: Thoroughly stress tests unauthorized calls,
ZeroAddressallocations,ZeroAmount, missing schedules, andNoReleasableTokensdouble-claim protections.
To deploy to a public testnet like Sepolia:
- Update your
.envfile with yourPRIVATE_KEYand your AlchemySEPOLIA_RPC_URL. - Ensure your wallet has sufficient Sepolia ETH for gas fees.
- Run the automated deployment script targeting Sepolia:
make deploy-sepoliaThe scripts will handle everything and seamlessly sync the newly deployed contract addresses directly to your web interface.
├── index.html # Frontend Viewport
├── app.js # Web3 interaction logic & UI bindings (JSDoc annotated)
├── style.css # Interface styling & themes
├── config.js # Auto-generated runtime configurations
├── package.json # Node dependencies (Local Server)
├── Makefile # Orchestration build runner (Uses --no-git)
├── scripts/
│ └── deploy.sh # Bash deployment engine
└── contracts/ # Foundry Ecosystem
├── foundry.toml # Foundry settings
├── src/
│ ├── MockToken.sol # ERC20 Mock implementation (NatSpec)
│ └── TokenVesting.sol # Core linear vesting logic (NatSpec, Yul Assembly)
├── test/
│ ├── MockToken.t.sol # Metadata and supply tests
│ └── TokenVesting.t.sol# 13 extensive schedule & temporal tests
└── script/
└── DeployVesting.s.sol # Foundry Deployment scripts
The TokenVesting.sol contract incorporates state-of-the-art security features:
- Linear Vesting Mechanics: Releases tokens continuously block-by-block after a cliff.
- Security Checkpoints: Built utilizing OpenZeppelin's
SafeERC20,Ownable, andReentrancyGuardto prevent reentrancy attacks and loss of funds. - Yul Assembly Hashing: Replaces standard
abi.encodewith an optimal inline memorykeccak256assembly routine. - Extensive NatSpec: Fully documented utilizing Ethereum's NatSpec standard for developer tooling visibility.