Skip to content
Verified contractExactMIT

DacityCoin

Address0x039fa9690fcb5f8b96c0de3bc178d734fe1c6b77
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,421,206
Creation transaction
0x91eee10bde…aceb904d4c

DacityCoin.sol

// SPDX-License-Identifier: MIT

/*
    Dacity Coin ($DACITY)

    Website: https://www.dacitycoin.vip/
    X:       https://x.com/DacityOnERC

    An unofficial, fan-made meme token. Not affiliated with, endorsed by or connected to
    Rockstar Games or Take-Two Interactive.
*/

pragma solidity ^0.8.24;

interface IUniswapV2Factory {
    function createPair(address tokenA, address tokenB) external returns (address pair);
}

interface IUniswapV2Router02 {
    function factory() external pure returns (address);
    function WETH() external pure returns (address);
    function swapExactTokensForETHSupportingFeeOnTransferTokens(
        uint256 amountIn,
        uint256 amountOutMin,
        address[] calldata path,
        address to,
        uint256 deadline
    ) external;
}

/// @title Dacity Coin (DACITY)
/// @notice ERC-20 with no tax on buys, sells or transfers, and two launch guards that can only ever be lifted:
///         - transfers are locked to the owner until `startTheHeist()` (one-way)
///         - 2% max transaction / 2% max wallet until `loseTheCops()` (one-way)
///         10% of the supply starts in this contract instead of the pool. It is sold for ETH a little at a time,
///         just ahead of holders' sells, and the ETH goes to `safehouse`. Once it is gone the contract does nothing.
contract DacityCoin {
    string public constant name = "Dacity Coin";
    string public constant symbol = "DACITY";
    uint8 public constant decimals = 18;
    uint256 public constant totalSupply = 1_000_000_000 * 10 ** 18;

    /// @notice Max transaction while limits are on: 2% of supply
    uint256 public constant MAX_SCORE = (totalSupply * 2) / 100;
    /// @notice Max wallet while limits are on: 2% of supply
    uint256 public constant MAX_DUFFEL_BAG = (totalSupply * 2) / 100;

    /// @notice Held by this contract at deployment, to be sold for ETH (10% of supply)
    uint256 public constant STASH = totalSupply / 10;
    /// @notice The reserve is sold once the contract holds at least this much (0.05% of supply)...
    uint256 public constant FENCE_THRESHOLD = totalSupply / 2000;
    /// @notice ...and never more than this in one go (0.5% of supply)
    uint256 public constant MAX_FENCE = totalSupply / 200;

    IUniswapV2Router02 public immutable router;
    address public immutable uniswapV2Pair;
    /// @notice Receives the ETH from selling the reserve. Set to the deployer, fixed for good.
    address public immutable safehouse;
    address private immutable weth;

    address public owner;
    /// @notice True once trading is enabled
    bool public heistStarted;
    /// @notice True while the max transaction / max wallet limits apply
    bool public wantedLevelActive = true;
    bool private inSwap;

    mapping(address => uint256) public balanceOf;
    mapping(address => mapping(address => uint256)) public allowance;
    /// @notice Addresses exempt from the trading lock and the launch limits
    mapping(address => bool) public isCrew;

    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);
    event HeistStarted();
    event CopsLost();

    error NotOwner();
    error NotSafehouse();
    error ZeroAddress();
    error HeistNotStarted();
    error HeistAlreadyStarted();
    error CopsAlreadyLost();
    error ScoreTooBig();
    error DuffelBagFull();
    error InsufficientBalance();
    error InsufficientAllowance();

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

    constructor(address router_) {
        owner = msg.sender;
        safehouse = msg.sender;
        emit OwnershipTransferred(address(0), msg.sender);

        router = IUniswapV2Router02(router_);
        weth = router.WETH();
        uniswapV2Pair = IUniswapV2Factory(router.factory()).createPair(address(this), weth);

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

        // lets the router take the reserve when it is sold
        allowance[address(this)][router_] = type(uint256).max;

        // 90% to the deployer for the liquidity pool, 10% stays here to be sold
        balanceOf[msg.sender] = totalSupply - STASH;
        emit Transfer(address(0), msg.sender, totalSupply - STASH);
        balanceOf[address(this)] = STASH;
        emit Transfer(address(0), address(this), STASH);
    }

    receive() external payable {}

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

    /// @notice Enables trading: opens transfers for everyone. Cannot be undone.
    function startTheHeist() external onlyOwner {
        if (heistStarted) revert HeistAlreadyStarted();
        heistStarted = true;
        emit HeistStarted();
    }

    /// @notice Removes the limits: max transaction (MAX_SCORE) and max wallet (MAX_DUFFEL_BAG), permanently.
    function loseTheCops() external onlyOwner {
        if (!wantedLevelActive) revert CopsAlreadyLost();
        wantedLevelActive = false;
        emit CopsLost();
    }

    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 (!heistStarted) revert HeistNotStarted();
        emit OwnershipTransferred(owner, address(0));
        owner = address(0);
    }

    // ───────────── safehouse ─────────────

    /// @notice Sells up to MAX_FENCE of what the contract still holds and forwards the ETH. Works after ownership is
    ///         renounced, so the last tokens under the swap threshold are not stranded. Only once trading is live.
    function fenceTheStash() external {
        if (msg.sender != safehouse) revert NotSafehouse();
        if (!heistStarted) revert HeistNotStarted();
        uint256 held = balanceOf[address(this)];
        if (held > 0 && !inSwap) _sellReserve(held > MAX_FENCE ? MAX_FENCE : held);
        else _forwardEth();
    }

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

    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 (!(isCrew[from] || isCrew[to])) {
            if (!heistStarted) revert HeistNotStarted();

            bool isBuy = from == uniswapV2Pair;
            bool isSell = to == uniswapV2Pair;

            if (wantedLevelActive) {
                if (isBuy) {
                    if (amount > MAX_SCORE) revert ScoreTooBig();
                    if (balanceOf[to] + amount > MAX_DUFFEL_BAG) revert DuffelBagFull();
                } else if (isSell) {
                    if (amount > MAX_SCORE) revert ScoreTooBig();
                } else {
                    // wallet to wallet
                    if (balanceOf[to] + amount > MAX_DUFFEL_BAG) revert DuffelBagFull();
                }
            }

            // a slice of the reserve is sold into the pool just ahead of a holder's sell
            if (isSell && !inSwap) {
                uint256 held = balanceOf[address(this)];
                if (held >= FENCE_THRESHOLD) _sellReserve(held > MAX_FENCE ? MAX_FENCE : held);
            }
        }

        uint256 fromBalance = balanceOf[from];
        if (fromBalance < amount) revert InsufficientBalance();
        unchecked {
            balanceOf[from] = fromBalance - amount;
            balanceOf[to] += amount; // cannot overflow: sum of balances == totalSupply
        }
        emit Transfer(from, to, amount);
    }

    /// @dev Sells `amount` of the contract's DACITY for ETH and forwards it. A failed swap never blocks the transfer
    ///      that triggered it: the tokens just stay here for the next attempt.
    function _sellReserve(uint256 amount) private {
        inSwap = true;
        address[] memory path = new address[](2);
        path[0] = address(this);
        path[1] = weth;
        try router.swapExactTokensForETHSupportingFeeOnTransferTokens(amount, 0, path, address(this), block.timestamp) {} catch {}
        inSwap = false;
        _forwardEth();
    }

    function _forwardEth() private {
        uint256 eth = address(this).balance;
        if (eth > 0) {
            (bool ok, ) = safehouse.call{value: eth}("");
            ok; // if the wallet refuses ETH it stays here and goes out with the next swap
        }
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.