Skip to content

dumbdevss/Movement-Vesting-Template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Token Vesting on Movement Network

A decentralized token vesting contract built on the Movement Network that enables time-locked token distribution with cliff periods and linear vesting schedules for team members, investors, and contributors.

Overview

The Token Vesting smart contract provides a robust solution for managing token distribution over time. The contract locks tokens and releases them gradually according to predefined schedules, enabling:

  • Linear Vesting: Tokens unlock proportionally over a specified duration
  • Cliff Periods: Initial lockup period before any tokens can be claimed
  • Flexible Scheduling: Custom vesting periods and cliff durations per beneficiary
  • On-Chain Verification: All vesting schedules stored immutably on-chain
  • Granular Claims: Beneficiaries can claim any amount up to their vested balance

This system is ideal for token distribution scenarios such as team allocations, investor vesting, advisor compensation, community rewards, and any situation requiring time-based token release.

What's Included

  • Movement CLI installation script (from l1-migration branch)
  • Token Vesting Contract: Production-ready Move module with linear vesting
  • Helper Scripts: Easy commands for deployment and testing
  • Project Structure: Standard Move project layout

Prerequisites

No prerequisites needed! The installation script will download a prebuilt Movement CLI binary.

System Requirements

  • Disk Space: ~50MB for the Movement CLI binary
  • Platform: Linux x86_64 (Replit compatible)
  • Time: Installation takes ~10 seconds

Quick Start

1. Install the Movement CLI

The installation script downloads a prebuilt Movement CLI binary from the l1-migration branch:

bash scripts/install-cli.sh

Note: This takes about 10 seconds. The script will attempt to configure your PATH automatically.

2. Initialize Your Configuration

Set up your Movement CLI configuration for the testnet:

bash scripts/init.sh

You'll be prompted to:

  • Select custom network
  • Enter REST URL: https://testnet.movementnetwork.xyz/v1
  • Enter Faucet URL: https://faucet.testnet.movementnetwork.xyz/
  • Generate a new private key (or provide your own)

Your configuration will be saved in .movement/config.yaml

⚠️ IMPORTANT: Never commit .movement/config.yaml to git - it contains your private key!

3. Fund Your Account

Get testnet MOVE tokens to pay for transactions:

movement account fund-with-faucet --account default

4. Build the Move Module

Compile the token vesting module:

bash scripts/build.sh

5. Test the Move Module

Run the unit tests:

bash scripts/test.sh

6. Deploy to Testnet

Deploy your module to the Movement testnet:

movement move publish --named-addresses vesting=default

To reduce gas costs (omit debug artifacts):

movement move publish --named-addresses vesting=default --included-artifacts none

Note If movement command fails and the cli is installed. install please run

export PATH="$HOME/bin:$PATH"

Project Structure

.
├── Move.toml                     # Move package configuration
├── sources/
│   └── vesting.move             # Your Move module
├── scripts/
│   ├── install-cli.sh           # Install Movement CLI
│   ├── init.sh                  # Initialize CLI configuration
│   ├── build.sh                 # Compile the module
│   ├── test.sh                  # Run tests
│   └── verify.sh                # Verify setup
└── tests/                       # Additional test files (optional)

The Token Vesting Module

Core Features

Linear Vesting

  • Proportional token unlock over time
  • Customizable vesting duration per beneficiary
  • Smooth, continuous vesting calculations

Cliff Periods

  • Optional initial lockup before vesting begins
  • Prevents early token access
  • Cliff duration configurable per stream

Flexible Claims

  • Beneficiaries claim any amount up to vested balance
  • Multiple partial claims supported
  • Gas-efficient claim operations

Event System

  • Stream creation events with full parameters
  • Claim events for audit trails
  • Complete transparency for all operations

Key Functions

Entry Functions (Callable via transactions)

  • create_stream: Create a new vesting schedule for a beneficiary (owner only, deposits MOVE tokens)
  • claim: Claim vested tokens up to available balance (beneficiary only)

View Functions (Read-only queries)

  • get_stream: Retrieve complete vesting stream details including total amount, start time, cliff, duration, and claimed amount
  • get_vested_amount: Calculate currently vested tokens for a beneficiary at a given timestamp

Usage Examples

Creating a Vesting Stream

movement move run \
  --function-id 'default::vesting::create_stream' \
  --args address:"0x742d35Cc6634C0532925a3b844Bc9e7595f0bEb1" \
  --args u64:100000000 \
  --args u64:31536000 \
  --args u64:7776000

