Skip to content
Verified contractExactMIT

ConfigurableToken

Address0xaa0c45e85d3f45e105c9b0e949e48e6803cbfe50
Balance

0 ETH

 

Transactions

1

 

Compiler

solc 0.8.35

 

Same code

6 more contracts

 

Details

Compiler
solc 0.8.35+commit.47b9dedd
Language
solidity
Optimization
Yes, 200 runs
EVM version
paris
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,387,474
Creation transaction
0x53f6bbd639…2c8f3f2572
Main copy (most transactions)
0x3d291bba…4d7ac8c2

Factory.sol

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

/**
 * ConfigurableToken — an ERC-20 whose capabilities are chosen at launch and
 * then FIXED (mintable / pausable / blacklist / tax / anti-whale are immutable
 * flags). Mutable parameters (tax %, max wallet, exclusions) can only be tuned
 * by the owner *if* the matching capability was enabled at launch — so a token
 * can never gain a power it wasn't created with. The owner can renounce to make
 * the token fully trustless.
 */
contract ConfigurableToken {
    // ---- config chosen at launch ----
    struct Config {
        bool   mintable;
        bool   pausable;
        bool   blacklist;
        bool   taxEnabled;
        uint16 taxBps;       // <= 2500 (25%)
        address taxWallet;
        bool   antiWhale;
        uint256 maxWallet;   // raw units (with decimals)
    }

    string public name;
    string public symbol;
    uint8 public immutable decimals;
    uint256 public totalSupply;

    mapping(address => uint256) public balanceOf;
    mapping(address => mapping(address => uint256)) public allowance;

    // capability flags (immutable after deploy)
    bool public immutable mintable;
    bool public immutable pausable;
    bool public immutable blacklistEnabled;
    bool public immutable taxEnabled;
    bool public immutable antiWhaleEnabled;

    // tunable (only if the matching capability is enabled)
    address public owner;
    uint16 public taxBps;
    address public taxWallet;
    uint256 public maxWallet;
    bool public paused;

    mapping(address => bool) public isBlacklisted;
    mapping(address => bool) public isFeeExcluded;   // skip tax
    mapping(address => bool) public isLimitExcluded; // skip max-wallet

    uint16 public constant MAX_TAX_BPS = 2500; // 25%

    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);

    modifier onlyOwner() { require(msg.sender == owner, "not owner"); _; }

    constructor(
        string memory _name,
        string memory _symbol,
        uint8 _decimals,
        uint256 _supply,
        address _creator,
        Config memory cfg
    ) {
        name = _name;
        symbol = _symbol;
        decimals = _decimals;

        mintable = cfg.mintable;
        pausable = cfg.pausable;
        blacklistEnabled = cfg.blacklist;
        taxEnabled = cfg.taxEnabled;
        antiWhaleEnabled = cfg.antiWhale;

        owner = _creator;

        if (cfg.taxEnabled) {
            require(cfg.taxBps > 0 && cfg.taxBps <= MAX_TAX_BPS, "bad tax");
            require(cfg.taxWallet != address(0), "bad tax wallet");
            taxBps = cfg.taxBps;
            taxWallet = cfg.taxWallet;
        }
        if (cfg.antiWhale) {
            require(cfg.maxWallet > 0, "bad max wallet");
            maxWallet = cfg.maxWallet;
        }

        // creator & tax wallet are never taxed or limited
        isFeeExcluded[_creator] = true;
        isLimitExcluded[_creator] = true;
        if (cfg.taxWallet != address(0)) {
            isFeeExcluded[cfg.taxWallet] = true;
            isLimitExcluded[cfg.taxWallet] = true;
        }
        isLimitExcluded[address(0)] = true;

        totalSupply = _supply;
        balanceOf[_creator] = _supply;
        emit Transfer(address(0), _creator, _supply);
    }

    // ---- ERC-20 ----
    function approve(address spender, uint256 value) external returns (bool) {
        allowance[msg.sender][spender] = value;
        emit Approval(msg.sender, spender, value);
        return true;
    }

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

    function transferFrom(address from, address to, uint256 value) external returns (bool) {
        uint256 allowed = allowance[from][msg.sender];
        require(allowed >= value, "insufficient allowance");
        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - value;
        _transfer(from, to, value);
        return true;
    }

    function _transfer(address from, address to, uint256 value) internal {
        require(from != address(0) && to != address(0), "zero address");
        if (blacklistEnabled) require(!isBlacklisted[from] && !isBlacklisted[to], "blacklisted");
        if (paused) require(from == owner, "paused");

        uint256 bal = balanceOf[from];
        require(bal >= value, "insufficient balance");

        uint256 tax = 0;
        if (taxBps > 0 && !isFeeExcluded[from] && !isFeeExcluded[to]) {
            tax = (value * taxBps) / 10000;
        }
        uint256 net = value - tax;

        if (maxWallet > 0 && !isLimitExcluded[to]) {
            require(balanceOf[to] + net <= maxWallet, "max wallet");
        }

        unchecked { balanceOf[from] = bal - value; }
        balanceOf[to] += net;
        emit Transfer(from, to, net);

        if (tax > 0) {
            balanceOf[taxWallet] += tax;
            emit Transfer(from, taxWallet, tax);
        }
    }

    // ---- burnable (always available; only your own / approved tokens) ----
    function burn(uint256 value) external {
        uint256 bal = balanceOf[msg.sender];
        require(bal >= value, "insufficient balance");
        unchecked { balanceOf[msg.sender] = bal - value; totalSupply -= value; }
        emit Transfer(msg.sender, address(0), value);
    }

    function burnFrom(address from, uint256 value) external {
        uint256 allowed = allowance[from][msg.sender];
        require(allowed >= value, "insufficient allowance");
        if (allowed != type(uint256).max) allowance[from][msg.sender] = allowed - value;
        uint256 bal = balanceOf[from];
        require(bal >= value, "insufficient balance");
        unchecked { balanceOf[from] = bal - value; totalSupply -= value; }
        emit Transfer(from, address(0), value);
    }

    // ---- owner powers (gated by the capability flags) ----
    function mint(address to, uint256 value) external onlyOwner {
        require(mintable, "not mintable");
        require(to != address(0), "zero address");
        totalSupply += value;
        balanceOf[to] += value;
        emit Transfer(address(0), to, value);
    }

    function pause() external onlyOwner { require(pausable, "not pausable"); paused = true; }
    function unpause() external onlyOwner { require(pausable, "not pausable"); paused = false; }

    function setBlacklist(address account, bool flag) external onlyOwner {
        require(blacklistEnabled, "no blacklist");
        isBlacklisted[account] = flag;
    }

    function setTaxBps(uint16 bps) external onlyOwner {
        require(taxEnabled, "no tax");
        require(bps <= MAX_TAX_BPS, "too high");
        taxBps = bps;
    }
    function setTaxWallet(address w) external onlyOwner {
        require(taxEnabled, "no tax");
        require(w != address(0), "zero address");
        taxWallet = w;
        isFeeExcluded[w] = true;
        isLimitExcluded[w] = true;
    }
    function setFeeExcluded(address a, bool flag) external onlyOwner { require(taxEnabled, "no tax"); isFeeExcluded[a] = flag; }

    function setMaxWallet(uint256 amount) external onlyOwner {
        require(antiWhaleEnabled, "no anti-whale");
        require(amount > 0, "zero");
        maxWallet = amount;
    }
    function setLimitExcluded(address a, bool flag) external onlyOwner { require(antiWhaleEnabled, "no anti-whale"); isLimitExcluded[a] = flag; }

    function transferOwnership(address newOwner) external onlyOwner {
        require(newOwner != address(0), "zero address");
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }
    function renounceOwnership() external onlyOwner {
        emit OwnershipTransferred(owner, address(0));
        owner = address(0);
    }
}

