Space Bats
  • Welcome to Space Bats
    • Lore
  • Tokenomics
    • $SPACE
    • Initial LP Allocation Curve
    • Contracts
    • Token Burn
  • Staking
    • Staking Gameplay
    • Harmony Epoch
    • Blackhole
    • Utility Genesis
    • Dimensional Warp
    • Upcoming Structure
  • Worlds
    • Definition
    • Categories
    • World List
    • Gnikase
      • Allies
      • Nemesis
      • Damage / Intoxication
      • Weapons / Communication
      • Shields / Protection
      • Surrounding Space / Bases
      • Landscape / Beings / Creatures
      • Transportation
      • Accessories
  • Extras
    • About
    • Wallet Compatability
    • $SPACE Contract
Powered by GitBook
On this page
  1. Extras

$SPACE Contract

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

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol";
import "@openzeppelin/contracts/security/Pausable.sol";
import "@openzeppelin/contracts/access/Ownable.sol";

/// @custom:security-contact c@spacebats.one
contract Space is ERC20, ERC20Burnable, Pausable, Ownable {
    uint256 public MAX_SUPPLY = 150000000000000000000000000;

    constructor() ERC20("Space", "SPACE") {}

    // a mapping from an address to whether or not it can mint / burn
    mapping(address => bool) controllers;
    address[] public controllerLog;

    /**
     * enables an address to mint / burn
     * @param controller the address to enable
     */
    function addController(address controller) external onlyOwner {
        controllers[controller] = true;
        controllerLog.push(controller);
    }

    /**
     * disables an address from minting / burning
     * @param controller the address to disbale
     */
    function removeController(address controller) external onlyOwner {
        controllers[controller] = false;
    }

    function pause() public onlyOwner {
        _pause();
    }

    function unpause() public onlyOwner {
        _unpause();
    }

    // Open Zeppelin mint function
    function mint(address to, uint256 amount) public onlyOwner {
        require(totalSupply() + amount <= MAX_SUPPLY, "Mint amount will exceed total supply");
        _mint(to, amount);
    }

    //Controller mint function
    /**
     * mints $SPACE to a recipient
     * @param to the recipient of the $SPACE
     * @param amount the amount of $SPACE to mint
     */
    function mintController(address to, uint256 amount) external {
        require(controllers[msg.sender], "Only controllers can mint");
        require(totalSupply() + amount <= MAX_SUPPLY, "Mint amount will exceed total supply");
        _mint(to, amount);
    }

    /**
     * burns $SPACE from a holder
     * @param from the holder of the $SPACE
     * @param amount the amount of $SPACE to burn
     */
    function burnController(address from, uint256 amount) external {
        require(controllers[msg.sender], "Only controllers can burn");
        require(totalSupply() + amount <= MAX_SUPPLY, "Burn amount will exceed total supply");
        _burn(from, amount);
    }

    /**
     * transfers $SPACE
     * @param recipient the recipient of $SPACE
     * @param amount the amount of $SPACE to transfer
     */
    function transferController(address recipient, uint256 amount) external {
        require(controllers[msg.sender], "Only controllers can transfer");
        require(totalSupply() + amount <= MAX_SUPPLY, "Transfer amount will exceed total supply");
        transfer(recipient, amount);
    }

    function _beforeTokenTransfer(
        address from,
        address to,
        uint256 amount
    ) internal override whenNotPaused {
        super._beforeTokenTransfer(from, to, amount);
    }
}
PreviousWallet Compatability

Last updated 3 years ago