CypherToken

Description:

Multi-signature wallet contract requiring multiple confirmations for transaction execution.

Blockchain: Ethereum

Source Code: View Code On The Blockchain

Solidity Source Code:

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

/*

Cypher Chat AI
Website: https://cypherchat.pro
X: https://x.com/cypherchatai
*/

/**
 * @title IERC20
 * @notice ERC-20 interface definition
 */
interface IERC20 {
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);

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

/**
 * @title Ownable
 * @dev Basic access control mechanism with ownership transfer and renounce functionality.
 */
abstract contract Ownable {
    address private _owner;

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

    /**
     * @notice Initializes the contract setting the deployer as the initial owner.
     */
    constructor(address initialOwner) {
        require(initialOwner != address(0), "Owner cannot be zero address");
        _owner = initialOwner;
        emit OwnershipTransferred(address(0), initialOwner);
    }

    /**
     * @notice Returns the address of the current owner.
     */
    function owner() public view returns (address) {
        return _owner;
    }

    /**
     * @notice Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        require(_owner == msg.sender, "Caller is not the owner");
        _;
    }

    /**
     * @notice Transfers ownership to a new address.
     * @param newOwner Address of the new owner.
     */
    function transferOwnership(address newOwner) external onlyOwner {
        require(newOwner != address(0), "New owner cannot be zero address");
        emit OwnershipTransferred(_owner, newOwner);
        _owner = newOwner;
    }

    /**
     * @notice Renounces ownership of the contract.
     * @dev Leaves the contract without an owner. Cannot be undone.
     */
    function renounceOwnership() external onlyOwner {
        emit OwnershipTransferred(_owner, address(0));
        _owner = address(0);
    }
}

/**
 * @title CypherToken
 * @notice Fully compliant ERC-20 token with burn, recovery, and ownership control.
 */
contract CypherToken is IERC20, Ownable {
    string private _name;
    string private _symbol;
    uint8 public constant decimals = 18;

    uint256 private _totalSupply;

    mapping(address => uint256) private _balances;
    mapping(address => mapping(address => uint256)) private _allowances;

    /**
     * @notice Constructs the ERC-20 token with custom parameters.
     * @param name_ The name of the token (e.g., "Cypher Chat Token").
     * @param symbol_ The symbol of the token (e.g., "CYPHER").
     * @param initialSupply_ The initial supply in whole tokens (converted to 18 decimals).
     * @param recipient The address receiving the initial supply.
     */
    constructor(
        string memory name_,
        string memory symbol_,
        uint256 initialSupply_,
        address recipient
    ) Ownable(msg.sender) {
        require(bytes(name_).length > 0, "Token name required");
        require(bytes(symbol_).length > 0, "Token symbol required");
        require(recipient != address(0), "Recipient cannot be zero address");
        require(initialSupply_ > 0, "Initial supply must be greater than 0");

        _name = name_;
        _symbol = symbol_;

        // Mint full supply (converted to 18 decimals)
        _mint(recipient, initialSupply_ * 10 ** uint256(decimals));
    }

    // ---------------- ERC20 Standard ----------------

    function name() public view returns (string memory) {
        return _name;
    }

    function symbol() public view returns (string memory) {
        return _symbol;
    }

    function totalSupply() public view override returns (uint256) {
        return _totalSupply;
    }

    function balanceOf(address account) public view override returns (uint256) {
        return _balances[account];
    }

    function transfer(address recipient, uint256 amount) public override returns (bool) {
        _transfer(msg.sender, recipient, amount);
        return true;
    }

    function allowance(address owner_, address spender) public view override returns (uint256) {
        return _allowances[owner_][spender];
    }

    function approve(address spender, uint256 amount) public override returns (bool) {
        require(spender != address(0), "Approve to zero address");

        _allowances[msg.sender][spender] = amount;
        emit Approval(msg.sender, spender, amount);
        return true;
    }

    function transferFrom(address sender, address recipient, uint256 amount) public override returns (bool) {
        uint256 currentAllowance = _allowances[sender][msg.sender];
        require(currentAllowance >= amount, "Transfer amount exceeds allowance");

        _transfer(sender, recipient, amount);

        _allowances[sender][msg.sender] = currentAllowance - amount;
        emit Approval(sender, msg.sender, _allowances[sender][msg.sender]);
        return true;
    }

    // ---------------- Internal Transfers ----------------

    function _transfer(address sender, address recipient, uint256 amount) internal {
        require(sender != address(0), "Transfer from zero address");
        require(recipient != address(0), "Transfer to zero address");
        require(_balances[sender] >= amount, "Transfer amount exceeds balance");

        _balances[sender] -= amount;
        _balances[recipient] += amount;

        emit Transfer(sender, recipient, amount);
    }

    function _mint(address account, uint256 amount) internal {
        require(account != address(0), "Mint to zero address");

        _totalSupply += amount;
        _balances[account] += amount;

        emit Transfer(address(0), account, amount);
    }

    // ---------------- Extensions ----------------

    /**
     * @notice Burns tokens from the caller's account.
     * @param amount Amount to burn (in wei).
     */
    function burn(uint256 amount) external {
        require(_balances[msg.sender] >= amount, "Burn amount exceeds balance");

        _balances[msg.sender] -= amount;
        _totalSupply -= amount;

        emit Transfer(msg.sender, address(0), amount);
    }

    /**
     * @notice Allows owner to recover ERC20 tokens mistakenly sent to this contract.
     * @param token Address of the token to recover.
     * @param to Destination address.
     * @param amount Amount to recover.
     */
    function recoverERC20(address token, address to, uint256 amount) external onlyOwner {
        require(token != address(this), "Cannot recover own token");
        require(to != address(0), "Recipient cannot be zero address");

        bool success = IERC20(token).transfer(to, amount);
        require(success, "Token recovery failed");
    }
}

Tags:
ERC20, Multisig, Burnable, Multi-Signature, Factory|addr:0xeb3b8751aaa0b81adda817f75f459450fddebd36|verified:true|block:23587402|tx:0xdb4e328bb1b00273833082796690c35f712081a22bc8a99eaeb8f86278c1fc59|first_check:1760604658

Submitted on: 2025-10-16 10:51:01

Comments

Log in to comment.

No comments yet.