/**
 * TokenFactory — deploys a ConfigurableToken in a SINGLE transaction while
 * collecting the service fee on-chain.
 */
contract TokenFactory {
    address public owner;
    address public feeWallet;
    uint256 public fee; // wei

    event TokenCreated(address indexed token, address indexed creator, string name, string symbol, uint8 decimals, uint256 supply);

    modifier onlyOwner() { require(msg.sender == owner, "not owner"); _; }

    constructor(address _feeWallet, uint256 _fee) {
        owner = msg.sender;
        feeWallet = _feeWallet;
        fee = _fee;
    }

    function createToken(
        string calldata name,
        string calldata symbol,
        uint8 decimals,
        uint256 supply,
        ConfigurableToken.Config calldata cfg
    ) external payable returns (address) {
        require(msg.value >= fee, "insufficient fee");
        (bool ok, ) = payable(feeWallet).call{value: msg.value}("");
        require(ok, "fee transfer failed");

        ConfigurableToken token = new ConfigurableToken(name, symbol, decimals, supply, msg.sender, cfg);
        emit TokenCreated(address(token), msg.sender, name, symbol, decimals, supply);
        return address(token);
    }

    function setFee(uint256 _fee) external onlyOwner { fee = _fee; }
    function setFeeWallet(address _feeWallet) external onlyOwner { feeWallet = _feeWallet; }
    function transferOwnership(address _owner) external onlyOwner { owner = _owner; }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  },
  "evmVersion": "paris"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.