facebook

how to build and launch a custom token (Rebase Logic)

Posted By : Rahul

Apr 29, 2025

Understanding Rebase Tokens in Ethereum

 

A rebase token is created using cryptocurrency development services. It is a crypto token that does not have a set amount in each holder's wallet.  Instead, they dynamically modify balances through a rebase process.


Most cryptocurrencies (like Bitcoin, ETH, and USDC) have a fixed supply model.

 

Meaning: If your wallet says 100 USDC, that's because you either received it via transfer or earned it via a transaction, and it stays there unless you manually do something.
Rebase tokens are different.


They automatically adjust wallet balances without explicit transfers!

 

Rebase tokens vs. fixed supply tokens

 

The supply of many cryptocurrencies, including Bitcoin and conventional ERC-20 tokens like USDC and UNI, is fixed. These tokens may mint or burn tokens to modify the supply. Only explicit transfers between wallets can change wallet balances.


Rebase tokens, on the other hand, have dynamic supplies and wallet balances that alternate automatically without the need for explicit transfers thanks to built-in rebase mechanisms. The balance of a wallet on Etherscan might therefore differ from the net of its transactions.

Example: Fixed supply


Receiving a USDC transfer or engaging with a smart contract (such as a Uniswap transaction) that initiates a transfer are the only ways for a wallet with $100 USDC to increase its balance. This is simple to understand from a tax standpoint because every purchase and sale is explicitly documented in the transaction history.

 

Example: Rebase token 
 

The balance of a wallet should be 0 AMPL if it receives 100.02 AMPL at first, transfers 0.02 AMPL, and then transfers out 100 AMPL. However, because of the rebase mechanism, the balance might show 50 AMPL instead, which would indicate that the supply of tokens has increased since they were first received.

 

Also, Check | How to Fetch Token Pricing with On-Chain Bonding Curves

 

Designing a rebasing token

 

Smart Contract Structure

  • // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.28;
    
    import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol";
    import {IERC20Errors} from "@openzeppelin/contracts/interfaces/draft-IERC6093.sol";
    
    contract ElasticToken is IERC20, IERC20Errors {
        uint256 internal totalShares;
        mapping(address => uint256) internal shares;
        mapping(address => mapping(address => uint256)) public allowance;
    
        receive() external payable {}
    
        function mint(address to) external payable {
            require(to != address(0), "Invalid address");
            uint256 newShares = totalShares == 0 ? msg.value : msg.value * totalShares / (address(this).balance - msg.value);
            require(newShares > 0, "Zero shares");
    
            totalShares += newShares;
            shares[to] += newShares;
    
            emit Transfer(address(0), to, balanceOf(to));
        }
    
        function burn(address from, uint256 amount) external {
            _spendAllowance(from, msg.sender, amount);
            uint256 shareAmount = _toShares(amount);
            shares[from] -= shareAmount;
            totalShares -= shareAmount;
    
            (bool sent, ) = from.call{value: amount}("");
            require(sent, "ETH transfer failed");
    
            emit Transfer(from, address(0), amount);
                }
    
        function transfer(address to, uint256 amount) external returns (bool) {
            transferFrom(msg.sender, to, amount);
            return true;
        }
    
        function transferFrom(address from, address to, uint256 amount) public returns (bool) {
            require(to != address(0), "Invalid address");
            _spendAllowance(from, msg.sender, amount);
            uint256 shareAmount = _toShares(amount);
            shares[from] -= shareAmount;
            shares[to] += shareAmount;
            emit Transfer(from, to, amount);
            return true;
        }
    
        function approve(address spender, uint256 amount) external returns (bool) {
            allowance[msg.sender][spender] = amount;
            emit Approval(msg.sender, spender, amount);
            return true;
        }
    
        function balanceOf(address account) public view returns (uint256) {
            return totalShares == 0 ? 0 : shares[account] * address(this).balance / totalShares;
        }
    
        function totalSupply() public view returns (uint256) {
            return address(this).balance;
        }
    
        function _toShares(uint256 amount) internal view returns (uint256) {
            return totalShares == 0 ? 0 : amount * totalShares / address(this).balance;
        }
    
        function _spendAllowance(address owner, address spender, uint256 amount) internal {
            if (owner != spender) {
                uint256 allowed = allowance[owner][spender];
                require(allowed >= amount, "Allowance exceeded");
                allowance[owner][spender] = allowed - amount;
            }
        }
    }

 

  • Deployment Script (using Hardhat)

     

    // scripts/deploy.js
    const hre = require("hardhat");
    
    async function main() {
      const ElasticToken = await hre.ethers.getContractFactory("ElasticToken");
      const token = await ElasticToken.deploy();
      await token.deployed();
    
      console.log("ElasticToken deployed to:", token.address);
    }
    
    main().catch((error) => {
      console.error(error);
      process.exitCode = 1;
    });

     

    Deployment Steps:

     

  • Install Hardhat:

     

    npm install --save-dev hardhat
    npx hardhat
  • Choose "Create a basic sample project" (or an empty project if you prefer)

     

  • Save the Solidity contract in contracts/ElasticToken.sol.

     

  • Save the deploy script inside scripts/deploy.js.

     

  • Run this to compile: npx hardhat compile

     

  • Deploy on local/testnet:

    npx hardhat run scripts/deploy.js --network goerli
    (Replace goerli with sepolia, mainnet, or whichever network you want.)
  • Verify on Etherscan (optional):

     

    npx hardhat verify --network goerli <your_contract_address>

 

Also, Check | Creating a Token Curated Registry (TCR) on Ethereum

 

Conclusion

 

In conclusion, rebase tokens represent a significant evolution in how token supply and wallet balances are managed within blockchain ecosystems like Ethereum. Unlike traditional fixed-supply tokens, rebase tokens automatically adjust user balances based on internal supply mechanisms without explicit transfers, creating new opportunities — and challenges — in DeFi and beyond. By leveraging smart contracts like the ElasticToken example, developers can create dynamic and responsive tokens that better reflect market conditions. With proper deployment and understanding, rebase tokens can drive innovative financial models while pushing the boundaries of what's possible in decentralized finance. If you are looking for defi development services, connect with our skilled blockchain developers to get started. 

Leave a

Comment

Name is required

Invalid Name

Comment is required

Recaptcha is required.

blog-detail

May 8, 2025 at 04:45 pm

Your comment is awaiting moderation.

bg bg

What's Trending in Tech

bg

Our Offices

India

INDIA

DG-18-009, Tower B,
Emaar Digital Greens, Sector 61,
Gurugram, Haryana
122011.
Unit- 117-120, First Floor,
Welldone Tech Park,
Sector 48, Sohna road,
Gurugram, Haryana
122018.
USA

USA

30N, Gloud St STR E, Sheridan, Wyoming (USA) - 82801
Singapore

SINGAPORE

10 Anson Road, #13-09, International Plaza Singapore 079903.

By using this site, you allow our use of cookies. For more information on the cookies we use and how to delete or block them, please read our cookie notice.

Chat with Us