Smart Contract
This Clarity smart contract implements a token vesting system designed for securing team or advisor tokens, ensuring long-term commitment, and managing vesting distribution over time to various participants. The contract allows for the creation of customized vesting schedules, token claiming, and transfers of vested tokens.
- Token initialization with custom name, symbol, and decimals
- Creation of personalized vesting schedules for participants
- Vesting period with customizable start time, cliff period, and vesting duration
- Calculation of vested tokens based on the current block height
- Claiming of vested tokens by participants
- Transfer of claimed tokens between participants
- Querying of token balances, vesting schedules, and contract information
The smart contract consists of the following main components:
-
Data Variables:
- Token information (name, symbol, decimals)
- Total supply
- Contract initialization status
-
Data Maps:
- Token balances
- Vesting schedules
-
Public Functions:
initialize
: Set up the token with basic informationcreate-vesting-schedule
: Create a vesting schedule for a participantclaim-vested-tokens
: Allow participants to claim their vested tokenstransfer
: Enable transferring of claimed tokens
-
Read-Only Functions:
get-vested-amount
: Calculate the amount of tokens vested for a participantget-balance
: Retrieve the token balance of an accountget-total-supply
: Get the total token supplyget-name
,get-symbol
,get-decimals
: Retrieve token informationget-vesting-schedule
: Get the vesting schedule for a participantis-initialized
: Check if the contract has been initialized
To set up and deploy this smart contract:
-
Ensure you have Clarinet installed.
-
Create a new Clarinet project:
clarinet new vesting-contract
-
Replace the contents of
contracts/vesting-contract.clar
with the provided smart contract code. -
Update the
Clarinet.toml
file to include the contract:[contracts.vesting-contract] path = "contracts/vesting-contract.clar" clarity_version = 2 epoch = 2.4
-
Test the contract locally:
clarinet test
-
Deploy the contract to a testnet or mainnet using Clarinet or other Stacks deployment tools.
- Only the contract owner can initialize the contract and create vesting schedules.
- Participants can only claim tokens that have vested according to their schedule.
- The contract uses various checks and balances to prevent unauthorized actions and ensure the integrity of the vesting process.
Comprehensive unit tests should be written to cover all functions and edge cases. Use Clarinet's testing framework to write and run tests:
- The contract doesn't support token minting or burning.
- There's no functionality to modify or revoke vesting schedules once created.
- Consider adding events (using
print
) to log important actions for off-chain tracking. - Implement a function to allow participants to check their claimable token amount directly.
[Amobi Ndubuisi or [email protected]]
This Clarity smart contract implements a token vesting system designed for securing team or advisor tokens, ensuring long-term commitment, and managing vesting distribution over time to various participants. The contract allows for the creation of customized vesting schedules, token claiming, and transfers of vested tokens.
- Token initialization with custom name, symbol, and decimals
- Creation of personalized vesting schedules for participants
- Vesting period with customizable start time, cliff period, and vesting duration
- Calculation of vested tokens based on the current block height
- Claiming of vested tokens by participants
- Transfer of claimed tokens between participants
- Querying of token balances, vesting schedules, and contract information
The smart contract consists of the following main components:
-
Data Variables:
- Token information (name, symbol, decimals)
- Total supply
- Contract initialization status
-
Data Maps:
- Token balances
- Vesting schedules
-
Public Functions:
initialize
: Set up the token with basic informationcreate-vesting-schedule
: Create a vesting schedule for a participantclaim-vested-tokens
: Allow participants to claim their vested tokenstransfer
: Enable transferring of claimed tokens
-
Read-Only Functions:
get-vested-amount
: Calculate the amount of tokens vested for a participantget-balance
: Retrieve the token balance of an accountget-total-supply
: Get the total token supplyget-name
,get-symbol
,get-decimals
: Retrieve token informationget-vesting-schedule
: Get the vesting schedule for a participantis-initialized
: Check if the contract has been initialized
To set up and deploy this smart contract:
-
Ensure you have Clarinet installed.
-
Create a new Clarinet project:
clarinet new vesting-contract
-
Replace the contents of
contracts/vesting-contract.clar
with the provided smart contract code. -
Update the
Clarinet.toml
file to include the contract:[contracts.vesting-contract] path = "contracts/vesting-contract.clar" clarity_version = 2 epoch = 2.4
-
Test the contract locally:
clarinet test
-
Deploy the contract to a testnet or mainnet using Clarinet or other Stacks deployment tools.
- Only the contract owner can initialize the contract and create vesting schedules.
- Participants can only claim tokens that have vested according to their schedule.
- The contract uses various checks and balances to prevent unauthorized actions and ensure the integrity of the vesting process.
Comprehensive unit tests should be written to cover all functions and edge cases. Use Clarinet's testing framework to write and run tests:
- The contract doesn't support token minting or burning.
- There's no functionality to modify or revoke vesting schedules once created.
- Consider adding events (using
print
) to log important actions for off-chain tracking. - Implement a function to allow participants to check their claimable token amount directly.
[Amobi Ndubuisi or [email protected]