Giter Club home page Giter Club logo

vestingvault-template's Introduction

๐Ÿงญ Table of contents

๐Ÿš€ Quick Start

โœ… Clone or fork vestingVault:

git clone https://github.com/menezesphill/vestingVault.git

๐Ÿ’ฟ Install dependencies with yarn:

cd vestingVault
yarn install

๐Ÿ’ฟ Install truffle for all users:

npm install -g truffle

๐Ÿช™ Vesting Vault

The vesting vault follows a Graded Vesting schedule that gradually grants ownership of a determined ERC20 Token to a grantee. For simplicity, each VestingVault instance can only grant one ERC20 Token that is defined on deployment as an argument to the Smart Constract constructor:

   ERC20 public token;
   
   constructor(ERC20 _token) {
        require(address(_token) != address(0));
        token = _token;
    }

Add Token Grant

There are four important variables that defines how the vesting unlocking will play out: Grantee address, Grant amount, Vesting Cliff and Vesting Duration. These are the arguments used to create a new grant:

   function addTokenGrant(
        address _recipient,
        uint256 _amount,
        uint16 _vestingDurationInDays,
        uint16 _vestingCliffInDays    
    )

The arguments address _recipient, uint256 _amount and _vestingDurationInDays are pretty straight forward. However _vestingCliffInDays can cause some confusion. Lets have a look at the picture below:

Vesting Curve

The Cliff defines when the grant starts to unlock, in our case, this cliff is given in days. _vestingCliffInDays can be Zero, in this case, vesting starts when the grant is created and there is no cooldown time before grantees can start claiming.

Revoke Token Grant

If the vesting authority (contract owner) decides to cancel vesting before _vestingDurationInDays ends. The grant can be revoked by using:

function revokeTokenGrant(address _recipient)

The remaining locked ERC20 Tokens are returned to the contract owner and any unlocked token is sent to address _recipient.

Claim Vested Tokens

If the address calling this method (i.e. msg.sender ) is a grantee recipient, unlocked balanced is sent to msg.sender.

function claimVestedToken()

๐Ÿง† Navigating Truffle

โœ… In case of making any changes to .sol files, you can run:

truffle compile

To update build artifacts;

โœ… Check if the test checklist passes by running:

truffle test

Testing cases are not as extensive as we would like. if you want to contribute creating new test cases, please do so.

โœ… Deploying contracts to local testnet:

There is a portion of the community that might be tempted to use Remix but we are not taking shortcuts. We would like to use a more "Orthodox" approach, if you will. For simplicity we will use Ganache GUI. It can be downloaded here: https://trufflesuite.com/ganache/

Upon starting Ganache, go ahead and QUICKSTART a new network, you will see a window that looks like this:

Make sure to change NETWORK ID and RPC SERVER info in your truffle-config.js file:

  networks: {
     development: {
      host: "127.0.0.1",     // Localhost
      port: 7545,            // Standard Ethereum port
      network_id: "5777",       // Any network
     },
   }

โš ๏ธ ATENTION: If you are using a WSL instance, you might need to configure the correct network on Ganache in order to deploy to the testnet.

When you are good to go, you can go ahead and:

truffle migrate

Now you can also run the tests on your local testnet:

truffle test --network development

And interact with your Smart Contracts from the console:

truffle console

vestingvault-template's People

Contributors

tnkerer avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.