RedCat DAO
  • Welcome to RedCat DAO
  • ☢️RedCat DAO
    • Discord YT Video
    • Discord Adopt RedCat
      • Step 1 - MAX 交易所入金與出金
      • Step2 - MetaMask 添加 BSC 鏈
      • Step3 - 幣安出金到 MetaMask 狐狸錢包
      • Step4 - 領養 RedCat
      • Step5 - 在二級市場或狐狸錢包查看 RedCat
      • Step6 - 認證持有 RedCat
    • Discord Announcement
    • Discord Verify
    • Discord Game
    • Discord Rest Area
    • Discord BlockChain Station
    • Discord BlockChain News
    • Discord Title
    • Discord Rank & Invite
  • 🏢RedCat Offical
    • Mint
    • Tool
    • Depoly Smart Contract
    • Smart Contract Control
  • 🎮RedCat Game
    • Cryptostal
      • Intro
      • Game Play
      • RedCat Ability
      • Strange Things
      • Crystal Drop Probability
      • Battle Record Not Read
    • Feeding Area
      • Intro
  • 🪟RedCat Gallery
    • Ethereum (ETH)
    • BNB Chain(BNB)
    • Polygon (MATIC)
  • 🏛️RedCat Social
    • Marketplace
    • Other Platform
  • 📔RedCat Smart Contract
    • RedCat NFT Contract
    • RedCat Game Contract
    • FT Contract (ERC20)
    • TokenFaucet Contract (ERC20)
    • NFT Contract (ERC721)
    • NFT Contract (ERC721A)
    • NFT Metadata Standards
    • MT Contract (ERC1155)
    • ERC20-Permit Contract (ERC2612)
    • SFT Contract (ERC3525)
    • Swapping Contract(PancakeSwap)
    • Yield Farms Contract(PancakeSwap)
    • Limit Orders Contract(PancakeSwap)
    • Syrup Pools Contract(PancakeSwap)
    • IFO Contract(PancakeSwap)
    • Transparent Proxy Contract
  • 🚄RedCat Experience
    • RedCat Roadmap
    • RedCat Pictures
    • RedCat Team
    • RedCat Contact
Powered by GitBook
On this page
  • IERC20.sol
  • ERC20.sol
  • Ownable.sol
  • RedCatCoin.sol
  • BNB Chain Testnet
  1. RedCat Smart Contract

FT Contract (ERC20)

ERC20

PreviousRedCat Game ContractNextTokenFaucet Contract (ERC20)

Last updated 1 year ago

IERC20.sol

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

interface IERC20 {

    event Transfer(address indexed from, address indexed to, uint value);
    event Approval(address indexed owner, address indexed spender, uint value);

    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint);
    function transfer(address recipient, uint amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint amount) external returns (bool);
    function approve(address spender, uint amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint);

    // ======================================================
    //                        OPTIONAL                       
    // ======================================================
    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);

}

ERC20.sol

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

import "./IERC20.sol";

contract ERC20 is IERC20 {

    //constant
    uint8 constant public decimals = 18;

    //attribute
    string public name;
    string public symbol;
    uint256 public totalSupply;
    mapping(address => uint256) public balanceOf;
    mapping(address => mapping(address => uint256)) public allowance;

    constructor(string memory _name, string memory _symbol, uint256 _totalSupply) {
        name = _name;
        symbol = _symbol;
        uint amount = _totalSupply * 1 ether;
        totalSupply = amount;
        balanceOf[msg.sender] = amount;
        emit Transfer(address(0), msg.sender, amount);
    }

    function transfer(address to, uint256 amount) external virtual returns (bool success) {
        _transfer(msg.sender, to, amount);
        return true;
    }

    function approve(address spender, uint256 amount) external virtual returns (bool success) {
        _approve(msg.sender, spender, amount);
        return true;
    }

    function transferFrom(address sender, address recipient, uint256 amount) external virtual returns (bool success) {
        uint currentAllowance = allowance[sender][msg.sender];
        require(currentAllowance >= amount, "ERC20: insufficient allownace");
        _approve(sender, msg.sender, currentAllowance - amount);
        _transfer(sender, recipient, amount);
        return true;
    }

    function _transfer(address sender, address recipient, uint256 amount) internal {
        require(sender != address(0), "ERC20: transfer sender the zero address");
        require(recipient != address(0), "ERC20: transfer recipient the zero address");
        require(balanceOf[sender] >= amount, "ERC20: transfer amount exceeds balance");

        balanceOf[sender] -= amount;
        balanceOf[recipient] += amount;
        emit Transfer(sender, recipient, amount);
    }

    function _approve(address owner, address spender, uint256 amount) internal {
        require(owner != address(0), "ERC20: approve from the zero address");
        require(spender != address(0), "ERC20: approve to the zero address");

        allowance[owner][spender] = amount;
        emit Approval(owner, spender, amount);
    }

    function _mint(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: mint to the zero address");

        balanceOf[account] += amount;
        totalSupply += amount;
        emit Transfer(address(0), account, amount);
    }

    function _burn(address account, uint256 amount) internal virtual {
        require(account != address(0), "ERC20: burn from the zero address");
        require(balanceOf[account] >= amount, "ERC20: burn amount exceeds balance");
    
        balanceOf[account] -= amount;
        totalSupply -= amount;
        emit Transfer(account, address(0), amount);
    }
    
}

Ownable.sol

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

contract Ownable {

    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    address private _owner;

    modifier onlyOwner() {
        require(owner() == msg.sender, "Ownable: caller is not the owner");
        _;
    }

    constructor() {
        _transferOwnership(msg.sender);
    }

    function owner() public view returns (address) {
        return _owner;
    }

    function transferOwnership(address newOwner) public onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    function _transferOwnership(address newOwner) internal {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }

}

RedCatCoin.sol

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

import "./ERC20.sol";
import "./Ownable.sol";

contract RedCatCoin is ERC20, Ownable {

    constructor(string memory _name, string memory _symbol, uint _totalSupply) ERC20(_name, _symbol, _totalSupply) {
        
    }

    function mint(address account, uint256 amount) external onlyOwner {
        _mint(account, amount);
    }

    function burn(address account, uint256 amount) external onlyOwner {
        _burn(account, amount);
    }

}

BNB Chain Testnet

📔
https://testnet.bscscan.com/address/0x8963a186664c23f48a5e670eee76459714c4d49b
EIP-20: Token StandardEthereum Improvement Proposals