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.
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 is a very simple contract that contains a single operation create(…), that creates the instance of TokenVestingFactory.
You can review the smart contract deployed by HUSSY.io here: