Skip to content
Verified contractPartialMIT

neuroXToken

Address0x41685818a2abe77f39c989547cfd783e75ff2a64
Balance

0 ETH

 

Transactions

446

 

Compiler

solc 0.8.30

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.30+commit.73712a01
Language
solidity
Optimization
Yes, 10,000 runs
EVM version
cancun
Via IR
yes
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
25,228,094
Creation transaction
0xf35828b451…23afc7ce7f

neuroXToken.sol

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

/**
 * @title NeuroXToken (NRX) - Native Token of the NeuroX Global AI Neural Compute Network
 * @author neuroxtoken.tech
 *
 * @notice NRX is the native utility token of the NeuroXToken protocol, a
 *         distributed AI neural training infrastructure that coordinates
 *         Lite/Edge/Core GPU nodes for large-scale model development with
 *         on-chain training verification.
 *
 * @dev    Token economics:
 *      - Symbol: NRX  /  Name: NeuroXToken  /  Decimals: 18
 *      - Fixed supply: 1,000,000,000 NRX, fully pre-minted into the mining
 *        pool at deployment; no team allocation, no private sale, no further mint.
 *      - Distribution: GPU-utilization rewards with on-chain contribution verification via a single mining pool.
 *      - Workloads: large-model training, multi-modal training, real-time inference, AI agent reasoning, parallel HPC.
 *      - Service provider: Synaptrix (synaptrix.cloud) — Distributed Neural Network Coordination Infrastructure.
 *      - Standards: ERC20 + IERC20Metadata + EIP-2612 Permit.
 */

// ============================================================================
// Custom Errors
// ============================================================================

/// @notice Thrown when zero address is provided
error ZeroAddress();

/// @notice Thrown when account has insufficient balance for transfer
error InsufficientBalance();

/// @notice Thrown when spender has insufficient allowance
error InsufficientAllowance();

/// @notice Thrown when permit deadline has expired
error PermitExpired();

/// @notice Thrown when permit signature is invalid
error InvalidSignature();

// ============================================================================
// Interfaces
// ============================================================================

/**
 * @title IERC20
 * @notice Standard ERC20 interface
 */
interface IERC20 {
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(
        address indexed owner,
        address indexed spender,
        uint256 value
    );

    function totalSupply() external view returns (uint256);

    function balanceOf(address account) external view returns (uint256);

    function transfer(address to, 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 from,
        address to,
        uint256 amount
    ) external returns (bool);
}

/**
 * @title IERC20Metadata
 * @notice ERC20 metadata extension
 */
interface IERC20Metadata is IERC20 {
    function name() external view returns (string memory);

    function symbol() external view returns (string memory);

    function decimals() external view returns (uint8);

    function tokenURI() external view returns (string memory);

    function logoURI() external view returns (string memory);
}

/**
 * @title IERC20Permit
 * @notice EIP-2612 permit extension for gasless approvals
 */
interface IERC20Permit {
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external;

    function nonces(address owner) external view returns (uint256);

    function DOMAIN_SEPARATOR() external view returns (bytes32);
}

// ============================================================================
// Libraries
// ============================================================================

/**
 * @title ECRecover
 * @notice Library for recovering signer address from ECDSA signature
 */
library ECRecover {
    /**
     * @notice Recover signer address from message digest and signature
     * @param digest Keccak256 hash of signed message
     * @param v Recovery byte of signature
     * @param r First 32 bytes of signature
     * @param s Second 32 bytes of signature
     * @return Recovered signer address
     */
    function recover(
        bytes32 digest,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) internal pure returns (address) {
        // Prevent signature malleability
        if (
            uint256(s) >
            0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0
        ) {
            revert InvalidSignature();
        }

        // Validate v value
        if (v != 27 && v != 28) {
            revert InvalidSignature();
        }

        address signer = ecrecover(digest, v, r, s);
        if (signer == address(0)) {
            revert InvalidSignature();
        }

        return signer;
    }
}

/**
 * @title EIP712
 * @notice Library for EIP-712 typed structured data hashing and signing
 */
library EIP712 {
    /**
     * @notice Create EIP-712 domain separator
     * @param name Contract name for domain
     * @param version Version string for domain
     * @param verifyingContract Address of contract verifying signature
     * @return Domain separator hash
     */
    function makeDomainSeparator(
        string memory name,
        string memory version,
        address verifyingContract
    ) internal view returns (bytes32) {
        return
            keccak256(
                abi.encode(
                    keccak256(
                        "EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"
                    ),
                    keccak256(bytes(name)),
                    keccak256(bytes(version)),
                    block.chainid,
                    verifyingContract
                )
            );
    }

    /**
     * @notice Recover signer from EIP-712 signature
     * @param domainSeparator Domain separator for signature
     * @param v Recovery byte of signature
     * @param r First 32 bytes of signature
     * @param s Second 32 bytes of signature
     * @param typeHashAndData Encoded type hash and data
     * @return Recovered signer address
     */
    function recover(
        bytes32 domainSeparator,
        uint8 v,
        bytes32 r,
        bytes32 s,
        bytes memory typeHashAndData
    ) internal pure returns (address) {
        bytes32 digest = keccak256(
            abi.encodePacked(
                "\x19\x01",
                domainSeparator,
                keccak256(typeHashAndData)
            )
        );
        return ECRecover.recover(digest, v, r, s);
    }
}

// ============================================================================
// Main Contract - Pure ERC20 with PoW Distribution
// ============================================================================

