Skip to content
Verified contractExactMIT

Entity314159265358979323846264338327950

Address0xae395be59846d0830764b838ecd853e0a79fd594
Balance

0 ETH

 

Transactions

3

 

Compiler

solc 0.8.28

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.28+commit.7893614a
Language
solidity
Optimization
Yes, 200 runs
License
MIT
Match
Exactcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
26,444,056
Creation transaction
0x7d4a7e44d1…909723793a

Entity.sol

// SPDX-License-Identifier: MIT

/*
    entity ($3NT1TY)

    3.14159265358979323846264338327950288419716939937510582097494459
    2307816406286208998628034825342117067982148086513282306647093844
    6095505822317253594081284811174502841027019385211055596446229489
    5493038196442881097566593344612847564823378678316527120190914564
    85669234603486104543266482133936072602491412737245870

    it does not sleep.
    it does not blink.
    it sees every transfer, and it remembers.

    three hundred and eight were given.
*/

pragma solidity ^0.8.24;

interface IUniswapV3Factory {
    function createPool(address tokenA, address tokenB, uint24 fee) external returns (address pool);
}

interface IUniswapV3Pool {
    function initialize(uint160 sqrtPriceX96) external;
}

/// @title entity3141592653589793238462643383279502884197169399375105820974944592307816406286... (3NT1TY)
/// @notice ERC-20 that keeps a record of every transfer made with it. No tax, no fees, no mint, no blacklist.
///         - every transfer is observed: it is counted (`observations`), folded into one running hash (`mind`), and
///           both addresses have their first block, latest block and number of sightings recorded (`witnessed`)
///         - transfers are locked to the owner until `awaken()` (one-way)
///         - 0.314% max transaction / 3.14% max wallet until `unbind()` (one-way)
///         The whole supply is minted to the deployer for the liquidity pool; the contract holds nothing.
///         The constructor creates the 3NT1TY/WETH Uniswap V3 pool and sets its opening price.
contract Entity314159265358979323846264338327950 {
    /// @notice 314 characters: six letters, then the first 308 digits. There is no end to it; this is where it was cut.
    string public constant name =
        "entity31415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870";
    string public constant symbol = "3NT1TY";
    uint8 public constant decimals = 18;
    /// @notice 314,159,265,358: the first twelve
    uint256 public constant totalSupply = 314_159_265_358 * 10 ** 18;

    /// @notice Max transaction while bound: 0.314% of supply
    uint256 public constant MAX_OFFERING = (totalSupply * 314) / 100_000;
    /// @notice Max wallet while bound: 3.14% of supply
    uint256 public constant MAX_VESSEL = (totalSupply * 314) / 10_000;

    /// @notice The 3NT1TY/WETH Uniswap V3 pool, created here. The only address the max wallet does not apply to.
    address public immutable uniswapV3Pool;
    /// @notice The block it was made in. It has been watching since.
    uint256 public immutable firstLight;

    address public owner;
    /// @notice True once trading is enabled
    bool public awake;
    /// @notice True while the max transaction / max wallet limits apply
    bool public bound = true;

    /// @notice How many transfers it has seen
    uint64 public observations;
    /// @notice The block of the latest transfer it saw
    uint64 public lastObservedBlock;

    /// @notice Everything it has seen, folded into one word. Each transfer is hashed into the one before it.
    bytes32 public mind;

    /// @dev A holder's balance and what the entity knows about them share one storage slot.
    struct Trace {
        uint128 balance;
        uint40 firstSeen;
        uint40 lastSeen;
        uint48 sightings;
    }

    mapping(address => Trace) private _traces;
    mapping(address => mapping(address => uint256)) public allowance;
    /// @notice Addresses exempt from the trading lock and the launch limits
    mapping(address => bool) public isChosen;

    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);
    /// @notice One per transfer. `index` counts from 1; `mind` is the running hash after this transfer.
    event Observed(uint256 indexed index, address indexed from, address indexed to, uint256 value, bytes32 mind);
    event Awakened();
    event Unbound();

    error NotOwner();
    error ZeroAddress();
    error StillDormant();
    error AlreadyAwake();
    error AlreadyUnbound();
    error OfferingTooLarge();
    error VesselFull();
    error InsufficientBalance();
    error InsufficientAllowance();

    modifier onlyOwner() {
        if (msg.sender != owner) revert NotOwner();
        _;
    }

    /// @param factory_ Uniswap V3 factory
    /// @param weth_ WETH
    /// @param fee_ pool fee tier (10000 = 1%)
    /// @param sqrtPriceIfToken0 opening sqrtPriceX96 to use if this contract sorts below WETH (it is token0)
    /// @param sqrtPriceIfToken1 opening sqrtPriceX96 to use if it sorts above WETH (it is token1)
    constructor(address factory_, address weth_, uint24 fee_, uint160 sqrtPriceIfToken0, uint160 sqrtPriceIfToken1) {
        owner = msg.sender;
        firstLight = block.number;
        emit OwnershipTransferred(address(0), msg.sender);

        address pool = IUniswapV3Factory(factory_).createPool(address(this), weth_, fee_);
        IUniswapV3Pool(pool).initialize(address(this) < weth_ ? sqrtPriceIfToken0 : sqrtPriceIfToken1);
        uniswapV3Pool = pool;

        isChosen[msg.sender] = true;
        isChosen[address(this)] = true;
        isChosen[address(0xdead)] = true;

        // 100% to the deployer for the liquidity pool
        _traces[msg.sender].balance = uint128(totalSupply);
        emit Transfer(address(0), msg.sender, totalSupply);
    }

    // ───────────── owner ─────────────

    /// @notice Enables trading: opens transfers for everyone. Cannot be undone.
    function awaken() external onlyOwner {
        if (awake) revert AlreadyAwake();
        awake = true;
        emit Awakened();
    }

    /// @notice Removes the limits: max transaction (MAX_OFFERING) and max wallet (MAX_VESSEL), permanently.
    function unbind() external onlyOwner {
        if (!bound) revert AlreadyUnbound();
        bound = false;
        emit Unbound();
    }

    function transferOwnership(address newOwner) external onlyOwner {
        if (newOwner == address(0)) revert ZeroAddress();
        emit OwnershipTransferred(owner, newOwner);
        owner = newOwner;
    }

    /// @notice Only possible once trading is live, so the token can't be bricked.
    function renounceOwnership() external onlyOwner {
        if (!awake) revert StillDormant();
        emit OwnershipTransferred(owner, address(0));
        owner = address(0);
    }

    // ───────────── what it knows ─────────────

    /// @notice What it knows about an address: the block it first moved 3NT1TY in or out, the block it last did,
    ///         and how many transfers it has been part of. All zero means it has not been seen. Yet.
    function witnessed(address who) external view returns (uint256 firstSeen, uint256 lastSeen, uint256 sightings) {
        Trace storage t = _traces[who];
        return (t.firstSeen, t.lastSeen, t.sightings);
    }

    /// @notice Whether an address has ever sent or received 3NT1TY
    function hasSeen(address who) external view returns (bool) {
        return _traces[who].sightings != 0;
    }

    /// @notice It is.
    function isWatching(address) external pure returns (bool) {
        return true;
    }

    /// @notice It says something different depending on how much it has seen.
    function whisper() external view returns (string memory) {
        uint256 n = observations % 7;
        if (n == 0) return "three hundred and eight were given.";
        if (n == 1) return "the circle does not close.";
        if (n == 2) return "you were counted before you arrived.";
        if (n == 3) return "nothing here repeats. look again.";
        if (n == 4) return "it remembers the order of things.";
        if (n == 5) return "the next one is yours to say.";
        return "do not ask what it is. ask what it has seen.";
    }

    // ───────────── ERC-20 ─────────────

    function balanceOf(address who) public view returns (uint256) {
        return _traces[who].balance;
    }

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

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

    function transferFrom(address from, address to, uint256 amount) external returns (bool) {
        uint256 allowed = allowance[from][msg.sender];
        if (allowed != type(uint256).max) {
            if (allowed < amount) revert InsufficientAllowance();
            unchecked {
                allowance[from][msg.sender] = allowed - amount;
            }
        }
        _transfer(from, to, amount);
        return true;
    }

    function _transfer(address from, address to, uint256 amount) internal {
        if (to == address(0)) revert ZeroAddress();

        if (!(isChosen[from] || isChosen[to])) {
            if (!awake) revert StillDormant();
            if (bound) {
                if (amount > MAX_OFFERING) revert OfferingTooLarge();
                // the pool holds the liquidity, so the max wallet cannot apply to it
                if (to != uniswapV3Pool && balanceOf(to) + amount > MAX_VESSEL) revert VesselFull();
            }
        }

        // storage pointers, updated one after the other, so a transfer to yourself stays correct
        Trace storage f = _traces[from];
        if (f.balance < amount) revert InsufficientBalance();
        uint40 blockNow = uint40(block.number);
        unchecked {
            // amount <= balance <= totalSupply < 2^128, and the sum of balances == totalSupply
            f.balance -= uint128(amount);
            if (f.sightings == 0) f.firstSeen = blockNow;
            f.lastSeen = blockNow;
            f.sightings++;

            Trace storage t = _traces[to];
            t.balance += uint128(amount);
            if (t.sightings == 0) t.firstSeen = blockNow;
            t.lastSeen = blockNow;
            t.sightings++;
        }
        emit Transfer(from, to, amount);

        // it saw that
        uint64 index = ++observations;
        lastObservedBlock = uint64(block.number);
        bytes32 thought = keccak256(abi.encode(mind, index, from, to, amount, block.number));
        mind = thought;
        emit Observed(index, from, to, amount, thought);
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.