🎓 A1Learner
🔍
0 of 45 lessons completed

Solidity Tokenomics Compared

Tokenomics is the set of rules that decide how tokens are released, created, and charged for. Comparing the three mechanics side by side shows what each one controls.

Vesting releases existing tokens slowly

Vesting does not create new tokens. It only unlocks tokens that were already set aside.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;

contract VestingReminder {
    uint256 public start;
    uint256 public cliff;
    uint256 public duration;
    uint256 public total;
    uint256 public released;

    constructor(uint256 amount) {
        start = 1000;
        cliff = 1100;
        duration = 1000;
        total = amount;
    }

    function claimable() public view returns (uint256) {
        if (block.timestamp < cliff) {
            return 0;
        }
        if (block.timestamp >= start + duration) {
            return total - released;
        }
        return (total * (block.timestamp - start)) / duration - released;
    }
}

Emissions create new tokens up to a cap

Emissions increase total supply over time. The cap is the hard stop on that growth.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;

contract EmissionReminder {
    uint256 public rate;
    uint256 public cap;
    uint256 public totalMinted;
    uint256 public lastTime;

    constructor() {
        rate = 10;
        cap = 5000;
        lastTime = block.timestamp;
    }

    function mint() public returns (uint256 amount) {
        uint256 elapsed = block.timestamp - lastTime;
        amount = elapsed * rate;
        if (totalMinted + amount > cap) {
            amount = cap - totalMinted;
        }
        totalMinted += amount;
        lastTime = block.timestamp;
    }
}

Fees take a slice without changing supply timing

A fee acts on one amount at one moment. Its split shares always sum back to the fee taken.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;

contract FeeReminder {
    function splitFee(uint256 fee) public pure returns (uint256 first, uint256 second) {
        first = (fee * 70) / 100;
        second = fee - first;
    }
}

Example

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.30;

contract TokenomicsSummary {
    uint256 public vestingTotal;
    uint256 public emissionCap;
    uint256 public emissionTotal;
    uint256 public emissionLastTime;
    uint256 public emissionRate;

    constructor() {
        vestingTotal = 1000;
        emissionCap = 5000;
        emissionRate = 10;
        emissionLastTime = block.timestamp;
    }

    function vestingClaimable() public view returns (uint256) {
        if (block.timestamp < 1100) {
            return 0;
        }
        if (block.timestamp >= 2000) {
            return vestingTotal;
        }
        return (vestingTotal * (block.timestamp - 1000)) / 1000;
    }

    function mintEmission() public returns (uint256 amount) {
        uint256 elapsed = block.timestamp - emissionLastTime;
        amount = elapsed * emissionRate;
        if (emissionTotal + amount > emissionCap) {
            amount = emissionCap - emissionTotal;
        }
        emissionTotal += amount;
        emissionLastTime = block.timestamp;
    }

    function splitFee(uint256 fee) public pure returns (uint256 first, uint256 second) {
        first = (fee * 70) / 100;
        second = fee - first;
    }
}

Key points

  • Vesting: Vesting controls when existing tokens become available and it releases nothing before the cliff.
  • Emissions: Emissions control how new tokens are created and they stop when the cap is reached.
  • Fees: Fees control what share is taken from an amount and how that share is divided.
  • Supply: Vesting moves existing supply into hands while emissions increase total supply.
  • Timing: Vesting and emissions both depend on time while a fee depends only on the amount.
  • Restatement: Together the three mechanics decide release timing, new supply, and charges without adding a fourth rule.

In this example, TokenomicsSummary brings the three earlier mechanics together in one contract, checks the vesting share at the midpoint, checks the fee split sums, and checks the emission amount over a warped interval.

Try it Yourself

Edit the code, then press Run.

Running is simulated · Remix IDE

Exercise

Which mechanic increases total supply?