Token Vesting Smart Contract on Conflux eSpace Testnet

In this blog post, we’ll explore a Token Vesting smart contract built using Solidity and deployed on the Conflux eSpace Testnet. The contract is designed to lock tokens for specific beneficiaries for a period of time before they can be claimed. This is useful in scenarios like team allocation, investor token distribution, or ecosystem incentives where tokens should be gradually unlocked rather than fully available at once.


:rocket: What is Token Vesting?

Token vesting is a mechanism to release tokens over time. Rather than giving someone their entire token allocation up front, a vesting schedule ensures they receive it gradually. This approach is used to align incentives and prevent early dumping of tokens.


:lock: TokenLockVault Contract Overview

The TokenLockVault contract allows an owner to lock tokens on behalf of beneficiaries. The tokens become claimable after a predefined unlock time.

Key Features

  • Token Locking: Lock tokens for an address until a future time.
  • Claim Functionality: Allows the user to claim their tokens after the unlock time.
  • Admin Functions: Only the owner can lock tokens for others.
  • ERC-20 Compatible: Works with any standard ERC-20 token.

:hammer_and_wrench: Smart Contract Functions

1. lockTokens(address beneficiary, uint256 amount, uint256 unlockTime)

Locks a specific amount of tokens for a beneficiary, which they can claim after the unlock time.

2. claimTokens()

Beneficiaries can call this function after the unlock time to receive their tokens.

3. getLockedTokens(address account)

Returns the total locked amount and unlock timestamp for a given user.


:gear: How It Works

  1. Owner approves the vault contract to spend tokens.
  2. Owner locks tokens for multiple addresses using the lockTokens function.
  3. After the unlock timestamp is reached, users can call claimTokens() to receive their tokens.
  4. Tokens remain non-transferable until claimed.

:test_tube: Demo Workflow (Conflux eSpace Testnet)

  1. Deploy your custom ERC-20 token (e.g., MyToken).
  2. Deploy TokenLockVault and pass the token address.
  3. Use approve from your token to allow TokenLockVault to manage the token balance.
  4. Call lockTokens() to assign locked tokens to recipients.
  5. After the unlock time, users call claimTokens() to receive their allocation.

:package: Smart Contract Code

You can find the full source code here:


:movie_camera: Video Tutorial


:loudspeaker: Summary

The TokenLockVault smart contract is a powerful utility for ensuring fair and secure distribution of tokens. By adding time-based locking, it encourages long-term commitment and aligns incentives for teams and communities.

Feel free to fork the repo and modify it for your project needs.


:handshake: Connect

For any help or collaboration, feel free to reach out on Twitter

Happy Building :rocket: