CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/npm-openzeppelin--contracts

Secure Smart Contract library for Solidity with battle-tested implementations of token standards, access control, governance, and essential utilities for building decentralized applications.

Pending

Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

Overview
Eval results
Files

finance.mddocs/

Finance

Token vesting and financial management contracts for controlled token distribution over time.

Capabilities

Vesting Wallet

Linear and cliff-based token vesting with customizable schedules and beneficiary management.

/**
 * Vesting wallet that releases tokens linearly over time
 */
contract VestingWallet is Context, Ownable {
    constructor(address beneficiary, uint64 startTimestamp, uint64 durationSeconds);
    function start() public view virtual returns (uint256);
    function duration() public view virtual returns (uint256);
    function end() public view virtual returns (uint256);
    function released() public view virtual returns (uint256);
    function released(address token) public view virtual returns (uint256);
    function releasable() public view virtual returns (uint256);
    function releasable(address token) public view virtual returns (uint256);
    function release() public virtual;
    function release(address token) public virtual;
    function vestedAmount(uint64 timestamp) public view virtual returns (uint256);
    function vestedAmount(address token, uint64 timestamp) public view virtual returns (uint256);
}

Usage Examples:

import "@openzeppelin/contracts/finance/VestingWallet.sol";

// Create a 4-year vesting wallet
VestingWallet vestingWallet = new VestingWallet(
    beneficiary,
    block.timestamp,  // Start immediately
    4 * 365 * 24 * 60 * 60  // 4 years in seconds
);

// Fund the vesting wallet
vestingWallet.transfer(1000 ether);

// Release vested tokens
vestingWallet.release();

// Check releasable amount
uint256 releasable = vestingWallet.releasable();

Vesting Wallet with Cliff

Enhanced vesting wallet with cliff period functionality.

/**
 * Vesting wallet with cliff period before any tokens are released
 */
contract VestingWalletCliff is VestingWallet {
    constructor(address beneficiary, uint64 startTimestamp, uint64 durationSeconds, uint64 cliffSeconds);
    function cliff() public view virtual returns (uint256);
    function vestedAmount(uint64 timestamp) public view virtual override returns (uint256);
    function vestedAmount(address token, uint64 timestamp) public view virtual override returns (uint256);
}

Usage Examples:

import "@openzeppelin/contracts/finance/VestingWalletCliff.sol";

// Create vesting with 1-year cliff, 4-year total
VestingWalletCliff cliffVesting = new VestingWalletCliff(
    beneficiary,
    block.timestamp,
    4 * 365 * 24 * 60 * 60,  // 4 years total
    1 * 365 * 24 * 60 * 60   // 1 year cliff
);

// Before cliff: releasable amount is 0
// After cliff: linear vesting begins

Finance Utilities

Vesting Schedule Management

Utilities for managing complex vesting schedules and calculations.

/**
 * Vesting calculation utilities
 */
library VestingUtils {
    function calculateVestedAmount(uint256 totalAllocation, uint64 start, uint64 duration, uint64 cliff, uint64 timestamp) internal pure returns (uint256);
    function calculateReleasableAmount(uint256 totalAllocation, uint256 released, uint64 start, uint64 duration, uint64 cliff, uint64 timestamp) internal pure returns (uint256);
    function isCliffReached(uint64 start, uint64 cliff, uint64 timestamp) internal pure returns (bool);
    function getVestingProgress(uint64 start, uint64 duration, uint64 timestamp) internal pure returns (uint256 progress);
}

Types

/**
 * Vesting schedule information
 */
struct VestingSchedule {
    address beneficiary;
    uint64 start;
    uint64 duration;
    uint64 cliff;
    uint256 totalAmount;
    uint256 released;
    bool revocable;
}

/**
 * Token release events
 */
event EtherReleased(uint256 amount);
event ERC20Released(address indexed token, uint256 amount);

/**
 * Vesting errors
 */
error VestingInvalidBeneficiary(address beneficiary);
error VestingInvalidDuration(uint64 duration);
error VestingInvalidCliff(uint64 cliff);
error VestingNoTokensReleasable();
error VestingInsufficientBalance(uint256 available, uint256 required);

Install with Tessl CLI

npx tessl i tessl/npm-openzeppelin--contracts

docs

access-control.md

account-abstraction.md

finance.md

governance.md

index.md

mathematical-utilities.md

meta-transactions.md

proxy-patterns.md

security-utilities.md

token-standards.md

tile.json