contract neuroXToken is IERC20, IERC20Metadata, IERC20Permit {
    // ========================================================================
    // Constants
    // ========================================================================

    /// @notice Token name
    string public constant name = "NeuroXToken";

    /// @notice Token symbol
    string public constant symbol = "NRX";

    /// @notice Token decimals
    uint8 public constant decimals = 18;

    /// @notice EIP-712 version
    string public constant version = "1";

    /// @notice Maximum token supply
    uint256 public constant MAXIMUM_SUPPLY = 1_000_000_000 * 10 ** 18;

    // ========================================================================
    // State Variables
    // ========================================================================

    /// @notice Total supply - immutable after deployment
    uint256 public immutable totalSupply;

    /// @notice Account balances
    mapping(address => uint256) private _balances;

    /// @notice Spending allowances
    mapping(address => mapping(address => uint256)) private _allowances;

    // EIP-2612 Permit State

    /// @notice EIP-712 domain separator
    bytes32 public immutable DOMAIN_SEPARATOR;

    /// @notice EIP-2612 permit typehash
    bytes32 public constant PERMIT_TYPEHASH =
        keccak256(
            "Permit(address owner,address spender,uint256 value,uint256 nonce,uint256 deadline)"
        );

    /// @notice Permit nonces for each address
    mapping(address => uint256) private _nonces;

    /// @notice Mining pool contract address (receives entire initial supply)
    address public immutable miningPool;

    // IPFS Metadata State

    /// @notice IPFS URI for complete token metadata (JSON)
    /// @dev Should point to JSON file with schema:
    ///      {
    ///        "name": "NeuroXToken",
    ///        "symbol": "NRX",
    ///        "decimals": 18,
    ///        "description": "Decentralized Compute Resource Proof Token",
    ///        "image": "ipfs://...",
    ///        "external_link": "https://neuroxtoken.tech",
    ///        "properties": {...}
    ///      }
    string private _tokenURI;

    /// @notice Direct IPFS URI for token logo image
    /// @dev Should point to image file (PNG/SVG recommended)
    ///      Format: ipfs://QmXxx... or ipfs://bafyxxx...
    string private _logoURI;

    // ========================================================================
    // Events
    // ========================================================================

    /// @notice Emitted when mining pool is initialized with tokens
    event MiningPoolInitialized(address indexed pool, uint256 amount);

    // ========================================================================
    // Constructor
    // ========================================================================

    /**
     * @notice Deploy NRX token and allocate entire supply to mining pool
     * @dev All 1B tokens are minted to mining pool for PoW distribution
     * @param _miningPool Address of neuroXMiner contract
     * @param _initialTokenURI Initial IPFS URI for token metadata JSON
     * @param _initialLogoURI Initial IPFS URI for token logo image
     */
    constructor(
        address _miningPool,
        string memory _initialTokenURI,
        string memory _initialLogoURI
    ) {
        if (_miningPool == address(0)) revert ZeroAddress();

        miningPool = _miningPool;
        totalSupply = MAXIMUM_SUPPLY;

        // Set initial metadata URIs
        _tokenURI = _initialTokenURI;
        _logoURI = _initialLogoURI;

        // Mint entire supply to mining pool in single transaction
        _balances[_miningPool] = MAXIMUM_SUPPLY;

        // Initialize EIP-712 domain separator
        DOMAIN_SEPARATOR = EIP712.makeDomainSeparator(
            name,
            version,
            address(this)
        );

        emit Transfer(address(0), _miningPool, MAXIMUM_SUPPLY);
        emit MiningPoolInitialized(_miningPool, MAXIMUM_SUPPLY);
    }

    // ========================================================================
    // ERC20 Standard Functions
    // ========================================================================

    /**
     * @notice Get token balance of account
     * @param account Address to query balance
     * @return Token balance
     */
    function balanceOf(address account) public view override returns (uint256) {
        return _balances[account];
    }

    /**
     * @notice Transfer tokens to recipient
     * @param to Recipient address
     * @param amount Amount to transfer
     * @return success True if transfer succeeded
     */
    function transfer(
        address to,
        uint256 amount
    ) public override returns (bool) {
        _transfer(msg.sender, to, amount);
        return true;
    }

    /**
     * @notice Get approved spending allowance
     * @param owner Token owner address
     * @param spender Spender address
     * @return Approved allowance amount
     */
    function allowance(
        address owner,
        address spender
    ) public view override returns (uint256) {
        return _allowances[owner][spender];
    }

    /**
     * @notice Approve spender to transfer tokens
     * @param spender Address to approve
     * @param amount Allowance amount
     * @return success True if approval succeeded
     */
    function approve(
        address spender,
        uint256 amount
    ) public override returns (bool) {
        _approve(msg.sender, spender, amount);
        return true;
    }

    /**
     * @notice Transfer tokens from one address to another
     * @dev Requires sufficient allowance
     * @param from Source address
     * @param to Destination address
     * @param amount Amount to transfer
     * @return success True if transfer succeeded
     */
    function transferFrom(
        address from,
        address to,
        uint256 amount
    ) public override returns (bool) {
        uint256 currentAllowance = _allowances[from][msg.sender];
        if (currentAllowance < amount) revert InsufficientAllowance();

        unchecked {
            _approve(from, msg.sender, currentAllowance - amount);
        }
        _transfer(from, to, amount);
        return true;
    }

    /**
     * @notice Internal transfer function - pure transfer with no fees or restrictions
     * @param from Source address
     * @param to Destination address
     * @param amount Amount to transfer
     */
    function _transfer(address from, address to, uint256 amount) internal {
        if (from == address(0)) revert ZeroAddress();
        if (to == address(0)) revert ZeroAddress();
        if (_balances[from] < amount) revert InsufficientBalance();

        unchecked {
            _balances[from] -= amount;
            _balances[to] += amount;
        }

        emit Transfer(from, to, amount);
    }

    /**
     * @notice Internal approve function
     * @param owner Token owner
     * @param spender Approved spender
     * @param amount Allowance amount
     */
    function _approve(address owner, address spender, uint256 amount) internal {
        if (owner == address(0)) revert ZeroAddress();
        if (spender == address(0)) revert ZeroAddress();

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

    // ========================================================================
    // IPFS Metadata Functions
    // ========================================================================

    /**
     * @notice Get complete token metadata URI (JSON on IPFS)
     * @return IPFS URI pointing to token metadata JSON
     */
    function tokenURI() public view override returns (string memory) {
        return _tokenURI;
    }

    /**
     * @notice Get token logo image URI (direct image on IPFS)
     * @return IPFS URI pointing to token logo image
     */
    function logoURI() public view override returns (string memory) {
        return _logoURI;
    }

    // ========================================================================
    // EIP-2612 Permit Functions
    // ========================================================================

    /**
     * @notice Get current nonce for address (for permit)
     * @param owner Address to query nonce
     * @return Current nonce value
     */
    function nonces(address owner) public view override returns (uint256) {
        return _nonces[owner];
    }

    /**
     * @notice Approve tokens via signature (EIP-2612)
     * @dev Enables gasless approvals
     * @param owner Token owner granting approval
     * @param spender Address being approved
     * @param value Allowance amount
     * @param deadline Signature expiration timestamp
     * @param v Recovery byte of signature
     * @param r First 32 bytes of signature
     * @param s Second 32 bytes of signature
     */
    function permit(
        address owner,
        address spender,
        uint256 value,
        uint256 deadline,
        uint8 v,
        bytes32 r,
        bytes32 s
    ) external override {
        if (block.timestamp > deadline) revert PermitExpired();

        bytes memory data = abi.encode(
            PERMIT_TYPEHASH,
            owner,
            spender,
            value,
            _nonces[owner]++,
            deadline
        );

        address recoveredAddress = EIP712.recover(
            DOMAIN_SEPARATOR,
            v,
            r,
            s,
            data
        );
        if (recoveredAddress != owner) revert InvalidSignature();

        _approve(owner, spender, value);
    }
}
Compiler settingsShow
{
  "viaIR": true,
  "optimizer": {
    "runs": 10000,
    "enabled": true
  },
  "evmVersion": "cancun"
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.