Skip to content
Verified contractPartialMIT

MetaBums

Address0xa70613ade175770eebe8d2a36ef512404b5ddc5d
Balance

0 ETH

 

Transactions

375

 

Compiler

solc 0.8.15

 

Same code

Only this contract

 

Details

Compiler
solc 0.8.15+commit.e14f2714
Language
solidity
Optimization
Yes, 200 runs
License
MIT
Match
Partialcreation code: yes, runtime code: yes
Verified on Sourcify
Created in block
15,360,836
Creation transaction
0x7ea35d3bba…4c997ce47e

MetaBums.sol

//SPDX-License-Identifier: MIT

pragma solidity >=0.8.0;

// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)

/**
 * @dev String operations.
 */
library Strings {
    bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
    uint8 private constant _ADDRESS_LENGTH = 20;

    /**
     * @dev Converts a `uint256` to its ASCII `string` decimal representation.
     */
    function toString(uint256 value) internal pure returns (string memory) {
        // Inspired by OraclizeAPI's implementation - MIT licence
        // https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol

        if (value == 0) {
            return "0";
        }
        uint256 temp = value;
        uint256 digits;
        while (temp != 0) {
            digits++;
            temp /= 10;
        }
        bytes memory buffer = new bytes(digits);
        while (value != 0) {
            digits -= 1;
            buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
            value /= 10;
        }
        return string(buffer);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
     */
    function toHexString(uint256 value) internal pure returns (string memory) {
        if (value == 0) {
            return "0x00";
        }
        uint256 temp = value;
        uint256 length = 0;
        while (temp != 0) {
            length++;
            temp >>= 8;
        }
        return toHexString(value, length);
    }

    /**
     * @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
     */
    function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
        bytes memory buffer = new bytes(2 * length + 2);
        buffer[0] = "0";
        buffer[1] = "x";
        for (uint256 i = 2 * length + 1; i > 1; --i) {
            buffer[i] = _HEX_SYMBOLS[value & 0xf];
            value >>= 4;
        }
        require(value == 0, "Strings: hex length insufficient");
        return string(buffer);
    }

    /**
     * @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
     */
    function toHexString(address addr) internal pure returns (string memory) {
        return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
    }
}

// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)

// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)

/**
 * @dev Provides information about the current execution context, including the
 * sender of the transaction and its data. While these are generally available
 * via msg.sender and msg.data, they should not be accessed in such a direct
 * manner, since when dealing with meta-transactions the account sending and
 * paying for execution may not be the actual sender (as far as an application
 * is concerned).
 *
 * This contract is only required for intermediate, library-like contracts.
 */
abstract contract Context {
    function _msgSender() internal view virtual returns (address) {
        return msg.sender;
    }

    function _msgData() internal view virtual returns (bytes calldata) {
        return msg.data;
    }
}

/**
 * @dev Contract module which provides a basic access control mechanism, where
 * there is an account (an owner) that can be granted exclusive access to
 * specific functions.
 *
 * By default, the owner account will be the one that deploys the contract. This
 * can later be changed with {transferOwnership}.
 *
 * This module is used through inheritance. It will make available the modifier
 * `onlyOwner`, which can be applied to your functions to restrict their use to
 * the owner.
 */