Parameters:

  • Beneficiary address
  • Total amount (in octas: 100000000 = 1 MOVE)
  • Duration in seconds (31536000 = 1 year)
  • Cliff in seconds (7776000 = 90 days)

Claiming Vested Tokens

movement move run \
  --function-id 'default::vesting::claim' \
  --args u64:50000000

Parameters:

  • Amount to claim in octas (50000000 = 0.5 MOVE)

Development Workflow

Edit Your Module

Modify sources/vesting.move or add new .move files to the sources/ directory.

Update Dependencies

Edit Move.toml to change dependencies. The default configuration uses the Aptos Framework.

Address Configuration

The Move.toml file uses a placeholder address _ for vesting. When compiling or publishing:

# Use the default profile address
movement move compile --named-addresses vesting=default

# Or specify an explicit address
movement move compile --named-addresses vesting=0xYOUR_ADDRESS

Tip: Edit Move.toml and set vesting = "0xYOUR_ADDRESS" to avoid using --named-addresses every time.

Architecture Details

Resource Account Pattern

The contract uses a resource account to manage vesting state independently from the deployer:

  • VestingContract: Stored under the resource account, contains all streams and token reserves
  • State: Holds the signing capability and event handles
  • Benefits: Cleaner separation, predictable addresses, better security

Vesting Calculation

The contract implements linear vesting with the following formula:

vested_amount = (elapsed_time / total_duration) * total_amount

Key points:

  • Vesting starts after the cliff period passes
  • Tokens vest linearly until the end of the duration
  • Beneficiaries can claim partial amounts multiple times
  • All calculations use seconds for precision

Token Management

MOVE tokens are deposited into the contract when streams are created:

  • Owner deposits tokens during create_stream
  • Tokens held in contract's Coin<AptosCoin> reserve
  • Beneficiaries withdraw vested amounts via claim
  • Unclaimed tokens remain locked in contract

Movement CLI Commands

Essential Movement CLI commands for working with your contract:

# Check CLI version
movement --version

# Compile module
movement move compile --named-addresses vesting=default

# Run tests
movement move test

# Publish module
movement move publish --named-addresses vesting=default

# Check account balance
movement account list

# Fund account (testnet only)
movement account fund-with-faucet --account default

Security Considerations

Access Control

  • Only contract owner can create vesting streams
  • Only beneficiaries can claim their vested tokens
  • Cliff periods enforce minimum lockup

Error Handling

The contract includes comprehensive error checking:

  • ERROR_NOT_OWNER: Caller is not the contract owner
  • ERROR_STREAM_EXISTS: Beneficiary already has a vesting stream
  • ERROR_STREAM_NOT_FOUND: No stream exists for beneficiary
  • ERROR_INVALID_DURATION: Duration must be greater than zero
  • ERROR_NO_VESTED_TOKENS: No tokens available to claim
  • ERROR_CLIFF_EXCEEDS_DURATION: Cliff period longer than total duration
  • ERROR_NOTHING_TO_CLAIM: No claimable tokens at current time
  • ERROR_INVALID_AMOUNT: Amount must be greater than zero
  • ERROR_CLIFF_HAS_NOT_PASSED: Attempting to claim before cliff ends
  • ERROR_INSUFFICIENT_FUNDS: Owner lacks sufficient tokens for deposit

Best Practices

  1. Time Calculations: All durations in seconds (use consistent units)
  2. Token Precision: Use octas (1 MOVE = 100,000,000 octas)
  3. Cliff Design: Set reasonable cliff periods (typically 30-365 days)
  4. Owner Funding: Ensure owner has sufficient balance before creating streams
  5. Gradual Claims: Beneficiaries can claim incrementally to manage gas costs

Resources

Network Information

Movement Testnet (Bardock)

Future Enhancements

Potential features to add:

  • Multiple concurrent streams per beneficiary
  • Stream revocation/cancellation by owner
  • Non-linear vesting curves (exponential, stepped)
  • Stream transfer between addresses
  • Batch stream creation
  • Emergency pause mechanism
  • Vesting templates for common schedules

License

This project is based on the Movement Labs aptos-core repository and follows the same licensing.

Contributing

Contributions are welcome! Feel free to:

  • Report bugs
  • Suggest features
  • Submit pull requests
  • Share your implementations

Join the Movement community and help build the future of decentralized token vesting!

About

A vesting contract built on the Movement Network

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors