Factory method pattern for creating Token Vesting smart contracts

We have published a smart contract on Ethereum Blockchain for easier deployment of Token Vesting Contracts for present and future team members and advisors at HUSSY.io. This contract is called TokenVestingFactory and is publicly reviewable at this address. In this article, I describe the implementation details and advantages of this approach.

What is token vesting?

Employees in typical (non-Blockchain) companies are usually paid in regular monthly payments, e.g. 12 times per year. Vesting contracts simplifies this process and allows team members and advisors to be paid in ERC20 tokens in as many payments as they want.

Vesting contract allows to lock any given amount of tokens for any given duration, while only an aliquot part of this total amount is releasable at given time. Token vesting ensures a long-term commitment of people working on a project with more flexibility than common employment contract.

At HUSSY.io, we are using the standard and reliable OpenZeppelin token vesting contract. Source code of this contract is available in the official GitHub repository of the OpenZeppelin project.

Token Vesting schedule of the standard OpenZeppelin Token Vesting Contract.

There are two functions for interaction with the OpenZeppelin TokenVesting smart contract:

  • release(ERC20Basic token) — Releases the releasableAmount of tokens to the beneficiary address. This operation can be executed by anyone.
  • revoke(ERC20Basic token) — Releases the releasableAmount of tokens to the beneficiary address and the remaining unvested tokens are refunded back to the contract owner. This operation can be executed only by the TokenVesting contract owner.

What is the token vesting factory?

Factory is a software design pattern for creating instances of a class. Using this pattern simplifies creating new vesting contracts and saves transaction costs (“gas”). Instead of deploying a new TokenVesting contract for each team member, we deploy a single instance of TokenVestingFactory that ensures the creation of new token vesting contracts.

TokenVestingFactory creates new instances of TokenVesting contract with given parameters (duration, cliff, start date, end date, beneficiary address). Afterwards we can lock any amount of ERC20 tokens to this contract.

TokenVestingFactory is a very simple contract that contains a single operation create(…), that creates the instance of TokenVestingFactory.

Basic TokenVestingFactory with implicitly enabled revocation.

You can review the smart contract deployed by HUSSY.io here:
https://etherscan.io/address/0x3004ee3c5471777c37980030dd9bfc7e5fac503a#code