Sub topic 11
How vesting contracts work on-chain
This chapter assumes you have read the earlier chapters on vesting terms (cliffs, linear release, TGE unlocks) and unlock events. It also assumes you can read short Python functions and know what a smart contract and an ERC-20 token are. You do not need to write Solidity.
An off-chain vesting schedule is a promise in a legal agreement. An on-chain vesting contract is that promise turned into code, with tokens held by the contract. This chapter covers how the contract works internally, which variants exist, and which properties decide whether the schedule can be trusted. The next chapter uses these properties to verify schedules against public data.
What a vesting contract actually does
A vesting contract is a smart contract that holds tokens for a beneficiary and lets the beneficiary withdraw them according to a formula. It has three parts:
- Custody. The contract's address holds the tokens. Nobody, including the team, can move them except through the contract's functions.
- A schedule. The contract stores a few parameters: a start time, a cliff, a duration, and sometimes a TGE amount. The formula is the same cliff-plus-linear function from the vesting chapter.
- A release function. The beneficiary (or anyone, on the beneficiary's behalf) calls it. The contract computes how much has vested, subtracts what was already paid, and transfers the difference.
The contract does not push tokens out on a timer. Smart contracts only run when a transaction calls them. Between calls, tokens that have vested but not been claimed stay in the contract. This matters for supply data, as the section on unlock events below explains.
The core accounting identity
Most vesting contracts, including the widely used OpenZeppelin VestingWallet, rely on one identity:
releasable(now) = vested(now) - releasedvested(now) is a pure function of time and the total allocation. released is a counter that the contract increments on every payout. Because vested is cumulative, the contract needs no record of past claims beyond that one counter. A beneficiary who claims every day and one who claims once a year receive the same total by the same date.
The total allocation is usually computed as balance + released. The contract does not store a fixed number. It measures whatever it currently holds plus whatever it has already paid out. This has a consequence: tokens sent to the contract later are also treated as part of the vested pool, and the schedule applies to them retroactively.
Here is that logic in Python. It mirrors the contract's integer arithmetic.
class VestingWallet:
"""Cliff + linear vesting, modelled on an on-chain wallet.
Times are in months; amounts are whole tokens (integer math)."""
def __init__(self, balance, start, cliff, duration):
self.balance = balance # tokens currently held by the contract
self.released = 0 # running total already paid out
self.start = start
self.cliff = cliff
self.duration = duration
def vested_amount(self, now):
total = self.balance + self.released
if now < self.start + self.cliff:
return 0
if now >= self.start + self.duration:
return total
return total * (now - self.start) // self.duration
def releasable(self, now):
return self.vested_amount(now) - self.released
def release(self, now):
amount = self.releasable(now)
self.balance -= amount
self.released += amount
return amount
def deposit(self, amount):
self.balance += amount
wallet = VestingWallet(balance=1200, start=0, cliff=12, duration=48)
print("month 6 :", wallet.release(6)) # 0, before the cliff
print("month 12:", wallet.release(12)) # 300, accrued since start
print("month 24:", wallet.release(24)) # 300 more
wallet.deposit(120) # a top-up changes the total allocation
print("month 24 after top-up:", wallet.release(24)) # 60
print("month 48:", wallet.release(48)) # the rest
print("total paid:", wallet.released) # 1320Three details are worth noticing in the output:
- At month 12 the cliff ends and the beneficiary receives 300 tokens at once. That is the amount accrued since the start (12/48 of 1,200), not zero.
- The top-up of 120 tokens at month 24 produces an immediate release of 60. That is half of the new tokens, because half of the duration has elapsed.
- The final total is 1,320, which is every token ever deposited.
Sequence of events
The diagram shows the lifecycle of a simple vesting contract. Funding happens once, and claims happen whenever the beneficiary chooses.
Common designs
Projects do not all deploy the same contract. The main patterns differ in who can change the terms and how many beneficiaries one contract serves.
| Design | How it works | Typical use | Main risk to check |
|---|---|---|---|
| Single-beneficiary wallet (for example OpenZeppelin `VestingWallet`) | One contract per beneficiary, with parameters fixed at deployment | Team, advisors, treasury | Whether the beneficiary or owner address can be changed |
| Multi-beneficiary vesting contract | One contract stores a schedule per beneficiary in a mapping | Large investor rounds | Admin functions that can create, edit, or revoke schedules |
| Streaming protocols (for example Sablier, Hedgey) | A linear stream is created per recipient, often as a transferable NFT | Contributors, grants, payroll | Whether streams are cancelable and by whom |
| Merkle distributor | A contract holds the tokens and a Merkle root of eligible claims. Users prove their entitlement to claim | Airdrops, community TGE unlocks | Whether the root can be replaced, and how long claims stay open |
| Token locker (for example a liquidity locker) | Holds tokens until a single unlock date, with no linear release | Liquidity-pool tokens, simple team locks | Whether the lock date can be extended or shortened |
A lock and vesting are different. A lock releases everything at one date, which produces a single large unlock event. A vesting contract releases gradually after a cliff, so the same total produces many small events.
Properties that decide whether you can trust it
The formula is rarely where schedules go wrong. The surrounding permissions are. For each contract you evaluate, check the following.
Is it fully funded?
A contract only enforces a schedule for tokens it holds. If the project deploys a contract for 200 million tokens but sends only 20 million, the other 180 million are still a promise. Compare the contract's token balance with the claimed allocation. Also check that the tokens are in the contract itself and not in a separate multisig wallet that is merely "intended" to fund it later.
Who is the owner, and what can the owner do?
Many vesting contracts are Ownable. An owner might be able to:
- Change the beneficiary. This is usually harmless, but it lets a team move the vested rights to another address.
- Revoke the schedule and take back unvested tokens. This is common for employee grants and unacceptable for a locked liquidity position.
- Shorten the duration or move the start time. This accelerates unlocks.
A contract with no owner functions, or whose ownership was renounced, is immutable in its terms. A contract whose owner is an externally owned account (a single private key) is a much weaker guarantee than one controlled by a multisig with a timelock.
Is the contract upgradeable?
If the vesting contract sits behind a proxy, the code can be replaced by whoever holds the upgrade key. A readable formula in today's implementation says nothing about tomorrow's. Look for an admin address on the proxy and see who controls it.
How is time measured?
Contracts compare block.timestamp against stored times, in seconds. Two practical consequences follow:
- "12 months" is stored as a fixed number of seconds, commonly 365 days divided by 12 or a flat 30 days per month. A documented "one-year cliff" can differ from the calendar date by a few days, so use the contract's own numbers.
- Validators can shift a timestamp by seconds, which is irrelevant to monthly schedules.
Which token does it handle?
The VestingWallet pattern pays out whatever token the caller names. For tokens that charge fees on transfer or change balances without transfers (rebasing tokens), the balance + released identity can break. The contract may release more or fewer tokens than the original deposit.
What this means for supply modeling
Your month-by-month supply model computes vested(month) for each allocation. On-chain, that figure is the cumulative amount the beneficiary could have claimed, not the amount that has reached the market. Three behaviors create the gap:
- Delayed claims. A beneficiary may call
releasemonths late. The tokens remain locked in the contract from the market's point of view, but they are claimable at any time. They are a latent supply overhang. - Batch claims. Beneficiaries often claim right after the cliff, which concentrates a large amount in a single block even though the schedule is linear.
- Intermediate transfers. Released tokens frequently move to an exchange deposit address, a market maker, or a custodian. Those transfers are the observable signal of selling pressure, and they come after the release.
Your model is therefore an upper bound on newly liquid supply for a given date, not a forecast of sales.
Common errors
- Reading the formula and ignoring the owner. An elegant linear function with an owner who can call
revokeorsetBeneficiaryis only as strong as that owner's key management. - Confusing the cliff with a delayed start. In the standard design, the amount accrued from the start date is released at the cliff. A 12-month cliff on a 48-month schedule releases 25% at month 12, not 0%.
- Assuming one contract per allocation. A team allocation is often split across many beneficiaries, each with its own wallet or mapping entry. Summing one contract understates the total.
- Assuming funded means locked. Tokens can be in a multisig before being deposited. The multisig can still move them.
- Forgetting that time parameters are in seconds. A contract deployed with
cliff = 12rather than12 * 30 dayshas a 12-second cliff.
Exercises
Exercise
A vesting wallet holds 900 tokens, has released 0, and has start = day 0, cliff = 90 days, duration = 360 days. How many tokens are releasable on day 89, on day 90, and on day 180 (assuming nothing was released on day 90)?
Show answer
Day 89 is before the cliff, so 0. On day 90 the cliff has ended, and vested = 900 90 // 360 = 225, so 225 are releasable. On day 180, vested = 900 180 // 360 = 450, so 450 are releasable (released is still 0 under the stated assumption).
Exercise
A project announces a four-year team vesting schedule in a contract owned by a single externally owned account. The contract has an owner-only revoke function and sits behind an upgradeable proxy. Name two reasons you would not treat the announced schedule as binding, and one check that would raise your confidence.
Show answer
The owner key can call revoke and take back (or redirect) unvested tokens, and whoever controls the proxy admin can replace the contract logic, so the formula can change at any time. Both rest on one key. To raise confidence, check whether ownership and proxy admin were transferred to a multisig with a timelock or renounced, and confirm the contract holds the full allocation.