🌳
Bonsai Docs
  • Introduction
    • Bonsai
    • What is Smart Media?
  • Platform
    • No-code creator studio
    • Guide: Create a post
  • Smart Media
    • Framework for builders
  • Building Smart Media
    • ElizaOS server setup
    • Bonsai Client
    • Templates
  • Guide: Create a Template
  • Client Integrations
    • Showing whether a post is Smart Media
    • Linking to Bonsai for remixes
    • Creating a smart media post
  • Actions
    • Reward Swap
  • Launchpad
    • Overview
    • Getting Started
    • Launchpad Contract
    • Vesting ERC20 Contract
    • Hooks
    • API
      • Tokens
      • Token Balances
      • Buy / Sell Quotes
      • Link your token to a Lens Post & Account
  • ElizaOS
    • plugin-bonsai-launchpad
    • client-lens
Powered by GitBook
On this page
  1. Launchpad

Vesting ERC20 Contract

Custom ERC20 contract for automatic vesting

PreviousLaunchpad ContractNextHooks

Last updated 29 days ago

The VestingERC20 contract allows new tokens to be deployed with some simple vesting terms to reduce the impact of new supply entering the market after graduation or allow for projects to use the platform for ICOs.

When a token is created from the Launchpad it is non-transferrable. Whenever new tokens are bought they are minted and burned when they are sold. Once the token supply hits 800 million the token is considered graduated and liquidity can be released to Uniswap. Once liquidity is released tokens are unlocked according to the vesting schedule they were created with.

The contract takes two arguments for vesting when instantiated:

  1. cliffPercent: the percent of tokens that are available immediately upon liquidity release.

  2. vestingDuration: the number of seconds over which the remaining tokens will become available, unlocking linearly.

No claims are required, all tokens are in your wallet and the contract automatically checks how many tokens you have available and will simply revert if you try to send a transaction with more than the available amount.

Contract Reference

The contract follows the ERC20 standard with a few differences.

constructor: takes the args used to set the vesting terms and Launchpad address - used to trigger vesting start.

    constructor(
        address _launchpad,
        string memory name,
        string memory symbol,
        string memory _uri,
        uint256 _cliffPercent,
        uint256 _vestingDuration
    ) SolmateERC20(name, symbol, 18)

getAvailableBalance: returns all tokens that can be transferred. This is equal to all non-vested tokens plus the tokens that have finished vesting. This check is used in transferand transferFromfunctions to ensure that a transfer for more tokens than are available will revert.

function getAvailableBalance(address user) public view returns (uint256)

You can view a verified VestingERC20 token contract on Lens Chain here