abstract contract Ownable is Context {
    address private _owner;

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

    /**
     * @dev Initializes the contract setting the deployer as the initial owner.
     */
    constructor() {
        _transferOwnership(_msgSender());
    }

    /**
     * @dev Throws if called by any account other than the owner.
     */
    modifier onlyOwner() {
        _checkOwner();
        _;
    }

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

    /**
     * @dev Throws if the sender is not the owner.
     */
    function _checkOwner() internal view virtual {
        require(owner() == _msgSender(), "Ownable: caller is not the owner");
    }

    /**
     * @dev Leaves the contract without owner. It will not be possible to call
     * `onlyOwner` functions anymore. Can only be called by the current owner.
     *
     * NOTE: Renouncing ownership will leave the contract without an owner,
     * thereby removing any functionality that is only available to the owner.
     */
    function renounceOwnership() public virtual onlyOwner {
        _transferOwnership(address(0));
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Can only be called by the current owner.
     */
    function transferOwnership(address newOwner) public virtual onlyOwner {
        require(newOwner != address(0), "Ownable: new owner is the zero address");
        _transferOwnership(newOwner);
    }

    /**
     * @dev Transfers ownership of the contract to a new account (`newOwner`).
     * Internal function without access restriction.
     */
    function _transferOwnership(address newOwner) internal virtual {
        address oldOwner = _owner;
        _owner = newOwner;
        emit OwnershipTransferred(oldOwner, newOwner);
    }
}

/// @notice Modern, minimalist, and gas efficient ERC-721 implementation.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol)
abstract contract ERC721 {
    /*//////////////////////////////////////////////////////////////
                                 EVENTS
    //////////////////////////////////////////////////////////////*/

    event Transfer(address indexed from, address indexed to, uint256 indexed id);

    event Approval(address indexed owner, address indexed spender, uint256 indexed id);

    event ApprovalForAll(address indexed owner, address indexed operator, bool approved);

    /*//////////////////////////////////////////////////////////////
                         METADATA STORAGE/LOGIC
    //////////////////////////////////////////////////////////////*/

    string public name;

    string public symbol;

    function tokenURI(uint256 id) public view virtual returns (string memory);

    /*//////////////////////////////////////////////////////////////
                      ERC721 BALANCE/OWNER STORAGE
    //////////////////////////////////////////////////////////////*/

    mapping(uint256 => address) internal _ownerOf;

    mapping(address => uint256) internal _balanceOf;

    function ownerOf(uint256 id) public view virtual returns (address owner) {
        require((owner = _ownerOf[id]) != address(0), "NOT_MINTED");
    }

    function balanceOf(address owner) public view virtual returns (uint256) {
        require(owner != address(0), "ZERO_ADDRESS");

        return _balanceOf[owner];
    }

    /*//////////////////////////////////////////////////////////////
                         ERC721 APPROVAL STORAGE
    //////////////////////////////////////////////////////////////*/

    mapping(uint256 => address) public getApproved;

    mapping(address => mapping(address => bool)) public isApprovedForAll;

    /*//////////////////////////////////////////////////////////////
                               CONSTRUCTOR
    //////////////////////////////////////////////////////////////*/

    constructor(string memory _name, string memory _symbol) {
        name = _name;
        symbol = _symbol;
    }

    /*//////////////////////////////////////////////////////////////
                              ERC721 LOGIC
    //////////////////////////////////////////////////////////////*/

    function approve(address spender, uint256 id) public virtual {
        address owner = _ownerOf[id];

        require(msg.sender == owner || isApprovedForAll[owner][msg.sender], "NOT_AUTHORIZED");

        getApproved[id] = spender;

        emit Approval(owner, spender, id);
    }

    function setApprovalForAll(address operator, bool approved) public virtual {
        isApprovedForAll[msg.sender][operator] = approved;

        emit ApprovalForAll(msg.sender, operator, approved);
    }

    function transferFrom(
        address from,
        address to,
        uint256 id
    ) public virtual {
        require(from == _ownerOf[id], "WRONG_FROM");

        require(to != address(0), "INVALID_RECIPIENT");

        require(
            msg.sender == from || isApprovedForAll[from][msg.sender] || msg.sender == getApproved[id],
            "NOT_AUTHORIZED"
        );

        // Underflow of the sender's balance is impossible because we check for
        // ownership above and the recipient's balance can't realistically overflow.
        unchecked {
            _balanceOf[from]--;

            _balanceOf[to]++;
        }

        _ownerOf[id] = to;

        delete getApproved[id];

        emit Transfer(from, to, id);
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 id
    ) public virtual {
        transferFrom(from, to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, "") ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function safeTransferFrom(
        address from,
        address to,
        uint256 id,
        bytes calldata data
    ) public virtual {
        transferFrom(from, to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, from, id, data) ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    /*//////////////////////////////////////////////////////////////
                              ERC165 LOGIC
    //////////////////////////////////////////////////////////////*/

    function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
        return
            interfaceId == 0x01ffc9a7 || // ERC165 Interface ID for ERC165
            interfaceId == 0x80ac58cd || // ERC165 Interface ID for ERC721
            interfaceId == 0x5b5e139f; // ERC165 Interface ID for ERC721Metadata
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL MINT/BURN LOGIC
    //////////////////////////////////////////////////////////////*/

    function _mint(address to, uint256 id) internal virtual {
        require(to != address(0), "INVALID_RECIPIENT");

        require(_ownerOf[id] == address(0), "ALREADY_MINTED");

        // Counter overflow is incredibly unrealistic.
        unchecked {
            _balanceOf[to]++;
        }

        _ownerOf[id] = to;

        emit Transfer(address(0), to, id);
    }

    function _burn(uint256 id) internal virtual {
        address owner = _ownerOf[id];

        require(owner != address(0), "NOT_MINTED");

        // Ownership check above ensures no underflow.
        unchecked {
            _balanceOf[owner]--;
        }

        delete _ownerOf[id];

        delete getApproved[id];

        emit Transfer(owner, address(0), id);
    }

    /*//////////////////////////////////////////////////////////////
                        INTERNAL SAFE MINT LOGIC
    //////////////////////////////////////////////////////////////*/

    function _safeMint(address to, uint256 id) internal virtual {
        _mint(to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, "") ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }

    function _safeMint(
        address to,
        uint256 id,
        bytes memory data
    ) internal virtual {
        _mint(to, id);

        require(
            to.code.length == 0 ||
                ERC721TokenReceiver(to).onERC721Received(msg.sender, address(0), id, data) ==
                ERC721TokenReceiver.onERC721Received.selector,
            "UNSAFE_RECIPIENT"
        );
    }
}

/// @notice A generic interface for a contract which properly accepts ERC721 tokens.
/// @author Solmate (https://github.com/Rari-Capital/solmate/blob/main/src/tokens/ERC721.sol)
abstract contract ERC721TokenReceiver {
    function onERC721Received(
        address,
        address,
        uint256,
        bytes calldata
    ) external virtual returns (bytes4) {
        return ERC721TokenReceiver.onERC721Received.selector;
    }
}

//****************************************************************************// 
// WELCOME TO THE CRYPTO WINTER. IT'S TIME TO BURN SOME TRASH FOR HEAT IF YOU //
//            WANT TO SURVIVE THE CYPHERPUNK DYSTOPIA WE CALL ...             //
//                     __             __                                      //
//     /'\_/`\        /\ \__         /\ \                                     //
//    /\      \     __\ \ ,_\    __  \ \ \____  __  __    ___ ___     ____    //
//    \ \ \__\ \  /'__`\ \ \/  /'__`\ \ \ '__`\/\ \/\ \ /' __` __`\  /',__\   //
//     \ \ \_/\ \/\  __/\ \ \_/\ \L\.\_\ \ \L\ \ \ \_\ \/\ \/\ \/\ \/\__, `\  //
//      \ \_\\ \_\ \____\\ \__\ \__/.\_\\ \_,__/\ \____/\ \_\ \_\ \_\/\____/  //
//       \/_/ \/_/\/____/ \/__/\/__/\/_/ \/___/  \/___/  \/_/\/_/\/_/\/___/   //
//                                 __________________                         //
//                                  \................\                        //
//                                   \.................\                      //
//                                     \.................\                    //
//                                       \xxxxxxxxxxxxxxxxx\                  //
//                      /-------------------------------------                //
//                    //xxxxxxxxxxxxxxx//                 // |                //
//                  //               //                  //  |                //
//                //               //                  / /  ||                //
//              //               //                  / /    ||                //
//            //_______________//                  / /      ||                //
//           -------------------------------------/ /------- |                //
//           |    WASTE    |    NO   |RESIDENTIAL|           |                //
//           |  MANAGEMENT |RECYCLING|TRASH ONLY |           |                //
//           |-----------------------------------|           |                //     
//           | PROPERTY OF METABUMS INCORPORATED |           |                //
//           -------------------------------------------------                //
//****************************************************************************// 

contract MetaBums is ERC721, Ownable {
    // saves 66 gas using < MAX+1 rather than <= MAX
    uint256 public constant MAX_SUPPLY_PLUS_ONE = 6970;

    bool public metadataFrozen;
    uint256 public totalSupply;
    string public baseURI;
    mapping(address => uint256) bumAdopters;

    uint256 public trash = type(uint256).max;
    bytes32 public fire;

    mapping(address=>uint) public donations;

    event Shout(string exclamation);

    constructor(string memory _baseURI) ERC721("Metabums", "BUMS") {
        baseURI = _baseURI;
        _mint(msg.sender, 0);
        totalSupply = 1;
    }

    function adoptABum(uint8 quantity) external fleeTheRobotOverlords payable {
        uint256 currentId = totalSupply;
        require(quantity > 0 && quantity < 6, "BAD_QUANTITY");
        require(currentId + quantity < MAX_SUPPLY_PLUS_ONE, "MINT_COMPLETE");
        require(bumAdopters[msg.sender] == 0, "CAN_ONLY_MINT_ONCE");
        for (uint i = 0; i < quantity; ++i)
            _mint(msg.sender, currentId + i);
        unchecked{ totalSupply += quantity; }
        if(msg.value > 0)
            donations[msg.sender] = donations[msg.sender] + msg.value;
        bumAdopters[msg.sender] = 1 + uint(bytes32(abi.encodePacked(msg.sender))) ^ uint(blockhash(block.number));
    }

    function burnTrashForHeat() external fleeTheRobotOverlords {
        unchecked {
            trash -= 1;
            fire = keccak256(abi.encodePacked(blockhash(block.number), msg.sender, trash));
        }
    }

    function moveBackInWithMom(address basement) external fleeTheRobotOverlords {
        address mom = _ownerOf[0];
        unchecked {
            _balanceOf[mom]--;
            _balanceOf[basement]++;
        }
        _ownerOf[0] = basement;
        delete getApproved[0];
        emit Transfer(mom, basement, 0);
    }

    function begForChange() external fleeTheRobotOverlords payable { 
        require(msg.value != 0, "MUST_PAY");
        unchecked{
            donations[msg.sender] = donations[msg.sender] + msg.value;
            fire = keccak256(abi.encodePacked(msg.value)) ^ fire;
        }
    }

    function holla(uint wut, address atyaboi) external fleeTheRobotOverlords {
        bool robot = toBool(uint256(keccak256(abi.encodePacked(block.number))) % 2);
        uint firstLetter = wut;
        uint secondLetter = wut % 8 + bumAdopters[msg.sender] + donations[msg.sender];
        uint thirdLetter = addmod(uint(bytes32(abi.encode(address(msg.sender)))), trash, 26);
        (bool dongle, bytes memory port) = atyaboi.call(abi.encode(robot));
        uint fourthLetter = addmod(uint(bytes32(port)), thirdLetter, 26);
        string memory out;
        if(!(robot && dongle)) {
            out = string.concat(
                uintToString(firstLetter),
                uintToString(secondLetter),
                uintToString(thirdLetter),
                uintToString(fourthLetter)
            );
        } else {
            // THE AI APOCALYPSE COMETH
            out = string.concat(
                Strings.toHexString(firstLetter % 10),
                Strings.toHexString(secondLetter % 10),
                Strings.toHexString(thirdLetter % 10),
                Strings.toHexString(fourthLetter % 10 )
            );
        }
        emit Shout(out);
    }

    function tokenURI(uint256 _tokenId) public view virtual override returns (string memory) {
        require(ownerOf(_tokenId) != address(0));
        return string(abi.encodePacked(baseURI, paddedString(_tokenId), ".json"));
    }

    function paddedString(uint256 _tokenId) internal pure returns (string memory) {
        if(_tokenId > 999)
            return Strings.toString(_tokenId);
        if (_tokenId > 99)
            return string.concat("0", Strings.toString(_tokenId));
        if (_tokenId > 9)
            return string.concat("00", Strings.toString(_tokenId));
        return string.concat("000", Strings.toString(_tokenId));
    }

    function updateBaseURI(string memory _baseURI) external onlyOwner {
        require(metadataFrozen == false, "METADATA_FROZEN");
        baseURI = _baseURI;
    }

    function freezeBaseURI() external onlyOwner {
        metadataFrozen = true;
    }

    function toBool(uint256 x) internal pure returns (bool r) {
        assembly { r := x }
    }

    function uintToString(uint256 x) internal pure returns (string memory) {
        bytes memory LETTERS = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
        bytes memory _string = new bytes(1);
        _string[0] = LETTERS[x % 26];
        return string(_string);
    }

    modifier fleeTheRobotOverlords() {
        require(msg.sender.code.length == 0, "ERR_NO_BOTS");
        _;
    }

    function bankTheUnbanked() external onlyOwner {
        payable(owner()).transfer(address(this).balance);
    }
}
Compiler settingsShow
{
  "optimizer": {
    "runs": 200,
    "enabled": true
  }
}

Source code and metadata: Sourcify.

The source code belongs to the authors of the contract.