Distribute tokens over time according to a configurable vesting schedule
A vesting schedule policy that manages token distribution over time with a 12-month cliff followed by continuous release for the remaining 3 years. This is accomplished by enforcing a minimum balance on the wallet consistent with the unvested amount remaining.
The policy above contains some pre-populated values in the mapped trackers to enable testing out the policy. The wallets used match the first 3 wallets in a local anvil chain. Replace these with dev wallets you control when testing on mainnet or testnet.
Looking at the table above we can expect the first 0xf39Fd... wallet to be able to transfer about 25% of the tokens (assuming the date is January 15, 2026).The 0x7099... wallet is still in the initial 12 month cliff and cannot make any transfers that would drop the balance below 1000 tokens.Finally, the 0x3C44... wallet has completed the vesting period and can transfer all of it’s tokens w/o restrictions.
The above policy relies on two extra values to perform the logic that controls the vesting schedule. These are sender (msg.sender) and senderBalance. Having these available to the Rules Engine requires a few minor adjustments to the token contract.Below you can see the transfer function is also passing the balance and msg.sender to the modifier, which then passes it on to the Rules Engine.
Copy
Ask AI
function transfer( address to, uint256 value ) public override checkRulesBeforeTransfer(to, value, balanceOf(msg.sender), msg.sender) returns (bool) { return super.transfer(to, value); }
You also need to protect the transferFrom function to ensure users can not circumvent the
vesting schedule with that function. The demo repo below contains examples of this, which are left
out here for brevity.
To set up vesting for an investor, you’ll need to populate the mapped trackers.If you already know the vesting amounts and wallets upfront, you could include them in the initial policy setup. The more likely scenario is that you’ll deploy the token and policy first, and then configure the vesting details post token deployment.
add amount and start to the policy
actually mint the tokens to the wallets
To update the mapped trackers in your policy, you can do the following:
You can later add new vesting allotments in the future by adding new keys to the mapped tracker. Using the same approach as above.It is possible to edit a previously entered vesting allotment by submitting the same key with a new value. If the key is not matched, then it will be added to the existing set.