ERC-20 S.C.s

The ZCN Token Smart Contract is an ERC-20 token built for the Züs blockchain ecosystem. It follows the ERC-20 standard while incorporating key features such as custom decimals, controlled minting, and allowance management.

The contract is built using OpenZeppelin’s secure and tested libraries, ensuring interoperability with wallets, exchanges, and decentralized applications (dApps).

Contract Overview

  • Token Name: Configurable (set during deployment)

  • Symbol: Configurable (set during deployment)

  • Decimals: 10 (instead of the default 18)

  • Initial Supply: 500,000,000 ZCN

  • Total Supply: Can be increased via minting by the contract owner

  • Minting: Restricted to the owner

  • Allowance Management: Includes increaseApproval() for backward compatibility

  • Standard Functions: Implements all ERC-20 functions such as transfer, approve, allowance, etc.

Smart Contract Code

// SPDX-License-Identifier: MIT
pragma solidity 0.8.18;

import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

/**
 * @title Token
 *
 * @notice Represents ERC20 implementation for ZCN tokens
 */
contract Token is ERC20, Ownable {
    constructor(string memory name_, string memory symbol_)
        ERC20(name_, symbol_)
    {
        _mint(msg.sender, 500000000 * 10**decimals());
    }

    /**
     * @notice Overrides ERC20 decimals function to modify amount of token decimals
     * @return uint8 The amount of token decimals
     */
    function decimals() public pure override returns (uint8){
        return 10;
    }

    /**
     * @notice Public mint function
     * @param account_ The address to mint tokens to
     * @param amount_ The amount of tokens to mint
     */
    function mint(address account_, uint256 amount_) external onlyOwner {
        _mint(account_, amount_);
    }

    /**
     * @notice Alias for an older version of ERC20 smart contract to use increaseAllowance method
     * @param spender_ The address to increase allowance for
     * @param amount_ The amount to increase
     */
    function increaseApproval(address spender_, uint256 amount_) external onlyOwner {
        increaseAllowance(spender_, amount_);
    }
}

Key Features

1. ERC-20 Compliance

This contract follows the ERC-20 standard, meaning it supports:

  • transfer(): Allows token transfers between users.

  • approve(): Grants spending permission to another address.

  • allowance(): Checks the approved spending limit.

  • transferFrom(): Executes transfers on behalf of a user.

2. Custom Decimals

Unlike the default 18 decimals in ERC-20, this token has 10 decimals:

function decimals() public pure override returns (uint8){
    return 10;
}
  • This allows for finer precision in transactions.

3. Minting New Tokens

  • Only the contract owner can mint new tokens:

function mint(address account_, uint256 amount_) external onlyOwner {
    _mint(account_, amount_);
}
  • Use case:

    • This function can be used for staking rewards, governance incentives, or controlled token supply expansion.

4. Increased Allowance Function (increaseApproval)

  • Provides backward compatibility for older ERC-20 implementations:

function increaseApproval(address spender_, uint256 amount_) external onlyOwner {
    increaseAllowance(spender_, amount_);
}
  • This function allows adjusting allowances without resetting them, which is useful in older DeFi applications.

Deployment & Usage

1. Deploying the Contract

To deploy the contract, provide the token name and symbol:

Token zcnToken = new Token("Zus Coin", "ZCN");

2. Interacting with the Contract

Minting New Tokens

zcnToken.mint(0xRecipientAddress, 1000 * 10**10);

✅ Mints 1,000 ZCN tokens.

Transferring Tokens

zcnToken.transfer(0xRecipientAddress, 500 * 10**10);

✅ Transfers 500 ZCN to the recipient.

Approving a Spender

zcnToken.approve(0xSpenderAddress, 200 * 10**10);

✅ Allows spender to transfer up to 200 ZCN on behalf of the owner.

Checking Balance

zcnToken.balanceOf(0xUserAddress);

✅ Returns the token balance of a user.

Using increaseApproval

zcnToken.increaseApproval(0xSpenderAddress, 50 * 10**10);

✅ Increases allowance by 50 ZCN.

Use Cases

  • Utility Token: Used for transactions, fees, and governance within the Züs ecosystem.

  • DeFi & Staking: Can be used in staking, farming, and liquidity pools.

  • Token Bridging: Supports cross-chain transfers between Ethereum and Züs.

The ZCN ERC-20 Smart Contract is designed for efficiency, security, and seamless integration within the Züs ecosystem. It offers controlled minting, customized decimals, and standard ERC-20 functions, ensuring compatibility with DeFi applications, wallets, and exchanges.

Last updated