Feature Tip: Add private address tag to any address under My Name Tag !
Overview
TokenID
2609
Total Transfers
-
Market
Onchain Market Cap
$0.00
Circulating Supply Market Cap
-
Other Info
Token Contract
Loading...
Loading
Loading...
Loading
Loading...
Loading
# | Exchange | Pair | Price | 24H Volume | % Volume |
---|
Contract Name:
Gm
Compiler Version
v0.8.9+commit.e5eed63a
Contract Source Code (Solidity Standard Json-Input format)
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.9; import {IBaseERC721Interface, ConfigSettings} from "gwei-slim-nft-contracts/contracts/base/ERC721Base.sol"; import {ERC721Delegated} from "gwei-slim-nft-contracts/contracts/base/ERC721Delegated.sol"; import {StringsUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import {CountersUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import {AddressUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol"; import {GmRenderer} from "./GmRenderer.sol"; import {Base64} from "base64-sol/base64.sol"; /** GGGGGGGGGGGGGMMMMMMMM MMMMMMMM GGG::::::::::::GM:::::::M M:::::::M GG:::::::::::::::GM::::::::M M::::::::M G:::::GGGGGGGG::::GM:::::::::M M:::::::::M G:::::G GGGGGGM::::::::::M M::::::::::M G:::::G M:::::::::::M M:::::::::::M G:::::G M:::::::M::::M M::::M:::::::M G:::::G GGGGGGGGGGM::::::M M::::M M::::M M::::::M G:::::G G::::::::GM::::::M M::::M::::M M::::::M G:::::G GGGGG::::GM::::::M M:::::::M M::::::M G:::::G G::::GM::::::M M:::::M M::::::M G:::::G G::::GM::::::M MMMMM M::::::M G:::::GGGGGGGG::::GM::::::M M::::::M GG:::::::::::::::GM::::::M M::::::M GGG::::::GGG:::GM::::::M M::::::M GGGGGG GGGGMMMMMMMM MMMMMMMM */ /// @author twitter.com/brxckinridge /// @author twitter.com/isiain /// @notice gm contract Gm is ERC721Delegated { using CountersUpgradeable for CountersUpgradeable.Counter; CountersUpgradeable.Counter private currentTokenId; uint256 public immutable maxSupply; uint256 public salePrice; GmRenderer public renderer; mapping(uint256 => bytes32) private mintSeeds; mapping(uint256 => bool) private hasHadCoffee; event DrankCoffee(uint256 indexed tokenId, address indexed actor); constructor( address baseFactory, address _rendererAddress, uint256 _maxSupply ) ERC721Delegated( baseFactory, "gm", "gm", ConfigSettings({ royaltyBps: 1000, uriBase: "", uriExtension: "", hasTransferHook: false }) ) { renderer = GmRenderer(_rendererAddress); maxSupply = _maxSupply; } /// @notice drinks coffee and updates the seed, only able to be called once /// @param tokenId The token ID for the token function drinkCoffee(uint256 tokenId) public { require(_isApprovedOrOwner(msg.sender, tokenId), "Needs to own"); require(!hasHadCoffee[tokenId], "Already had coffee"); hasHadCoffee[tokenId] = true; mintSeeds[tokenId] = _generateSeed(tokenId); emit DrankCoffee(tokenId, msg.sender); } /// @notice sets the sale price for Gm /// @param newPrice, the new price to mint new gms function setSalePrice(uint256 newPrice) public onlyOwner { salePrice = newPrice; } /// @notice returns number of mints left before sell out function mintsLeft() external view returns (uint256) { return maxSupply - currentTokenId.current(); } /// @notice mints (count) new gms /// @param count, the number of gms to mint function mint(uint256 count) public payable { require(currentTokenId.current() + count <= maxSupply, "Gm: mint would exceed max supply"); require(salePrice != 0, "Gm: sale not started"); require(count <= 10, "Gm: cannot mint more than 10 in one transaction"); require(msg.value == salePrice * count, "Gm: wrong sale price"); for (uint256 i = 0; i < count; i++) { mintSeeds[currentTokenId.current()] = _generateSeed( currentTokenId.current() ); _mint(msg.sender, currentTokenId.current()); currentTokenId.increment(); } } /// @notice burns the gm /// @param tokenId, the token id of be burned function burn(uint256 tokenId) public { require( _isApprovedOrOwner(msg.sender, tokenId), "Gm: only approved or owner can burn" ); _burn(tokenId); } /// @notice withdraws the eth funds from the contract to the owner function withdraw() external onlyOwner { // No need for gas limit to trusted address. AddressUpgradeable.sendValue(payable(_owner()), address(this).balance); } /// @notice returns the base64 encoded svg /// @param data, bytes representing the svg function svgBase64Data(bytes memory data) internal pure returns (string memory) { return string( abi.encodePacked( "data:image/svg+xml;base64,", Base64.encode(data) ) ); } /// @notice returns the base64 data uri metadata json /// @param tokenId, the token id of the gm function tokenURI(uint256 tokenId) public view returns (string memory) { string memory json; (bytes memory tokenData, bytes memory name, bytes memory bgColor, bytes memory fontColor, bytes memory filter) = renderer.svgRaw( mintSeeds[tokenId] ); bytes memory caff; if (hasHadCoffee[tokenId]) { caff = "Yes"; } else { caff = "No"; } bytes memory attributes = abi.encodePacked('"attributes": [', '{"trait_type":"style","value":"', name, '"},{"trait_type":"background color","value":"', bgColor, '"},{"trait_type":"font color","value":"', fontColor, '"},{"trait_type":"caffeinated","value":"', caff, '"},{"trait_type":"effect","value":"', filter, '"}]'); json = Base64.encode( bytes( string( abi.encodePacked( '{"description": "gm-onchain is a collection of 6969 randomly generated, onchain renderings of our favorite crypto phrase. enjoy.",', '"title": "gm ', StringsUpgradeable.toString(tokenId), '", "image": "', svgBase64Data(tokenData), '",', attributes, '}' ) ) ) ); return string(abi.encodePacked("data:application/json;base64,", json)); } /// @notice returns the seed for the tokenId /// @param tokenId, the token id of the gm function seed(uint256 tokenId) external view returns (bytes32) { return mintSeeds[tokenId]; } /// @notice generates a pseudo random seed /// @param tokenId, the token id of the gm function _generateSeed(uint256 tokenId) private view returns (bytes32) { return keccak256(abi.encodePacked( msg.sender, tx.gasprice, tokenId, block.number, block.timestamp, blockhash(block.number - 1) ) ); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (access/Ownable.sol) pragma solidity ^0.8.0; import "../utils/ContextUpgradeable.sol"; import "../proxy/utils/Initializable.sol"; /** * @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 OwnableUpgradeable is Initializable, ContextUpgradeable { address private _owner; event OwnershipTransferred(address indexed previousOwner, address indexed newOwner); /** * @dev Initializes the contract setting the deployer as the initial owner. */ function __Ownable_init() internal onlyInitializing { __Context_init_unchained(); __Ownable_init_unchained(); } function __Ownable_init_unchained() internal onlyInitializing { _transferOwnership(_msgSender()); } /** * @dev Returns the address of the current owner. */ function owner() public view virtual returns (address) { return _owner; } /** * @dev Throws if called by any account other than the owner. */ modifier onlyOwner() { 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); } uint256[49] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC165.sol) pragma solidity ^0.8.0; import "../utils/introspection/IERC165Upgradeable.sol";
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC2981.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; /** * @dev Interface for the NFT Royalty Standard */ interface IERC2981Upgradeable is IERC165Upgradeable { /** * @dev Called with the sale price to determine how much royalty is owed and to whom. * @param tokenId - the NFT asset queried for royalty information * @param salePrice - the sale price of the NFT asset specified by `tokenId` * @return receiver - address of who should be sent the royalty payment * @return royaltyAmount - the royalty payment amount for `salePrice` */ function royaltyInfo(uint256 tokenId, uint256 salePrice) external view returns (address receiver, uint256 royaltyAmount); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol) pragma solidity ^0.8.0; import "../../utils/AddressUpgradeable.sol"; /** * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect. * * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}. * * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity. * * [CAUTION] * ==== * Avoid leaving a contract uninitialized. * * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed: * * [.hljs-theme-light.nopadding] * ``` * /// @custom:oz-upgrades-unsafe-allow constructor * constructor() initializer {} * ``` * ==== */ abstract contract Initializable { /** * @dev Indicates that the contract has been initialized. */ bool private _initialized; /** * @dev Indicates that the contract is in the process of being initialized. */ bool private _initializing; /** * @dev Modifier to protect an initializer function from being invoked twice. */ modifier initializer() { // If the contract is initializing we ignore whether _initialized is set in order to support multiple // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the // contract may have been reentered. require(_initializing ? _isConstructor() : !_initialized, "Initializable: contract is already initialized"); bool isTopLevelCall = !_initializing; if (isTopLevelCall) { _initializing = true; _initialized = true; } _; if (isTopLevelCall) { _initializing = false; } } /** * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the * {initializer} modifier, directly or indirectly. */ modifier onlyInitializing() { require(_initializing, "Initializable: contract is not initializing"); _; } function _isConstructor() private view returns (bool) { return !AddressUpgradeable.isContract(address(this)); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol) pragma solidity ^0.8.0; import "./IERC721Upgradeable.sol"; import "./IERC721ReceiverUpgradeable.sol"; import "./extensions/IERC721MetadataUpgradeable.sol"; import "../../utils/AddressUpgradeable.sol"; import "../../utils/ContextUpgradeable.sol"; import "../../utils/StringsUpgradeable.sol"; import "../../utils/introspection/ERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including * the Metadata extension, but not including the Enumerable extension, which is available separately as * {ERC721Enumerable}. */ contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable { using AddressUpgradeable for address; using StringsUpgradeable for uint256; // Token name string private _name; // Token symbol string private _symbol; // Mapping from token ID to owner address mapping(uint256 => address) private _owners; // Mapping owner address to token count mapping(address => uint256) private _balances; // Mapping from token ID to approved address mapping(uint256 => address) private _tokenApprovals; // Mapping from owner to operator approvals mapping(address => mapping(address => bool)) private _operatorApprovals; /** * @dev Initializes the contract by setting a `name` and a `symbol` to the token collection. */ function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing { __Context_init_unchained(); __ERC165_init_unchained(); __ERC721_init_unchained(name_, symbol_); } function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing { _name = name_; _symbol = symbol_; } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) { return interfaceId == type(IERC721Upgradeable).interfaceId || interfaceId == type(IERC721MetadataUpgradeable).interfaceId || super.supportsInterface(interfaceId); } /** * @dev See {IERC721-balanceOf}. */ function balanceOf(address owner) public view virtual override returns (uint256) { require(owner != address(0), "ERC721: balance query for the zero address"); return _balances[owner]; } /** * @dev See {IERC721-ownerOf}. */ function ownerOf(uint256 tokenId) public view virtual override returns (address) { address owner = _owners[tokenId]; require(owner != address(0), "ERC721: owner query for nonexistent token"); return owner; } /** * @dev See {IERC721Metadata-name}. */ function name() public view virtual override returns (string memory) { return _name; } /** * @dev See {IERC721Metadata-symbol}. */ function symbol() public view virtual override returns (string memory) { return _symbol; } /** * @dev See {IERC721Metadata-tokenURI}. */ function tokenURI(uint256 tokenId) public view virtual override returns (string memory) { require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token"); string memory baseURI = _baseURI(); return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : ""; } /** * @dev Base URI for computing {tokenURI}. If set, the resulting URI for each * token will be the concatenation of the `baseURI` and the `tokenId`. Empty * by default, can be overriden in child contracts. */ function _baseURI() internal view virtual returns (string memory) { return ""; } /** * @dev See {IERC721-approve}. */ function approve(address to, uint256 tokenId) public virtual override { address owner = ERC721Upgradeable.ownerOf(tokenId); require(to != owner, "ERC721: approval to current owner"); require( _msgSender() == owner || isApprovedForAll(owner, _msgSender()), "ERC721: approve caller is not owner nor approved for all" ); _approve(to, tokenId); } /** * @dev See {IERC721-getApproved}. */ function getApproved(uint256 tokenId) public view virtual override returns (address) { require(_exists(tokenId), "ERC721: approved query for nonexistent token"); return _tokenApprovals[tokenId]; } /** * @dev See {IERC721-setApprovalForAll}. */ function setApprovalForAll(address operator, bool approved) public virtual override { _setApprovalForAll(_msgSender(), operator, approved); } /** * @dev See {IERC721-isApprovedForAll}. */ function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) { return _operatorApprovals[owner][operator]; } /** * @dev See {IERC721-transferFrom}. */ function transferFrom( address from, address to, uint256 tokenId ) public virtual override { //solhint-disable-next-line max-line-length require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _transfer(from, to, tokenId); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId ) public virtual override { safeTransferFrom(from, to, tokenId, ""); } /** * @dev See {IERC721-safeTransferFrom}. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes memory _data ) public virtual override { require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved"); _safeTransfer(from, to, tokenId, _data); } /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * `_data` is additional data, it has no specified format and it is sent in call to `to`. * * This internal function is equivalent to {safeTransferFrom}, and can be used to e.g. * implement alternative mechanisms to perform token transfer, such as signature-based. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeTransfer( address from, address to, uint256 tokenId, bytes memory _data ) internal virtual { _transfer(from, to, tokenId); require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer"); } /** * @dev Returns whether `tokenId` exists. * * Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}. * * Tokens start existing when they are minted (`_mint`), * and stop existing when they are burned (`_burn`). */ function _exists(uint256 tokenId) internal view virtual returns (bool) { return _owners[tokenId] != address(0); } /** * @dev Returns whether `spender` is allowed to manage `tokenId`. * * Requirements: * * - `tokenId` must exist. */ function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) { require(_exists(tokenId), "ERC721: operator query for nonexistent token"); address owner = ERC721Upgradeable.ownerOf(tokenId); return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender)); } /** * @dev Safely mints `tokenId` and transfers it to `to`. * * Requirements: * * - `tokenId` must not exist. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function _safeMint(address to, uint256 tokenId) internal virtual { _safeMint(to, tokenId, ""); } /** * @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is * forwarded in {IERC721Receiver-onERC721Received} to contract recipients. */ function _safeMint( address to, uint256 tokenId, bytes memory _data ) internal virtual { _mint(to, tokenId); require( _checkOnERC721Received(address(0), to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer" ); } /** * @dev Mints `tokenId` and transfers it to `to`. * * WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible * * Requirements: * * - `tokenId` must not exist. * - `to` cannot be the zero address. * * Emits a {Transfer} event. */ function _mint(address to, uint256 tokenId) internal virtual { require(to != address(0), "ERC721: mint to the zero address"); require(!_exists(tokenId), "ERC721: token already minted"); _beforeTokenTransfer(address(0), to, tokenId); _balances[to] += 1; _owners[tokenId] = to; emit Transfer(address(0), to, tokenId); } /** * @dev Destroys `tokenId`. * The approval is cleared when the token is burned. * * Requirements: * * - `tokenId` must exist. * * Emits a {Transfer} event. */ function _burn(uint256 tokenId) internal virtual { address owner = ERC721Upgradeable.ownerOf(tokenId); _beforeTokenTransfer(owner, address(0), tokenId); // Clear approvals _approve(address(0), tokenId); _balances[owner] -= 1; delete _owners[tokenId]; emit Transfer(owner, address(0), tokenId); } /** * @dev Transfers `tokenId` from `from` to `to`. * As opposed to {transferFrom}, this imposes no restrictions on msg.sender. * * Requirements: * * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * * Emits a {Transfer} event. */ function _transfer( address from, address to, uint256 tokenId ) internal virtual { require(ERC721Upgradeable.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own"); require(to != address(0), "ERC721: transfer to the zero address"); _beforeTokenTransfer(from, to, tokenId); // Clear approvals from the previous owner _approve(address(0), tokenId); _balances[from] -= 1; _balances[to] += 1; _owners[tokenId] = to; emit Transfer(from, to, tokenId); } /** * @dev Approve `to` to operate on `tokenId` * * Emits a {Approval} event. */ function _approve(address to, uint256 tokenId) internal virtual { _tokenApprovals[tokenId] = to; emit Approval(ERC721Upgradeable.ownerOf(tokenId), to, tokenId); } /** * @dev Approve `operator` to operate on all of `owner` tokens * * Emits a {ApprovalForAll} event. */ function _setApprovalForAll( address owner, address operator, bool approved ) internal virtual { require(owner != operator, "ERC721: approve to caller"); _operatorApprovals[owner][operator] = approved; emit ApprovalForAll(owner, operator, approved); } /** * @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address. * The call is not executed if the target address is not a contract. * * @param from address representing the previous owner of the given token ID * @param to target address that will receive the tokens * @param tokenId uint256 ID of the token to be transferred * @param _data bytes optional data to send along with the call * @return bool whether the call correctly returned the expected magic value */ function _checkOnERC721Received( address from, address to, uint256 tokenId, bytes memory _data ) private returns (bool) { if (to.isContract()) { try IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) { return retval == IERC721ReceiverUpgradeable.onERC721Received.selector; } catch (bytes memory reason) { if (reason.length == 0) { revert("ERC721: transfer to non ERC721Receiver implementer"); } else { assembly { revert(add(32, reason), mload(reason)) } } } } else { return true; } } /** * @dev Hook that is called before any token transfer. This includes minting * and burning. * * Calling conditions: * * - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be * transferred to `to`. * - When `from` is zero, `tokenId` will be minted for `to`. * - When `to` is zero, ``from``'s `tokenId` will be burned. * - `from` and `to` are never both zero. * * To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks]. */ function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal virtual {} uint256[44] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol) pragma solidity ^0.8.0; /** * @title ERC721 token receiver interface * @dev Interface for any contract that wants to support safeTransfers * from ERC721 asset contracts. */ interface IERC721ReceiverUpgradeable { /** * @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom} * by `operator` from `from`, this function is called. * * It must return its Solidity selector to confirm the token transfer. * If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted. * * The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`. */ function onERC721Received( address operator, address from, uint256 tokenId, bytes calldata data ) external returns (bytes4); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol) pragma solidity ^0.8.0; import "../../utils/introspection/IERC165Upgradeable.sol"; /** * @dev Required interface of an ERC721 compliant contract. */ interface IERC721Upgradeable is IERC165Upgradeable { /** * @dev Emitted when `tokenId` token is transferred from `from` to `to`. */ event Transfer(address indexed from, address indexed to, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables `approved` to manage the `tokenId` token. */ event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId); /** * @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets. */ event ApprovalForAll(address indexed owner, address indexed operator, bool approved); /** * @dev Returns the number of tokens in ``owner``'s account. */ function balanceOf(address owner) external view returns (uint256 balance); /** * @dev Returns the owner of the `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function ownerOf(uint256 tokenId) external view returns (address owner); /** * @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients * are aware of the ERC721 protocol to prevent tokens from being forever locked. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Transfers `tokenId` token from `from` to `to`. * * WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * * Emits a {Transfer} event. */ function transferFrom( address from, address to, uint256 tokenId ) external; /** * @dev Gives permission to `to` to transfer `tokenId` token to another account. * The approval is cleared when the token is transferred. * * Only a single account can be approved at a time, so approving the zero address clears previous approvals. * * Requirements: * * - The caller must own the token or be an approved operator. * - `tokenId` must exist. * * Emits an {Approval} event. */ function approve(address to, uint256 tokenId) external; /** * @dev Returns the account approved for `tokenId` token. * * Requirements: * * - `tokenId` must exist. */ function getApproved(uint256 tokenId) external view returns (address operator); /** * @dev Approve or remove `operator` as an operator for the caller. * Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller. * * Requirements: * * - The `operator` cannot be the caller. * * Emits an {ApprovalForAll} event. */ function setApprovalForAll(address operator, bool _approved) external; /** * @dev Returns if the `operator` is allowed to manage all of the assets of `owner`. * * See {setApprovalForAll} */ function isApprovedForAll(address owner, address operator) external view returns (bool); /** * @dev Safely transfers `tokenId` token from `from` to `to`. * * Requirements: * * - `from` cannot be the zero address. * - `to` cannot be the zero address. * - `tokenId` token must exist and be owned by `from`. * - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}. * - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer. * * Emits a {Transfer} event. */ function safeTransferFrom( address from, address to, uint256 tokenId, bytes calldata data ) external; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol) pragma solidity ^0.8.0; import "../IERC721Upgradeable.sol"; /** * @title ERC-721 Non-Fungible Token Standard, optional metadata extension * @dev See https://eips.ethereum.org/EIPS/eip-721 */ interface IERC721MetadataUpgradeable is IERC721Upgradeable { /** * @dev Returns the token collection name. */ function name() external view returns (string memory); /** * @dev Returns the token collection symbol. */ function symbol() external view returns (string memory); /** * @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token. */ function tokenURI(uint256 tokenId) external view returns (string memory); }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Address.sol) pragma solidity ^0.8.0; /** * @dev Collection of functions related to the address type */ library AddressUpgradeable { /** * @dev Returns true if `account` is a contract. * * [IMPORTANT] * ==== * It is unsafe to assume that an address for which this function returns * false is an externally-owned account (EOA) and not a contract. * * Among others, `isContract` will return false for the following * types of addresses: * * - an externally-owned account * - a contract in construction * - an address where a contract will be created * - an address where a contract lived, but was destroyed * ==== */ function isContract(address account) internal view returns (bool) { // This method relies on extcodesize, which returns 0 for contracts in // construction, since the code is only stored at the end of the // constructor execution. uint256 size; assembly { size := extcodesize(account) } return size > 0; } /** * @dev Replacement for Solidity's `transfer`: sends `amount` wei to * `recipient`, forwarding all available gas and reverting on errors. * * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost * of certain opcodes, possibly making contracts go over the 2300 gas limit * imposed by `transfer`, making them unable to receive funds via * `transfer`. {sendValue} removes this limitation. * * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more]. * * IMPORTANT: because control is transferred to `recipient`, care must be * taken to not create reentrancy vulnerabilities. Consider using * {ReentrancyGuard} or the * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern]. */ function sendValue(address payable recipient, uint256 amount) internal { require(address(this).balance >= amount, "Address: insufficient balance"); (bool success, ) = recipient.call{value: amount}(""); require(success, "Address: unable to send value, recipient may have reverted"); } /** * @dev Performs a Solidity function call using a low level `call`. A * plain `call` is an unsafe replacement for a function call: use this * function instead. * * If `target` reverts with a revert reason, it is bubbled up by this * function (like regular Solidity function calls). * * Returns the raw returned data. To convert to the expected return value, * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`]. * * Requirements: * * - `target` must be a contract. * - calling `target` with `data` must not revert. * * _Available since v3.1._ */ function functionCall(address target, bytes memory data) internal returns (bytes memory) { return functionCall(target, data, "Address: low-level call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with * `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCall( address target, bytes memory data, string memory errorMessage ) internal returns (bytes memory) { return functionCallWithValue(target, data, 0, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but also transferring `value` wei to `target`. * * Requirements: * * - the calling contract must have an ETH balance of at least `value`. * - the called Solidity function must be `payable`. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value ) internal returns (bytes memory) { return functionCallWithValue(target, data, value, "Address: low-level call with value failed"); } /** * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but * with `errorMessage` as a fallback revert reason when `target` reverts. * * _Available since v3.1._ */ function functionCallWithValue( address target, bytes memory data, uint256 value, string memory errorMessage ) internal returns (bytes memory) { require(address(this).balance >= value, "Address: insufficient balance for call"); require(isContract(target), "Address: call to non-contract"); (bool success, bytes memory returndata) = target.call{value: value}(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) { return functionStaticCall(target, data, "Address: low-level static call failed"); } /** * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`], * but performing a static call. * * _Available since v3.3._ */ function functionStaticCall( address target, bytes memory data, string memory errorMessage ) internal view returns (bytes memory) { require(isContract(target), "Address: static call to non-contract"); (bool success, bytes memory returndata) = target.staticcall(data); return verifyCallResult(success, returndata, errorMessage); } /** * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the * revert reason using the provided one. * * _Available since v4.3._ */ function verifyCallResult( bool success, bytes memory returndata, string memory errorMessage ) internal pure returns (bytes memory) { if (success) { return returndata; } else { // Look for revert reason and bubble it up if present if (returndata.length > 0) { // The easiest way to bubble the revert reason is using memory via assembly assembly { let returndata_size := mload(returndata) revert(add(32, returndata), returndata_size) } } else { revert(errorMessage); } } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Context.sol) pragma solidity ^0.8.0; import "../proxy/utils/Initializable.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 ContextUpgradeable is Initializable { function __Context_init() internal onlyInitializing { __Context_init_unchained(); } function __Context_init_unchained() internal onlyInitializing { } function _msgSender() internal view virtual returns (address) { return msg.sender; } function _msgData() internal view virtual returns (bytes calldata) { return msg.data; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Counters.sol) pragma solidity ^0.8.0; /** * @title Counters * @author Matt Condon (@shrugs) * @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number * of elements in a mapping, issuing ERC721 ids, or counting request ids. * * Include with `using Counters for Counters.Counter;` */ library CountersUpgradeable { struct Counter { // This variable should never be directly accessed by users of the library: interactions must be restricted to // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add // this feature: see https://github.com/ethereum/solidity/issues/4637 uint256 _value; // default: 0 } function current(Counter storage counter) internal view returns (uint256) { return counter._value; } function increment(Counter storage counter) internal { unchecked { counter._value += 1; } } function decrement(Counter storage counter) internal { uint256 value = counter._value; require(value > 0, "Counter: decrement overflow"); unchecked { counter._value = value - 1; } } function reset(Counter storage counter) internal { counter._value = 0; } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/StorageSlot.sol) pragma solidity ^0.8.0; /** * @dev Library for reading and writing primitive types to specific storage slots. * * Storage slots are often used to avoid storage conflict when dealing with upgradeable contracts. * This library helps with reading and writing to such slots without the need for inline assembly. * * The functions in this library return Slot structs that contain a `value` member that can be used to read or write. * * Example usage to set ERC1967 implementation slot: * ``` * contract ERC1967 { * bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; * * function _getImplementation() internal view returns (address) { * return StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value; * } * * function _setImplementation(address newImplementation) internal { * require(Address.isContract(newImplementation), "ERC1967: new implementation is not a contract"); * StorageSlot.getAddressSlot(_IMPLEMENTATION_SLOT).value = newImplementation; * } * } * ``` * * _Available since v4.1 for `address`, `bool`, `bytes32`, and `uint256`._ */ library StorageSlotUpgradeable { struct AddressSlot { address value; } struct BooleanSlot { bool value; } struct Bytes32Slot { bytes32 value; } struct Uint256Slot { uint256 value; } /** * @dev Returns an `AddressSlot` with member `value` located at `slot`. */ function getAddressSlot(bytes32 slot) internal pure returns (AddressSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `BooleanSlot` with member `value` located at `slot`. */ function getBooleanSlot(bytes32 slot) internal pure returns (BooleanSlot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Bytes32Slot` with member `value` located at `slot`. */ function getBytes32Slot(bytes32 slot) internal pure returns (Bytes32Slot storage r) { assembly { r.slot := slot } } /** * @dev Returns an `Uint256Slot` with member `value` located at `slot`. */ function getUint256Slot(bytes32 slot) internal pure returns (Uint256Slot storage r) { assembly { r.slot := slot } } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/Strings.sol) pragma solidity ^0.8.0; /** * @dev String operations. */ library StringsUpgradeable { bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef"; /** * @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); } }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol) pragma solidity ^0.8.0; import "./IERC165Upgradeable.sol"; import "../../proxy/utils/Initializable.sol"; /** * @dev Implementation of the {IERC165} interface. * * Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check * for the additional interface id that will be supported. For example: * * ```solidity * function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { * return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId); * } * ``` * * Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation. */ abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable { function __ERC165_init() internal onlyInitializing { __ERC165_init_unchained(); } function __ERC165_init_unchained() internal onlyInitializing { } /** * @dev See {IERC165-supportsInterface}. */ function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) { return interfaceId == type(IERC165Upgradeable).interfaceId; } uint256[50] private __gap; }
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol) pragma solidity ^0.8.0; /** * @dev Interface of the ERC165 standard, as defined in the * https://eips.ethereum.org/EIPS/eip-165[EIP]. * * Implementers can declare support of contract interfaces, which can then be * queried by others ({ERC165Checker}). * * For an implementation, see {ERC165}. */ interface IERC165Upgradeable { /** * @dev Returns true if this contract implements the interface defined by * `interfaceId`. See the corresponding * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section] * to learn more about how these ids are created. * * This function call must use less than 30 000 gas. */ function supportsInterface(bytes4 interfaceId) external view returns (bool); }
// SPDX-License-Identifier: MIT pragma solidity >=0.6.0; /// @title Base64 /// @author Brecht Devos - <[email protected]> /// @notice Provides functions for encoding/decoding base64 library Base64 { string internal constant TABLE_ENCODE = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; bytes internal constant TABLE_DECODE = hex"0000000000000000000000000000000000000000000000000000000000000000" hex"00000000000000000000003e0000003f3435363738393a3b3c3d000000000000" hex"00000102030405060708090a0b0c0d0e0f101112131415161718190000000000" hex"001a1b1c1d1e1f202122232425262728292a2b2c2d2e2f303132330000000000"; function encode(bytes memory data) internal pure returns (string memory) { if (data.length == 0) return ''; // load the table into memory string memory table = TABLE_ENCODE; // multiply by 4/3 rounded up uint256 encodedLen = 4 * ((data.length + 2) / 3); // add some extra buffer at the end required for the writing string memory result = new string(encodedLen + 32); assembly { // set the actual output length mstore(result, encodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 3 bytes at a time for {} lt(dataPtr, endPtr) {} { // read 3 bytes dataPtr := add(dataPtr, 3) let input := mload(dataPtr) // write 4 characters mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and(shr( 6, input), 0x3F)))) resultPtr := add(resultPtr, 1) mstore8(resultPtr, mload(add(tablePtr, and( input, 0x3F)))) resultPtr := add(resultPtr, 1) } // padding with '=' switch mod(mload(data), 3) case 1 { mstore(sub(resultPtr, 2), shl(240, 0x3d3d)) } case 2 { mstore(sub(resultPtr, 1), shl(248, 0x3d)) } } return result; } function decode(string memory _data) internal pure returns (bytes memory) { bytes memory data = bytes(_data); if (data.length == 0) return new bytes(0); require(data.length % 4 == 0, "invalid base64 decoder input"); // load the table into memory bytes memory table = TABLE_DECODE; // every 4 characters represent 3 bytes uint256 decodedLen = (data.length / 4) * 3; // add some extra buffer at the end required for the writing bytes memory result = new bytes(decodedLen + 32); assembly { // padding with '=' let lastBytes := mload(add(data, mload(data))) if eq(and(lastBytes, 0xFF), 0x3d) { decodedLen := sub(decodedLen, 1) if eq(and(lastBytes, 0xFFFF), 0x3d3d) { decodedLen := sub(decodedLen, 1) } } // set the actual output length mstore(result, decodedLen) // prepare the lookup table let tablePtr := add(table, 1) // input ptr let dataPtr := data let endPtr := add(dataPtr, mload(data)) // result ptr, jump over length let resultPtr := add(result, 32) // run over the input, 4 characters at a time for {} lt(dataPtr, endPtr) {} { // read 4 characters dataPtr := add(dataPtr, 4) let input := mload(dataPtr) // write 3 bytes let output := add( add( shl(18, and(mload(add(tablePtr, and(shr(24, input), 0xFF))), 0xFF)), shl(12, and(mload(add(tablePtr, and(shr(16, input), 0xFF))), 0xFF))), add( shl( 6, and(mload(add(tablePtr, and(shr( 8, input), 0xFF))), 0xFF)), and(mload(add(tablePtr, and( input , 0xFF))), 0xFF) ) ) mstore(resultPtr, shl(232, output)) resultPtr := add(resultPtr, 3) } } return result; } }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; interface GmDataInterface { struct GmDataSet { bytes imageName; bytes compressedImage; uint256 compressedSize; } function getSvg(uint256 index) external pure returns (GmDataSet memory); }
// SPDX-License-Identifier: MIT pragma solidity ^0.8.9; import {InflateLib} from "./InflateLib.sol"; import {GmDataInterface} from "./GmDataInterface.sol"; import {StringsUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; interface ICourierFont { function font() external view returns (string memory); } contract GmRenderer { ICourierFont private immutable font; GmDataInterface private immutable gmData1; GmDataInterface private immutable gmData2; struct Color { bytes hexNum; bytes name; } constructor( ICourierFont fontAddress, GmDataInterface gmData1Address, GmDataInterface gmData2Address ) { font = fontAddress; gmData1 = gmData1Address; gmData2 = gmData2Address; } /// @notice decompresses the GmDataSet /// @param gmData, compressed ascii svg data function decompress(GmDataInterface.GmDataSet memory gmData) public pure returns (bytes memory, bytes memory) { (, bytes memory inflated) = InflateLib.puff( gmData.compressedImage, gmData.compressedSize ); return (gmData.imageName, inflated); } /// @notice returns an svg filter /// @param index, a random number derived from the seed function _getFilter(uint256 index) internal pure returns (bytes memory) { // 1 || 2 || 3 || 4 || 5 -> noise 5% if ( (index == 1) || (index == 2) || (index == 3) || (index == 4) || (index == 5) ) { return "noise"; } // 7 || 8 || 98 -> scribble 3% if ((index == 7) || (index == 8) || (index == 9)) { return "scribble"; } // 10 - 29 -> morph 20% if (((100 - index) > 70) && ((100 - index) <= 90)) { return "morph"; } // 30 - 39 -> glow 10% if (((100 - index) > 60) && ((100 - index) <= 70)) { return "glow"; } // 69 -> fractal 1% if (index == 69) { return "fractal"; } return "none"; } /// @notice returns a background color and font color /// @param seed, pseudo random seed function _getColors(bytes32 seed) internal pure returns (Color memory bgColor, Color memory fontColor) { uint32 bgRand = uint32(bytes4(seed)) % 111; uint32 fontJitter = uint32(bytes4(seed << 32)) % 5; uint32 fontOperation = uint8(bytes1(seed << 64)) % 2; uint32 fontRand; if (fontOperation == 0) { fontRand = (bgRand + (55 + fontJitter)) % 111; } else { fontRand = (bgRand + (55 - fontJitter)) % 111; } return (_getColor(bgRand), _getColor(fontRand)); } /// @notice executes string comparison against two strings /// @param a, first string /// @param b, second string function strCompare(string memory a, string memory b) internal pure returns (bool) { if(bytes(a).length != bytes(b).length) { return false; } else { return keccak256(abi.encodePacked(a)) == keccak256(abi.encodePacked(b)); } } /// @notice returns the raw svg yielded by seed /// @param seed, pseudo random seed function svgRaw(bytes32 seed) external view returns ( bytes memory, bytes memory, bytes memory, bytes memory, bytes memory ) { uint32 style = uint32(bytes4(seed << 65)) % 69; uint32 filterRand = uint32(bytes4(seed << 97)) % 100; bytes memory filter = _getFilter(filterRand); (Color memory bgColor, Color memory fontColor) = _getColors(seed); bytes memory inner; bytes memory name; if (style < 50) { (name, inner) = decompress(gmData1.getSvg(style)); } else { (name, inner) = decompress(gmData2.getSvg(style)); } if ((strCompare(string(name), "Hex")) || (strCompare(string(name), "Binary")) || (strCompare(string(name), "Morse")) || (strCompare(string(name), "Mnemonic"))){ filter = "none"; } return ( abi.encodePacked( svgPreambleString(bgColor.hexNum, fontColor.hexNum, filter), inner, "</svg>" ), name, bgColor.name, fontColor.name, filter ); } /// @notice returns the svg filters function svgFilterDefs() private view returns (bytes memory) { return abi.encodePacked( '<defs><filter id="fractal" filterUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%" ><feTurbulence id="turbulence" type="fractalNoise" baseFrequency="0.03" numOctaves="1" ><animate attributeName="baseFrequency" values="0.01;0.4;0.01" dur="100s" repeatCount="indefinite" /></feTurbulence><feDisplacementMap in="SourceGraphic" scale="50"></feDisplacementMap></filter><filter id="morph"><feMorphology operator="dilate" radius="0"><animate attributeName="radius" values="0;5;0" dur="8s" repeatCount="indefinite" /></feMorphology></filter><filter id="glow" filterUnits="objectBoundingBox" x="0%" y="0%" width="100%" height="100%" ><feGaussianBlur stdDeviation="5" result="blur2" in="SourceGraphic" /><feMerge><feMergeNode in="blur2" /><feMergeNode in="SourceGraphic" /></feMerge></filter><filter id="noise"><feTurbulence baseFrequency="0.05"/><feColorMatrix type="hueRotate" values="0"><animate attributeName="values" from="0" to="360" dur="1s" repeatCount="indefinite"/></feColorMatrix><feColorMatrix type="matrix" values="0 0 0 0 1 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0"/><feDisplacementMap in="SourceGraphic" scale="10"/></filter><filter id="none"><feOffset></feOffset></filter><filter id="scribble"><feTurbulence type="turbulence" baseFrequency="0.05" numOctaves="2" result="turbulence"/><feDisplacementMap in2="turbulence" in="SourceGraphic" scale="50" xChannelSelector="R" yChannelSelector="G"/></filter><filter id="tile" x="10" y="10" width="10%" height="10%"><feTile in="SourceGraphic" x="10" y="10" width="10" height="10" /><feTile/></filter></defs>' ); } /// @notice returns the svg preamble /// @param bgColor, color of the background as hex string /// @param fontColor, color of the font as hex string /// @param filter, filter for the svg function svgPreambleString( bytes memory bgColor, bytes memory fontColor, bytes memory filter ) private view returns (bytes memory) { return abi.encodePacked( "<svg viewBox='0 0 640 640' width='100%' height='100%' xmlns='http://www.w3.org/2000/svg'><style> @font-face { font-family: CourierFont; src: url('", font.font(), "') format('opentype'); }", ".base{filter:url(#", filter, ");fill:", fontColor, ";font-family:CourierFont;font-size: 16px;}</style>", svgFilterDefs(), '<rect width="100%" height="100%" fill="', bgColor, '" /> ' ); } /// @notice returns the Color yielded by index /// @param index, random number determined by seed function _getColor(uint32 index) internal pure returns (Color memory color) { // AUTOGEN:START if (index == 0) { color.hexNum = "#000000"; color.name = "Black"; } if (index == 1) { color.hexNum = "#004c6a"; color.name = "Navy Dark Blue"; } if (index == 2) { color.hexNum = "#0098d4"; color.name = "Bayern Blue"; } if (index == 3) { color.hexNum = "#00e436"; color.name = "Lexaloffle Green"; } if (index == 4) { color.hexNum = "#1034a6"; color.name = "Egyptian Blue"; } if (index == 5) { color.hexNum = "#008811"; color.name = "Lush Garden"; } if (index == 6) { color.hexNum = "#06d078"; color.name = "Underwater Fern"; } if (index == 7) { color.hexNum = "#1c1cf0"; color.name = "Bluebonnet"; } if (index == 8) { color.hexNum = "#127453"; color.name = "Green Velvet"; } if (index == 9) { color.hexNum = "#14bab4"; color.name = "Super Rare Jade"; } if (index == 10) { color.hexNum = "#111122"; color.name = "Corbeau"; } if (index == 11) { color.hexNum = "#165d95"; color.name = "Lapis Jewel"; } if (index == 12) { color.hexNum = "#16b8f3"; color.name = "Zima Blue"; } if (index == 13) { color.hexNum = "#1ef876"; color.name = "Synthetic Spearmint"; } if (index == 14) { color.hexNum = "#214fc6"; color.name = "New Car"; } if (index == 15) { color.hexNum = "#249148"; color.name = "Paperboy's Lawn"; } if (index == 16) { color.hexNum = "#24da91"; color.name = "Reptile Green"; } if (index == 17) { color.hexNum = "#223311"; color.name = "Darkest Forest"; } if (index == 18) { color.hexNum = "#297f6d"; color.name = "Mermaid Sea"; } if (index == 19) { color.hexNum = "#22cccc"; color.name = "Mermaid Net"; } if (index == 20) { color.hexNum = "#2e2249"; color.name = "Elderberry"; } if (index == 21) { color.hexNum = "#326ab1"; color.name = "Dover Straits"; } if (index == 22) { color.hexNum = "#2bc51b"; color.name = "Felwood Leaves"; } if (index == 23) { color.hexNum = "#391285"; color.name = "Pixie Powder"; } if (index == 24) { color.hexNum = "#2e58e8"; color.name = "Veteran's Day Blue"; } if (index == 25) { color.hexNum = "#419f59"; color.name = "Chateau Green"; } if (index == 26) { color.hexNum = "#45e9c1"; color.name = "Aphrodite Aqua"; } if (index == 27) { color.hexNum = "#424330"; color.name = "Garden Path"; } if (index == 28) { color.hexNum = "#429395"; color.name = "Catalan"; } if (index == 29) { color.hexNum = "#44dd00"; color.name = "Magic Blade"; } if (index == 30) { color.hexNum = "#432e6f"; color.name = "Her Highness"; } if (index == 31) { color.hexNum = "#4477dd"; color.name = "Andrea Blue"; } if (index == 32) { color.hexNum = "#5ad33e"; color.name = "Verdant Fields"; } if (index == 33) { color.hexNum = "#3a18b1"; color.name = "Indigo Blue"; } if (index == 34) { color.hexNum = "#556611"; color.name = "Forestial Outpost"; } if (index == 35) { color.hexNum = "#55bb88"; color.name = "Bleached Olive"; } if (index == 36) { color.hexNum = "#5500ee"; color.name = "Tezcatlipoca Blue"; } if (index == 37) { color.hexNum = "#545554"; color.name = "Carbon Copy"; } if (index == 38) { color.hexNum = "#58a0bc"; color.name = "Dupain"; } if (index == 39) { color.hexNum = "#55ff22"; color.name = "Traffic Green"; } if (index == 40) { color.hexNum = "#5b3e90"; color.name = "Daisy Bush"; } if (index == 41) { color.hexNum = "#6688ff"; color.name = "Deep Denim"; } if (index == 42) { color.hexNum = "#61e160"; color.name = "Lightish Green"; } if (index == 43) { color.hexNum = "#6a31ca"; color.name = "Sagat Purple"; } if (index == 44) { color.hexNum = "#667c3e"; color.name = "Military Green"; } if (index == 45) { color.hexNum = "#68c89d"; color.name = "Intense Jade"; } if (index == 46) { color.hexNum = "#6d1008"; color.name = "Chestnut Brown"; } if (index == 47) { color.hexNum = "#696374"; color.name = "Purple Punch"; } if (index == 48) { color.hexNum = "#6fb7e0"; color.name = "Life Force"; } if (index == 49) { color.hexNum = "#770044"; color.name = "Dawn of the Fairies"; } if (index == 50) { color.hexNum = "#7851a9"; color.name = "Royal Lavender"; } if (index == 51) { color.hexNum = "#769c18"; color.name = "Luminescent Green"; } if (index == 52) { color.hexNum = "#7be892"; color.name = "Ragweed"; } if (index == 53) { color.hexNum = "#703be7"; color.name = "Bluish Purple"; } if (index == 54) { color.hexNum = "#7b8b5d"; color.name = "Sage Leaves"; } if (index == 55) { color.hexNum = "#82d9c5"; color.name = "Tender Turquoise"; } if (index == 56) { color.hexNum = "#7e2530"; color.name = "Scarlet Shade"; } if (index == 57) { color.hexNum = "#83769c"; color.name = "Voxatron Purple"; } if (index == 58) { color.hexNum = "#88cc00"; color.name = "Fabulous Frog"; } if (index == 59) { color.hexNum = "#881166"; color.name = "Possessed Purple"; } if (index == 60) { color.hexNum = "#8756e4"; color.name = "Gloomy Purple"; } if (index == 61) { color.hexNum = "#93b13d"; color.name = "Green Tea Ice Cream"; } if (index == 62) { color.hexNum = "#90fda9"; color.name = "Foam Green"; } if (index == 63) { color.hexNum = "#914b13"; color.name = "Parasite Brown"; } if (index == 64) { color.hexNum = "#919c81"; color.name = "Whispering Willow"; } if (index == 65) { color.hexNum = "#99eeee"; color.name = "Freezy Breezy"; } if (index == 66) { color.hexNum = "#983d53"; color.name = "Algae Red"; } if (index == 67) { color.hexNum = "#9c87c1"; color.name = "Petrified Purple"; } if (index == 68) { color.hexNum = "#98da2c"; color.name = "Effervescent Lime"; } if (index == 69) { color.hexNum = "#942193"; color.name = "Acai Juice"; } if (index == 70) { color.hexNum = "#a675fe"; color.name = "Purple Illusionist"; } if (index == 71) { color.hexNum = "#a4c161"; color.name = "Jungle Juice"; } if (index == 72) { color.hexNum = "#aa00cc"; color.name = "Ferocious Fuchsia"; } if (index == 73) { color.hexNum = "#a85e39"; color.name = "Earthen Jug"; } if (index == 74) { color.hexNum = "#aaa9a4"; color.name = "Ellie Grey"; } if (index == 75) { color.hexNum = "#aaee11"; color.name = "Glorious Green Glitter"; } if (index == 76) { color.hexNum = "#ad4379"; color.name = "Mystic Maroon"; } if (index == 77) { color.hexNum = "#b195e4"; color.name = "Dreamy Candy Forest"; } if (index == 78) { color.hexNum = "#b1dd52"; color.name = "Conifer"; } if (index == 79) { color.hexNum = "#c034af"; color.name = "Pink Perennial"; } if (index == 80) { color.hexNum = "#b78727"; color.name = "University of California Gold"; } if (index == 81) { color.hexNum = "#b9d08b"; color.name = "Young Leaves"; } if (index == 82) { color.hexNum = "#bb11ee"; color.name = "Promiscuous Pink"; } if (index == 83) { color.hexNum = "#c06960"; color.name = "Tapestry Red"; } if (index == 84) { color.hexNum = "#bebbc9"; color.name = "Silverberry"; } if (index == 85) { color.hexNum = "#bf0a30"; color.name = "Old Glory Red"; } if (index == 86) { color.hexNum = "#c35b99"; color.name = "Llilacquered"; } if (index == 87) { color.hexNum = "#caa906"; color.name = "Christmas Gold"; } if (index == 88) { color.hexNum = "#c2f177"; color.name = "Cucumber Milk"; } if (index == 89) { color.hexNum = "#d648d7"; color.name = "Pinkish Purple"; } if (index == 90) { color.hexNum = "#cf9346"; color.name = "Fleshtone Shade Wash"; } if (index == 91) { color.hexNum = "#d3e0b1"; color.name = "Rockmelon Rind"; } if (index == 92) { color.hexNum = "#d22d1d"; color.name = "Pure Red"; } if (index == 93) { color.hexNum = "#d28083"; color.name = "Galah"; } if (index == 94) { color.hexNum = "#d5c7e8"; color.name = "Foggy Love"; } if (index == 95) { color.hexNum = "#db1459"; color.name = "Rubylicious"; } if (index == 96) { color.hexNum = "#dd66bb"; color.name = "Pink Charge"; } if (index == 97) { color.hexNum = "#e2b227"; color.name = "Gold Tips"; } if (index == 98) { color.hexNum = "#ee0099"; color.name = "Love Vessel"; } if (index == 99) { color.hexNum = "#dd55ff"; color.name = "Flaming Flamingo"; } if (index == 100) { color.hexNum = "#eda367"; color.name = "Adventure Orange"; } if (index == 101) { color.hexNum = "#e9f1d0"; color.name = "Yellowish White"; } if (index == 102) { color.hexNum = "#ef3939"; color.name = "Vivaldi Red"; } if (index == 103) { color.hexNum = "#e78ea5"; color.name = "Underwater Flare"; } if (index == 104) { color.hexNum = "#eedd11"; color.name = "Yellow Buzzing"; } if (index == 105) { color.hexNum = "#ee2277"; color.name = "Furious Fuchsia"; } if (index == 106) { color.hexNum = "#f075e6"; color.name = "Lian Hong Lotus Pink"; } if (index == 107) { color.hexNum = "#f7c34c"; color.name = "Creamy Sweet Corn"; } if (index == 108) { color.hexNum = "#fc0fc0"; color.name = "CGA Pink"; } if (index == 109) { color.hexNum = "#ff6622"; color.name = "Sparrows Fire"; } if (index == 110) { color.hexNum = "#fbaf8d"; color.name = "Orange Grove"; } // AUTOGEN:END } }
// SPDX-License-Identifier: Apache-2.0 pragma solidity >=0.8.0 <0.9.0; // // inflate content script: // var pako = require('pako') // var deflate = (str) => [str.length,Buffer.from(pako.deflateRaw(Buffer.from(str, 'utf-8'), {level: 9})).toString('hex')] // /// @notice Based on https://github.com/madler/zlib/blob/master/contrib/puff library InflateLib { // Maximum bits in a code uint256 constant MAXBITS = 15; // Maximum number of literal/length codes uint256 constant MAXLCODES = 286; // Maximum number of distance codes uint256 constant MAXDCODES = 30; // Maximum codes lengths to read uint256 constant MAXCODES = (MAXLCODES + MAXDCODES); // Number of fixed literal/length codes uint256 constant FIXLCODES = 288; // Error codes enum ErrorCode { ERR_NONE, // 0 successful inflate ERR_NOT_TERMINATED, // 1 available inflate data did not terminate ERR_OUTPUT_EXHAUSTED, // 2 output space exhausted before completing inflate ERR_INVALID_BLOCK_TYPE, // 3 invalid block type (type == 3) ERR_STORED_LENGTH_NO_MATCH, // 4 stored block length did not match one's complement ERR_TOO_MANY_LENGTH_OR_DISTANCE_CODES, // 5 dynamic block code description: too many length or distance codes ERR_CODE_LENGTHS_CODES_INCOMPLETE, // 6 dynamic block code description: code lengths codes incomplete ERR_REPEAT_NO_FIRST_LENGTH, // 7 dynamic block code description: repeat lengths with no first length ERR_REPEAT_MORE, // 8 dynamic block code description: repeat more than specified lengths ERR_INVALID_LITERAL_LENGTH_CODE_LENGTHS, // 9 dynamic block code description: invalid literal/length code lengths ERR_INVALID_DISTANCE_CODE_LENGTHS, // 10 dynamic block code description: invalid distance code lengths ERR_MISSING_END_OF_BLOCK, // 11 dynamic block code description: missing end-of-block code ERR_INVALID_LENGTH_OR_DISTANCE_CODE, // 12 invalid literal/length or distance code in fixed or dynamic block ERR_DISTANCE_TOO_FAR, // 13 distance is too far back in fixed or dynamic block ERR_CONSTRUCT // 14 internal: error in construct() } // Input and output state struct State { ////////////////// // Output state // ////////////////// // Output buffer bytes output; // Bytes written to out so far uint256 outcnt; ///////////////// // Input state // ///////////////// // Input buffer bytes input; // Bytes read so far uint256 incnt; //////////////// // Temp state // //////////////// // Bit buffer uint256 bitbuf; // Number of bits in bit buffer uint256 bitcnt; ////////////////////////// // Static Huffman codes // ////////////////////////// Huffman lencode; Huffman distcode; } // Huffman code decoding tables struct Huffman { uint256[] counts; uint256[] symbols; } function bits(State memory s, uint256 need) private pure returns (ErrorCode, uint256) { // Bit accumulator (can use up to 20 bits) uint256 val; // Load at least need bits into val val = s.bitbuf; while (s.bitcnt < need) { if (s.incnt == s.input.length) { // Out of input return (ErrorCode.ERR_NOT_TERMINATED, 0); } // Load eight bits val |= uint256(uint8(s.input[s.incnt++])) << s.bitcnt; s.bitcnt += 8; } // Drop need bits and update buffer, always zero to seven bits left s.bitbuf = val >> need; s.bitcnt -= need; // Return need bits, zeroing the bits above that uint256 ret = (val & ((1 << need) - 1)); return (ErrorCode.ERR_NONE, ret); } function _stored(State memory s) private pure returns (ErrorCode) { // Length of stored block uint256 len; // Discard leftover bits from current byte (assumes s.bitcnt < 8) s.bitbuf = 0; s.bitcnt = 0; // Get length and check against its one's complement if (s.incnt + 4 > s.input.length) { // Not enough input return ErrorCode.ERR_NOT_TERMINATED; } len = uint256(uint8(s.input[s.incnt++])); len |= uint256(uint8(s.input[s.incnt++])) << 8; if ( uint8(s.input[s.incnt++]) != (~len & 0xFF) || uint8(s.input[s.incnt++]) != ((~len >> 8) & 0xFF) ) { // Didn't match complement! return ErrorCode.ERR_STORED_LENGTH_NO_MATCH; } // Copy len bytes from in to out if (s.incnt + len > s.input.length) { // Not enough input return ErrorCode.ERR_NOT_TERMINATED; } if (s.outcnt + len > s.output.length) { // Not enough output space return ErrorCode.ERR_OUTPUT_EXHAUSTED; } while (len != 0) { // Note: Solidity reverts on underflow, so we decrement here len -= 1; s.output[s.outcnt++] = s.input[s.incnt++]; } // Done with a valid stored block return ErrorCode.ERR_NONE; } function _decode(State memory s, Huffman memory h) private pure returns (ErrorCode, uint256) { // Current number of bits in code uint256 len; // Len bits being decoded uint256 code = 0; // First code of length len uint256 first = 0; // Number of codes of length len uint256 count; // Index of first code of length len in symbol table uint256 index = 0; // Error code ErrorCode err; for (len = 1; len <= MAXBITS; len++) { // Get next bit uint256 tempCode; (err, tempCode) = bits(s, 1); if (err != ErrorCode.ERR_NONE) { return (err, 0); } code |= tempCode; count = h.counts[len]; // If length len, return symbol if (code < first + count) { return (ErrorCode.ERR_NONE, h.symbols[index + (code - first)]); } // Else update for next length index += count; first += count; first <<= 1; code <<= 1; } // Ran out of codes return (ErrorCode.ERR_INVALID_LENGTH_OR_DISTANCE_CODE, 0); } function _construct( Huffman memory h, uint256[] memory lengths, uint256 n, uint256 start ) private pure returns (ErrorCode) { // Current symbol when stepping through lengths[] uint256 symbol; // Current length when stepping through h.counts[] uint256 len; // Number of possible codes left of current length uint256 left; // Offsets in symbol table for each length uint256[MAXBITS + 1] memory offs; // Count number of codes of each length for (len = 0; len <= MAXBITS; len++) { h.counts[len] = 0; } for (symbol = 0; symbol < n; symbol++) { // Assumes lengths are within bounds h.counts[lengths[start + symbol]]++; } // No codes! if (h.counts[0] == n) { // Complete, but decode() will fail return (ErrorCode.ERR_NONE); } // Check for an over-subscribed or incomplete set of lengths // One possible code of zero length left = 1; for (len = 1; len <= MAXBITS; len++) { // One more bit, double codes left left <<= 1; if (left < h.counts[len]) { // Over-subscribed--return error return ErrorCode.ERR_CONSTRUCT; } // Deduct count from possible codes left -= h.counts[len]; } // Generate offsets into symbol table for each length for sorting offs[1] = 0; for (len = 1; len < MAXBITS; len++) { offs[len + 1] = offs[len] + h.counts[len]; } // Put symbols in table sorted by length, by symbol order within each length for (symbol = 0; symbol < n; symbol++) { if (lengths[start + symbol] != 0) { h.symbols[offs[lengths[start + symbol]]++] = symbol; } } // Left > 0 means incomplete return left > 0 ? ErrorCode.ERR_CONSTRUCT : ErrorCode.ERR_NONE; } function _codes( State memory s, Huffman memory lencode, Huffman memory distcode ) private pure returns (ErrorCode) { // Decoded symbol uint256 symbol; // Length for copy uint256 len; // Distance for copy uint256 dist; // TODO Solidity doesn't support constant arrays, but these are fixed at compile-time // Size base for length codes 257..285 uint16[29] memory lens = [ 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31, 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258 ]; // Extra bits for length codes 257..285 uint8[29] memory lext = [ 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 0 ]; // Offset base for distance codes 0..29 uint16[30] memory dists = [ 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193, 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145, 8193, 12289, 16385, 24577 ]; // Extra bits for distance codes 0..29 uint8[30] memory dext = [ 0, 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7, 7, 8, 8, 9, 9, 10, 10, 11, 11, 12, 12, 13, 13 ]; // Error code ErrorCode err; // Decode literals and length/distance pairs while (symbol != 256) { (err, symbol) = _decode(s, lencode); if (err != ErrorCode.ERR_NONE) { // Invalid symbol return err; } if (symbol < 256) { // Literal: symbol is the byte // Write out the literal if (s.outcnt == s.output.length) { return ErrorCode.ERR_OUTPUT_EXHAUSTED; } s.output[s.outcnt] = bytes1(uint8(symbol)); s.outcnt++; } else if (symbol > 256) { uint256 tempBits; // Length // Get and compute length symbol -= 257; if (symbol >= 29) { // Invalid fixed code return ErrorCode.ERR_INVALID_LENGTH_OR_DISTANCE_CODE; } (err, tempBits) = bits(s, lext[symbol]); if (err != ErrorCode.ERR_NONE) { return err; } len = lens[symbol] + tempBits; // Get and check distance (err, symbol) = _decode(s, distcode); if (err != ErrorCode.ERR_NONE) { // Invalid symbol return err; } (err, tempBits) = bits(s, dext[symbol]); if (err != ErrorCode.ERR_NONE) { return err; } dist = dists[symbol] + tempBits; if (dist > s.outcnt) { // Distance too far back return ErrorCode.ERR_DISTANCE_TOO_FAR; } // Copy length bytes from distance bytes back if (s.outcnt + len > s.output.length) { return ErrorCode.ERR_OUTPUT_EXHAUSTED; } while (len != 0) { // Note: Solidity reverts on underflow, so we decrement here len -= 1; s.output[s.outcnt] = s.output[s.outcnt - dist]; s.outcnt++; } } else { s.outcnt += len; } } // Done with a valid fixed or dynamic block return ErrorCode.ERR_NONE; } function _build_fixed(State memory s) private pure returns (ErrorCode) { // Build fixed Huffman tables // TODO this is all a compile-time constant uint256 symbol; uint256[] memory lengths = new uint256[](FIXLCODES); // Literal/length table for (symbol = 0; symbol < 144; symbol++) { lengths[symbol] = 8; } for (; symbol < 256; symbol++) { lengths[symbol] = 9; } for (; symbol < 280; symbol++) { lengths[symbol] = 7; } for (; symbol < FIXLCODES; symbol++) { lengths[symbol] = 8; } _construct(s.lencode, lengths, FIXLCODES, 0); // Distance table for (symbol = 0; symbol < MAXDCODES; symbol++) { lengths[symbol] = 5; } _construct(s.distcode, lengths, MAXDCODES, 0); return ErrorCode.ERR_NONE; } function _fixed(State memory s) private pure returns (ErrorCode) { // Decode data until end-of-block code return _codes(s, s.lencode, s.distcode); } function _build_dynamic_lengths(State memory s) private pure returns (ErrorCode, uint256[] memory) { uint256 ncode; // Index of lengths[] uint256 index; // Descriptor code lengths uint256[] memory lengths = new uint256[](MAXCODES); // Error code ErrorCode err; // Permutation of code length codes uint8[19] memory order = [16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15]; (err, ncode) = bits(s, 4); if (err != ErrorCode.ERR_NONE) { return (err, lengths); } ncode += 4; // Read code length code lengths (really), missing lengths are zero for (index = 0; index < ncode; index++) { (err, lengths[order[index]]) = bits(s, 3); if (err != ErrorCode.ERR_NONE) { return (err, lengths); } } for (; index < 19; index++) { lengths[order[index]] = 0; } return (ErrorCode.ERR_NONE, lengths); } function _build_dynamic(State memory s) private pure returns ( ErrorCode, Huffman memory, Huffman memory ) { // Number of lengths in descriptor uint256 nlen; uint256 ndist; // Index of lengths[] uint256 index; // Error code ErrorCode err; // Descriptor code lengths uint256[] memory lengths = new uint256[](MAXCODES); // Length and distance codes Huffman memory lencode = Huffman(new uint256[](MAXBITS + 1), new uint256[](MAXLCODES)); Huffman memory distcode = Huffman(new uint256[](MAXBITS + 1), new uint256[](MAXDCODES)); uint256 tempBits; // Get number of lengths in each table, check lengths (err, nlen) = bits(s, 5); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } nlen += 257; (err, ndist) = bits(s, 5); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } ndist += 1; if (nlen > MAXLCODES || ndist > MAXDCODES) { // Bad counts return ( ErrorCode.ERR_TOO_MANY_LENGTH_OR_DISTANCE_CODES, lencode, distcode ); } (err, lengths) = _build_dynamic_lengths(s); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } // Build huffman table for code lengths codes (use lencode temporarily) err = _construct(lencode, lengths, 19, 0); if (err != ErrorCode.ERR_NONE) { // Require complete code set here return ( ErrorCode.ERR_CODE_LENGTHS_CODES_INCOMPLETE, lencode, distcode ); } // Read length/literal and distance code length tables index = 0; while (index < nlen + ndist) { // Decoded value uint256 symbol; // Last length to repeat uint256 len; (err, symbol) = _decode(s, lencode); if (err != ErrorCode.ERR_NONE) { // Invalid symbol return (err, lencode, distcode); } if (symbol < 16) { // Length in 0..15 lengths[index++] = symbol; } else { // Repeat instruction // Assume repeating zeros len = 0; if (symbol == 16) { // Repeat last length 3..6 times if (index == 0) { // No last length! return ( ErrorCode.ERR_REPEAT_NO_FIRST_LENGTH, lencode, distcode ); } // Last length len = lengths[index - 1]; (err, tempBits) = bits(s, 2); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } symbol = 3 + tempBits; } else if (symbol == 17) { // Repeat zero 3..10 times (err, tempBits) = bits(s, 3); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } symbol = 3 + tempBits; } else { // == 18, repeat zero 11..138 times (err, tempBits) = bits(s, 7); if (err != ErrorCode.ERR_NONE) { return (err, lencode, distcode); } symbol = 11 + tempBits; } if (index + symbol > nlen + ndist) { // Too many lengths! return (ErrorCode.ERR_REPEAT_MORE, lencode, distcode); } while (symbol != 0) { // Note: Solidity reverts on underflow, so we decrement here symbol -= 1; // Repeat last or zero symbol times lengths[index++] = len; } } } // Check for end-of-block code -- there better be one! if (lengths[256] == 0) { return (ErrorCode.ERR_MISSING_END_OF_BLOCK, lencode, distcode); } // Build huffman table for literal/length codes err = _construct(lencode, lengths, nlen, 0); if ( err != ErrorCode.ERR_NONE && (err == ErrorCode.ERR_NOT_TERMINATED || err == ErrorCode.ERR_OUTPUT_EXHAUSTED || nlen != lencode.counts[0] + lencode.counts[1]) ) { // Incomplete code ok only for single length 1 code return ( ErrorCode.ERR_INVALID_LITERAL_LENGTH_CODE_LENGTHS, lencode, distcode ); } // Build huffman table for distance codes err = _construct(distcode, lengths, ndist, nlen); if ( err != ErrorCode.ERR_NONE && (err == ErrorCode.ERR_NOT_TERMINATED || err == ErrorCode.ERR_OUTPUT_EXHAUSTED || ndist != distcode.counts[0] + distcode.counts[1]) ) { // Incomplete code ok only for single length 1 code return ( ErrorCode.ERR_INVALID_DISTANCE_CODE_LENGTHS, lencode, distcode ); } return (ErrorCode.ERR_NONE, lencode, distcode); } function _dynamic(State memory s) private pure returns (ErrorCode) { // Length and distance codes Huffman memory lencode; Huffman memory distcode; // Error code ErrorCode err; (err, lencode, distcode) = _build_dynamic(s); if (err != ErrorCode.ERR_NONE) { return err; } // Decode data until end-of-block code return _codes(s, lencode, distcode); } function puff(bytes memory source, uint256 destlen) internal pure returns (ErrorCode, bytes memory) { // Input/output state State memory s = State( new bytes(destlen), 0, source, 0, 0, 0, Huffman(new uint256[](MAXBITS + 1), new uint256[](FIXLCODES)), Huffman(new uint256[](MAXBITS + 1), new uint256[](MAXDCODES)) ); // Temp: last bit uint256 last; // Temp: block type bit uint256 t; // Error code ErrorCode err; // Build fixed Huffman tables err = _build_fixed(s); if (err != ErrorCode.ERR_NONE) { return (err, s.output); } // Process blocks until last block or error while (last == 0) { // One if last block (err, last) = bits(s, 1); if (err != ErrorCode.ERR_NONE) { return (err, s.output); } // Block type 0..3 (err, t) = bits(s, 2); if (err != ErrorCode.ERR_NONE) { return (err, s.output); } err = ( t == 0 ? _stored(s) : ( t == 1 ? _fixed(s) : ( t == 2 ? _dynamic(s) : ErrorCode.ERR_INVALID_BLOCK_TYPE ) ) ); // type == 3, invalid if (err != ErrorCode.ERR_NONE) { // Return with error break; } } return (err, s.output); } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.9; import {ERC721Upgradeable} from "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import {IERC2981Upgradeable, IERC165Upgradeable} from "@openzeppelin/contracts-upgradeable/interfaces/IERC2981Upgradeable.sol"; import {OwnableUpgradeable} from "@openzeppelin/contracts-upgradeable/access/OwnableUpgradeable.sol"; import {StringsUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/StringsUpgradeable.sol"; import {CountersUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/CountersUpgradeable.sol"; import {IBaseERC721Interface} from "./IBaseERC721Interface.sol"; struct ConfigSettings { uint16 royaltyBps; string uriBase; string uriExtension; bool hasTransferHook; } /** This smart contract adds features and allows for a ownership only by another smart contract as fallback behavior while also implementing all normal ERC721 functions as expected */ contract ERC721Base is ERC721Upgradeable, IBaseERC721Interface, IERC2981Upgradeable, OwnableUpgradeable { using CountersUpgradeable for CountersUpgradeable.Counter; // Minted counter for totalSupply() CountersUpgradeable.Counter private mintedCounter; modifier onlyInternal() { require(msg.sender == address(this), "Only internal"); _; } /// on-chain record of when this contract was deployed uint256 public immutable deployedBlock; ConfigSettings public advancedConfig; /// Constructor called once when the base contract is deployed constructor() { // Can be used to verify contract implementation is correct at address deployedBlock = block.number; } /// Initializer that's called when a new child nft is setup /// @param newOwner Owner for the new derived nft /// @param _name name of NFT contract /// @param _symbol symbol of NFT contract /// @param settings configuration settings for uri, royalty, and hooks features function initialize( address newOwner, string memory _name, string memory _symbol, ConfigSettings memory settings ) public initializer { __ERC721_init(_name, _symbol); __Ownable_init(); advancedConfig = settings; transferOwnership(newOwner); } /// Getter to expose appoval status to root contract function isApprovedForAll(address _owner, address operator) public view override returns (bool) { return ERC721Upgradeable.isApprovedForAll(_owner, operator) || operator == address(this); } /// internal getter for approval by all /// When isApprovedForAll is overridden, this can be used to call original impl function __isApprovedForAll(address _owner, address operator) public view override returns (bool) { return isApprovedForAll(_owner, operator); } /// Hook that when enabled manually calls _beforeTokenTransfer on function _beforeTokenTransfer( address from, address to, uint256 tokenId ) internal override { if (advancedConfig.hasTransferHook) { (bool success, ) = address(this).delegatecall( abi.encodeWithSignature( "_beforeTokenTransfer(address,address,uint256)", from, to, tokenId ) ); // Raise error again from result if error exists assembly { switch success // delegatecall returns 0 on error. case 0 { returndatacopy(0, 0, returndatasize()) revert(0, returndatasize()) } } } } /// Internal-only function to update the base uri function __setBaseURI(string memory uriBase, string memory uriExtension) public override onlyInternal { advancedConfig.uriBase = uriBase; advancedConfig.uriExtension = uriExtension; } /// @dev returns the number of minted tokens /// uses some extra gas but makes etherscan and users happy so :shrug: /// partial erc721enumerable implemntation function totalSupply() public view returns (uint256) { return mintedCounter.current(); } /** Internal-only @param to address to send the newly minted NFT to @dev This mints one edition to the given address by an allowed minter on the edition instance. */ function __mint(address to, uint256 tokenId) external override onlyInternal { _mint(to, tokenId); mintedCounter.increment(); } /** @param tokenId Token ID to burn User burn function for token id */ function burn(uint256 tokenId) public { require(_isApprovedOrOwner(_msgSender(), tokenId), "Not allowed"); _burn(tokenId); mintedCounter.decrement(); } /// Internal only function __burn(uint256 tokenId) public onlyInternal { _burn(tokenId); mintedCounter.decrement(); } /** Simple override for owner interface. */ function owner() public view override(OwnableUpgradeable) returns (address) { return super.owner(); } /// internal alias for overrides function __owner() public view override(IBaseERC721Interface) returns (address) { return owner(); } /// Get royalty information for token /// ignored token id to get royalty info. able to override and set per-token royalties /// @param _salePrice sales price for token to determine royalty split function royaltyInfo(uint256, uint256 _salePrice) external view override returns (address receiver, uint256 royaltyAmount) { // If ownership is revoked, don't set royalties. if (owner() == address(0x0)) { return (owner(), 0); } return (owner(), (_salePrice * advancedConfig.royaltyBps) / 10_000); } /// Default simple token-uri implementation. works for ipfs folders too /// @param tokenId token id ot get uri for /// @return default uri getter functionality function tokenURI(uint256 tokenId) public view override returns (string memory) { require(_exists(tokenId), "No token"); return string( abi.encodePacked( advancedConfig.uriBase, StringsUpgradeable.toString(tokenId), advancedConfig.uriExtension ) ); } /// internal base override function __tokenURI(uint256 tokenId) public view onlyInternal returns (string memory) { return tokenURI(tokenId); } /// Exposing token exists check for base contract function __exists(uint256 tokenId) external view override returns (bool) { return _exists(tokenId); } /// Getter for approved or owner function __isApprovedOrOwner(address spender, uint256 tokenId) external view override onlyInternal returns (bool) { return _isApprovedOrOwner(spender, tokenId); } /// IERC165 getter /// @param interfaceId interfaceId bytes4 to check support for function supportsInterface(bytes4 interfaceId) public view override(ERC721Upgradeable, IERC165Upgradeable) returns (bool) { return type(IERC2981Upgradeable).interfaceId == interfaceId || type(IBaseERC721Interface).interfaceId == interfaceId || ERC721Upgradeable.supportsInterface(interfaceId); } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.9; import {StorageSlotUpgradeable} from "@openzeppelin/contracts-upgradeable/utils/StorageSlotUpgradeable.sol"; import {IBaseERC721Interface, ConfigSettings} from "./ERC721Base.sol"; contract ERC721Delegated { uint256[100000] gap; bytes32 internal constant _IMPLEMENTATION_SLOT = 0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc; // Reference to base NFT implementation function implementation() public view returns (address) { return StorageSlotUpgradeable.getAddressSlot(_IMPLEMENTATION_SLOT).value; } function _initImplementation(address _nftImplementation) private { StorageSlotUpgradeable .getAddressSlot(_IMPLEMENTATION_SLOT) .value = _nftImplementation; } /// Constructor that sets up the constructor( address _nftImplementation, string memory name, string memory symbol, ConfigSettings memory settings ) { /// Removed for gas saving reasons, the check below implictly accomplishes this // require( // _nftImplementation.supportsInterface( // type(IBaseERC721Interface).interfaceId // ) // ); _initImplementation(_nftImplementation); (bool success, ) = _nftImplementation.delegatecall( abi.encodeWithSignature( "initialize(address,string,string,(uint16,string,string,bool))", msg.sender, name, symbol, settings ) ); require(success); } /// OnlyOwner implemntation that proxies to base ownable contract for info modifier onlyOwner() { require(msg.sender == base().__owner(), "Not owner"); _; } /// Getter to return the base implementation contract to call methods from /// Don't expose base contract to parent due to need to call private internal base functions function base() private view returns (IBaseERC721Interface) { return IBaseERC721Interface(address(this)); } // helpers to mimic Openzeppelin internal functions /// Getter for the contract owner /// @return address owner address function _owner() internal view returns (address) { return base().__owner(); } /// Internal burn function, only accessible from within contract /// @param id nft id to burn function _burn(uint256 id) internal { base().__burn(id); } /// Internal mint function, only accessible from within contract /// @param to address to mint NFT to /// @param id nft id to mint function _mint(address to, uint256 id) internal { base().__mint(to, id); } /// Internal exists function to determine if fn exists /// @param id nft id to check if exists function _exists(uint256 id) internal view returns (bool) { return base().__exists(id); } /// Internal getter for tokenURI /// @param tokenId id of token to get tokenURI for function _tokenURI(uint256 tokenId) internal view returns (string memory) { return base().__tokenURI(tokenId); } /// is approved for all getter underlying getter /// @param owner to check /// @param operator to check function _isApprovedForAll(address owner, address operator) internal view returns (bool) { return base().__isApprovedForAll(owner, operator); } /// Internal getter for approved or owner for a given operator /// @param operator address of operator to check /// @param id id of nft to check for function _isApprovedOrOwner(address operator, uint256 id) internal view returns (bool) { return base().__isApprovedOrOwner(operator, id); } /// Sets the base URI of the contract. Allowed only by parent contract /// @param newUri new uri base (http://URI) followed by number string of nft followed by extension string /// @param newExtension optional uri extension function _setBaseURI(string memory newUri, string memory newExtension) internal { base().__setBaseURI(newUri, newExtension); } /** * @dev Delegates the current call to nftImplementation. * * This function does not return to its internall call site, it will return directly to the external caller. */ function _fallback() internal virtual { address impl = implementation(); assembly { // Copy msg.data. We take full control of memory in this inline assembly // block because it will not return to Solidity code. We overwrite the // Solidity scratch pad at memory position 0. calldatacopy(0, 0, calldatasize()) // Call the implementation. // out and outsize are 0 because we don't know the size yet. let result := delegatecall(gas(), impl, 0, calldatasize(), 0, 0) // Copy the returned data. returndatacopy(0, 0, returndatasize()) switch result // delegatecall returns 0 on error. case 0 { revert(0, returndatasize()) } default { return(0, returndatasize()) } } } /** * @dev Fallback function that delegates calls to the address returned by `_implementation()`. Will run if no other * function in the contract matches the call data. */ fallback() external virtual { _fallback(); } /** * @dev No base NFT functions receive any value */ receive() external payable { revert(); } }
// SPDX-License-Identifier: GPL-3.0 pragma solidity 0.8.9; /// Additional features and functions assigned to the /// Base721 contract for hooks and overrides interface IBaseERC721Interface { /* Exposing common NFT internal functionality for base contract overrides To save gas and make API cleaner this is only for new functionality not exposed in the core ERC721 contract */ /// Mint an NFT. Allowed to mint by owner, approval or by the parent contract /// @param tokenId id to burn function __burn(uint256 tokenId) external; /// Mint an NFT. Allowed only by the parent contract /// @param to address to mint to /// @param tokenId token id to mint function __mint(address to, uint256 tokenId) external; /// Set the base URI of the contract. Allowed only by parent contract /// @param base base uri /// @param extension extension function __setBaseURI(string memory base, string memory extension) external; /* Exposes common internal read features for public use */ /// Token exists /// @param tokenId token id to see if it exists function __exists(uint256 tokenId) external view returns (bool); /// Simple approval for operation check on token for address /// @param spender address spending/changing token /// @param tokenId tokenID to change / operate on function __isApprovedOrOwner(address spender, uint256 tokenId) external view returns (bool); function __isApprovedForAll(address owner, address operator) external view returns (bool); function __tokenURI(uint256 tokenId) external view returns (string memory); function __owner() external view returns (address); }
{ "evmVersion": "london", "libraries": {}, "metadata": { "bytecodeHash": "ipfs", "useLiteralContent": true }, "optimizer": { "enabled": true, "runs": 100 }, "remappings": [], "outputSelection": { "*": { "*": [ "evm.bytecode", "evm.deployedBytecode", "devdoc", "userdoc", "metadata", "abi" ] } } }
Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
[{"inputs":[{"internalType":"address","name":"baseFactory","type":"address"},{"internalType":"address","name":"_rendererAddress","type":"address"},{"internalType":"uint256","name":"_maxSupply","type":"uint256"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"uint256","name":"tokenId","type":"uint256"},{"indexed":true,"internalType":"address","name":"actor","type":"address"}],"name":"DrankCoffee","type":"event"},{"stateMutability":"nonpayable","type":"fallback"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"burn","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"drinkCoffee","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"implementation","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"maxSupply","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"count","type":"uint256"}],"name":"mint","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"mintsLeft","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"renderer","outputs":[{"internalType":"contract GmRenderer","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"salePrice","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"seed","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"newPrice","type":"uint256"}],"name":"setSalePrice","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"tokenId","type":"uint256"}],"name":"tokenURI","outputs":[{"internalType":"string","name":"","type":"string"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"withdraw","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]
Contract Creation Code
60a06040523480156200001157600080fd5b5060405162001a3538038062001a3583398101604081905262000034916200021f565b8260405180604001604052806002815260200161676d60f01b81525060405180604001604052806002815260200161676d60f01b81525060405180608001604052806103e861ffff16815260200160405180602001604052806000815250815260200160405180602001604052806000815250815260200160001515815250620000c484620001a460201b60201c565b6000846001600160a01b031633858585604051602401620000e99493929190620002c1565b60408051601f198184030181529181526020820180516001600160e01b031663b1a78e3f60e01b1790525162000120919062000360565b600060405180830381855af49150503d80600081146200015d576040519150601f19603f3d011682016040523d82523d6000602084013e62000162565b606091505b50509050806200017157600080fd5b5050620186a280546001600160a01b0319166001600160a01b0396909616959095179094555050608052506200037e9050565b80620001de7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc60001b620001ff60201b6200098f1760201c565b80546001600160a01b0319166001600160a01b039290921691909117905550565b90565b80516001600160a01b03811681146200021a57600080fd5b919050565b6000806000606084860312156200023557600080fd5b620002408462000202565b9250620002506020850162000202565b9150604084015190509250925092565b60005b838110156200027d57818101518382015260200162000263565b838111156200028d576000848401525b50505050565b60008151808452620002ad81602086016020860162000260565b601f01601f19169290920160200192915050565b6001600160a01b0385168152608060208201819052600090620002e79083018662000293565b8281036040840152620002fb818662000293565b9050828103606084015261ffff845116815260208401516080602083015262000328608083018262000293565b90506040850151828203604084015262000343828262000293565b915050606085015115156060830152809250505095945050505050565b600082516200037481846020870162000260565b9190910192915050565b60805161168d620003a860003960008181610239015281816105bd01526105e8015261168d6000f3fe6080604052600436106100ab5760003560e01c8063955648371161006457806395564837146101955780639d5561e1146101d2578063a0712d68146101e7578063c87b56dd146101fa578063d5abeb0114610227578063f51f96dd1461025b576100b5565b80631919fed7146100cc5780633ccfd60b146100ec57806342966c68146101015780635c60da1b1461012157806385e9a256146101535780638ada6b0f14610173576100b5565b366100b557600080fd5b3480156100c157600080fd5b506100ca610273565b005b3480156100d857600080fd5b506100ca6100e7366004610f73565b6102a8565b3480156100f857600080fd5b506100ca610359565b34801561010d57600080fd5b506100ca61011c366004610f73565b61040d565b34801561012d57600080fd5b5061013661047b565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561015f57600080fd5b506100ca61016e366004610f73565b6104a9565b34801561017f57600080fd5b50620186a254610136906001600160a01b031681565b3480156101a157600080fd5b506101c46101b0366004610f73565b6000908152620186a3602052604090205490565b60405190815260200161014a565b3480156101de57600080fd5b506101c46105aa565b6100ca6101f5366004610f73565b6105e6565b34801561020657600080fd5b5061021a610215366004610f73565b6107eb565b60405161014a9190610fbc565b34801561023357600080fd5b506101c47f000000000000000000000000000000000000000000000000000000000000000081565b34801561026757600080fd5b506101c4620186a15481565b600061027d61047b565b90503660008037600080366000845af43d6000803e80801561029e573d6000f35b3d6000fd5b505050565b306001600160a01b03166313effa0f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156102e157600080fd5b505afa1580156102f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103199190610fef565b6001600160a01b0316336001600160a01b0316146103525760405162461bcd60e51b815260040161034990611018565b60405180910390fd5b620186a155565b306001600160a01b03166313effa0f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561039257600080fd5b505afa1580156103a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ca9190610fef565b6001600160a01b0316336001600160a01b0316146103fa5760405162461bcd60e51b815260040161034990611018565b61040b610405610992565b47610a05565b565b6104173382610b1e565b61046f5760405162461bcd60e51b815260206004820152602360248201527f476d3a206f6e6c7920617070726f766564206f72206f776e65722063616e20626044820152623ab93760e91b6064820152608401610349565b61047881610baa565b50565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6104b33382610b1e565b6104ee5760405162461bcd60e51b815260206004820152600c60248201526b2732b2b239903a379037bbb760a11b6044820152606401610349565b6000818152620186a4602052604090205460ff16156105445760405162461bcd60e51b8152602060048201526012602482015271416c72656164792068616420636f6666656560701b6044820152606401610349565b6000818152620186a460205260409020805460ff1916600117905561056881610bfe565b6000828152620186a36020526040808220929092559051339183917fd2d32cc177f71da46854436b0d443dbdba9b2fbdf1179d6ba10624d8321794ca9190a350565b60006105b7620186a05490565b6105e1907f0000000000000000000000000000000000000000000000000000000000000000611051565b905090565b7f000000000000000000000000000000000000000000000000000000000000000081610613620186a05490565b61061d9190611068565b111561066b5760405162461bcd60e51b815260206004820181905260248201527f476d3a206d696e7420776f756c6420657863656564206d617820737570706c796044820152606401610349565b620186a1546106b35760405162461bcd60e51b815260206004820152601460248201527311db4e881cd85b19481b9bdd081cdd185c9d195960621b6044820152606401610349565b600a81111561071c5760405162461bcd60e51b815260206004820152602f60248201527f476d3a2063616e6e6f74206d696e74206d6f7265207468616e20313020696e2060448201526e37b732903a3930b739b0b1ba34b7b760891b6064820152608401610349565b80620186a15461072c9190611080565b34146107715760405162461bcd60e51b8152602060048201526014602482015273476d3a2077726f6e672073616c6520707269636560601b6044820152606401610349565b60005b818110156107e75761078f61078a620186a05490565b610bfe565b620186a360006107a0620186a05490565b81526020810191909152604001600020556107c5336107c0620186a05490565b610c6d565b6107d5620186a080546001019055565b806107df8161109f565b915050610774565b5050565b620186a2546000828152620186a360205260408082205490516319c6e3a760e11b815260609384939283928392839283926001600160a01b039092169163338dc74e9161083e9160040190815260200190565b60006040518083038186803b15801561085657600080fd5b505afa15801561086a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108929190810190611158565b60008d8152620186a460205260409020549499509297509095509350915060609060ff16156108db575060408051808201909152600381526259657360e81b60208201526108f6565b506040805180820190915260028152614e6f60f01b60208201525b60008585858486604051602001610911959493929190611246565b604051602081830303815290604052905061095e61092e8b610cd6565b61093789610ddc565b8360405160200161094a939291906113e0565b604051602081830303815290604052610e0d565b9750876040516020016109719190611517565b60405160208183030381529060405298505050505050505050919050565b90565b6000306001600160a01b03166313effa0f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156109cd57600080fd5b505afa1580156109e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105e19190610fef565b80471015610a555760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610349565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610aa2576040519150601f19603f3d011682016040523d82523d6000602084013e610aa7565b606091505b50509050806102a35760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610349565b60003060405163296cf3bd60e11b81526001600160a01b0385811660048301526024820185905291909116906352d9e77a9060440160206040518083038186803b158015610b6b57600080fd5b505afa158015610b7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba3919061155c565b9392505050565b60405163068d00a960e51b815260048101829052309063d1a0152090602401600060405180830381600087803b158015610be357600080fd5b505af1158015610bf7573d6000803e3d6000fd5b5050505050565b6000333a834342610c10600183611051565b60405160609690961b6bffffffffffffffffffffffff1916602087015260348601949094526054850192909252607484015260948301524060b482015260d401604051602081830303815290604052805190602001209050919050565b30604051633dc8ded760e01b81526001600160a01b038481166004830152602482018490529190911690633dc8ded790604401600060405180830381600087803b158015610cba57600080fd5b505af1158015610cce573d6000803e3d6000fd5b505050505050565b606081610cfa5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115610d245780610d0e8161109f565b9150610d1d9050600a83611594565b9150610cfe565b60008167ffffffffffffffff811115610d3f57610d3f6110ba565b6040519080825280601f01601f191660200182016040528015610d69576020820181803683370190505b5090505b8415610dd457610d7e600183611051565b9150610d8b600a866115a8565b610d96906030611068565b60f81b818381518110610dab57610dab6115bc565b60200101906001600160f81b031916908160001a905350610dcd600a86611594565b9450610d6d565b949350505050565b6060610de782610e0d565b604051602001610df791906115d2565b6040516020818303038152906040529050919050565b6060815160001415610e2d57505060408051602081019091526000815290565b60006040518060600160405280604081526020016116186040913990506000600384516002610e5c9190611068565b610e669190611594565b610e71906004611080565b90506000610e80826020611068565b67ffffffffffffffff811115610e9857610e986110ba565b6040519080825280601f01601f191660200182016040528015610ec2576020820181803683370190505b509050818152600183018586518101602084015b81831015610f2e576003830192508251603f8160121c168501518253600182019150603f81600c1c168501518253600182019150603f8160061c168501518253600182019150603f8116850151825350600101610ed6565b600389510660018114610f485760028114610f5957610f65565b613d3d60f01b600119830152610f65565b603d60f81b6000198301525b509398975050505050505050565b600060208284031215610f8557600080fd5b5035919050565b60005b83811015610fa7578181015183820152602001610f8f565b83811115610fb6576000848401525b50505050565b6020815260008251806020840152610fdb816040850160208701610f8c565b601f01601f19169190910160400192915050565b60006020828403121561100157600080fd5b81516001600160a01b0381168114610ba357600080fd5b6020808252600990820152682737ba1037bbb732b960b91b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000828210156110635761106361103b565b500390565b6000821982111561107b5761107b61103b565b500190565b600081600019048311821515161561109a5761109a61103b565b500290565b60006000198214156110b3576110b361103b565b5060010190565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126110e157600080fd5b815167ffffffffffffffff808211156110fc576110fc6110ba565b604051601f8301601f19908116603f01168101908282118183101715611124576111246110ba565b8160405283815286602085880101111561113d57600080fd5b61114e846020830160208901610f8c565b9695505050505050565b600080600080600060a0868803121561117057600080fd5b855167ffffffffffffffff8082111561118857600080fd5b61119489838a016110d0565b965060208801519150808211156111aa57600080fd5b6111b689838a016110d0565b955060408801519150808211156111cc57600080fd5b6111d889838a016110d0565b945060608801519150808211156111ee57600080fd5b6111fa89838a016110d0565b9350608088015191508082111561121057600080fd5b5061121d888289016110d0565b9150509295509295909350565b6000815161123c818560208601610f8c565b9290920192915050565b6e2261747472696275746573223a205b60881b81527f7b2274726169745f74797065223a227374796c65222c2276616c7565223a2200600f820152855160009061129781602e850160208b01610f8c565b7f227d2c7b2274726169745f74797065223a226261636b67726f756e6420636f6c602e918401918201526c37b91116113b30b63ab2911d1160991b604e82015286516112ea81605b840160208b01610f8c565b7f227d2c7b2274726169745f74797065223a22666f6e7420636f6c6f72222c2276605b92909101918201526630b63ab2911d1160c91b607b8201528551611338816082840160208a01610f8c565b7f227d2c7b2274726169745f74797065223a226361666665696e61746564222c2260829290910191820152673b30b63ab2911d1160c11b60a28201526113d46113c56113bf61138a60aa85018961122a565b7f227d2c7b2274726169745f74797065223a22656666656374222c2276616c7565815262111d1160e91b602082015260230190565b8661122a565b62227d5d60e81b815260030190565b98975050505050505050565b7f7b226465736372697074696f6e223a2022676d2d6f6e636861696e206973206181527f20636f6c6c656374696f6e206f6620363936392072616e646f6d6c792067656e60208201527f6572617465642c206f6e636861696e2072656e646572696e6773206f66206f7560408201527f72206661766f726974652063727970746f207068726173652e20656e6a6f792e6060820152600061088b60f21b8060808401526c0113a34ba3632911d101133b69609d1b608284015285516114ac81608f860160208a01610f8c565b6c1116101134b6b0b3b2911d101160991b608f9185019182015285516114d981609c840160208a01610f8c565b01609c8101919091528351906114f682609e830160208801610f8c565b61150c609e83830101607d60f81b815260010190565b979650505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161154f81601d850160208701610f8c565b91909101601d0192915050565b60006020828403121561156e57600080fd5b81518015158114610ba357600080fd5b634e487b7160e01b600052601260045260246000fd5b6000826115a3576115a361157e565b500490565b6000826115b7576115b761157e565b500690565b634e487b7160e01b600052603260045260246000fd5b7f646174613a696d6167652f7376672b786d6c3b6261736536342c00000000000081526000825161160a81601a850160208701610f8c565b91909101601a019291505056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa26469706673582212208a752402cc66be9cc8a08365a08f7e87e02147c59acf447f21af126c0b90cd5664736f6c6343000809003300000000000000000000000043955024b1985e2b933a59021500ae5f55b04091000000000000000000000000bdfc8539bd9825ead5e57a5b3b0f92195fafc36f0000000000000000000000000000000000000000000000000000000000001b39
Deployed Bytecode
0x6080604052600436106100ab5760003560e01c8063955648371161006457806395564837146101955780639d5561e1146101d2578063a0712d68146101e7578063c87b56dd146101fa578063d5abeb0114610227578063f51f96dd1461025b576100b5565b80631919fed7146100cc5780633ccfd60b146100ec57806342966c68146101015780635c60da1b1461012157806385e9a256146101535780638ada6b0f14610173576100b5565b366100b557600080fd5b3480156100c157600080fd5b506100ca610273565b005b3480156100d857600080fd5b506100ca6100e7366004610f73565b6102a8565b3480156100f857600080fd5b506100ca610359565b34801561010d57600080fd5b506100ca61011c366004610f73565b61040d565b34801561012d57600080fd5b5061013661047b565b6040516001600160a01b0390911681526020015b60405180910390f35b34801561015f57600080fd5b506100ca61016e366004610f73565b6104a9565b34801561017f57600080fd5b50620186a254610136906001600160a01b031681565b3480156101a157600080fd5b506101c46101b0366004610f73565b6000908152620186a3602052604090205490565b60405190815260200161014a565b3480156101de57600080fd5b506101c46105aa565b6100ca6101f5366004610f73565b6105e6565b34801561020657600080fd5b5061021a610215366004610f73565b6107eb565b60405161014a9190610fbc565b34801561023357600080fd5b506101c47f0000000000000000000000000000000000000000000000000000000000001b3981565b34801561026757600080fd5b506101c4620186a15481565b600061027d61047b565b90503660008037600080366000845af43d6000803e80801561029e573d6000f35b3d6000fd5b505050565b306001600160a01b03166313effa0f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156102e157600080fd5b505afa1580156102f5573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103199190610fef565b6001600160a01b0316336001600160a01b0316146103525760405162461bcd60e51b815260040161034990611018565b60405180910390fd5b620186a155565b306001600160a01b03166313effa0f6040518163ffffffff1660e01b815260040160206040518083038186803b15801561039257600080fd5b505afa1580156103a6573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103ca9190610fef565b6001600160a01b0316336001600160a01b0316146103fa5760405162461bcd60e51b815260040161034990611018565b61040b610405610992565b47610a05565b565b6104173382610b1e565b61046f5760405162461bcd60e51b815260206004820152602360248201527f476d3a206f6e6c7920617070726f766564206f72206f776e65722063616e20626044820152623ab93760e91b6064820152608401610349565b61047881610baa565b50565b7f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc546001600160a01b031690565b6104b33382610b1e565b6104ee5760405162461bcd60e51b815260206004820152600c60248201526b2732b2b239903a379037bbb760a11b6044820152606401610349565b6000818152620186a4602052604090205460ff16156105445760405162461bcd60e51b8152602060048201526012602482015271416c72656164792068616420636f6666656560701b6044820152606401610349565b6000818152620186a460205260409020805460ff1916600117905561056881610bfe565b6000828152620186a36020526040808220929092559051339183917fd2d32cc177f71da46854436b0d443dbdba9b2fbdf1179d6ba10624d8321794ca9190a350565b60006105b7620186a05490565b6105e1907f0000000000000000000000000000000000000000000000000000000000001b39611051565b905090565b7f0000000000000000000000000000000000000000000000000000000000001b3981610613620186a05490565b61061d9190611068565b111561066b5760405162461bcd60e51b815260206004820181905260248201527f476d3a206d696e7420776f756c6420657863656564206d617820737570706c796044820152606401610349565b620186a1546106b35760405162461bcd60e51b815260206004820152601460248201527311db4e881cd85b19481b9bdd081cdd185c9d195960621b6044820152606401610349565b600a81111561071c5760405162461bcd60e51b815260206004820152602f60248201527f476d3a2063616e6e6f74206d696e74206d6f7265207468616e20313020696e2060448201526e37b732903a3930b739b0b1ba34b7b760891b6064820152608401610349565b80620186a15461072c9190611080565b34146107715760405162461bcd60e51b8152602060048201526014602482015273476d3a2077726f6e672073616c6520707269636560601b6044820152606401610349565b60005b818110156107e75761078f61078a620186a05490565b610bfe565b620186a360006107a0620186a05490565b81526020810191909152604001600020556107c5336107c0620186a05490565b610c6d565b6107d5620186a080546001019055565b806107df8161109f565b915050610774565b5050565b620186a2546000828152620186a360205260408082205490516319c6e3a760e11b815260609384939283928392839283926001600160a01b039092169163338dc74e9161083e9160040190815260200190565b60006040518083038186803b15801561085657600080fd5b505afa15801561086a573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526108929190810190611158565b60008d8152620186a460205260409020549499509297509095509350915060609060ff16156108db575060408051808201909152600381526259657360e81b60208201526108f6565b506040805180820190915260028152614e6f60f01b60208201525b60008585858486604051602001610911959493929190611246565b604051602081830303815290604052905061095e61092e8b610cd6565b61093789610ddc565b8360405160200161094a939291906113e0565b604051602081830303815290604052610e0d565b9750876040516020016109719190611517565b60405160208183030381529060405298505050505050505050919050565b90565b6000306001600160a01b03166313effa0f6040518163ffffffff1660e01b815260040160206040518083038186803b1580156109cd57600080fd5b505afa1580156109e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906105e19190610fef565b80471015610a555760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610349565b6000826001600160a01b03168260405160006040518083038185875af1925050503d8060008114610aa2576040519150601f19603f3d011682016040523d82523d6000602084013e610aa7565b606091505b50509050806102a35760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610349565b60003060405163296cf3bd60e11b81526001600160a01b0385811660048301526024820185905291909116906352d9e77a9060440160206040518083038186803b158015610b6b57600080fd5b505afa158015610b7f573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ba3919061155c565b9392505050565b60405163068d00a960e51b815260048101829052309063d1a0152090602401600060405180830381600087803b158015610be357600080fd5b505af1158015610bf7573d6000803e3d6000fd5b5050505050565b6000333a834342610c10600183611051565b60405160609690961b6bffffffffffffffffffffffff1916602087015260348601949094526054850192909252607484015260948301524060b482015260d401604051602081830303815290604052805190602001209050919050565b30604051633dc8ded760e01b81526001600160a01b038481166004830152602482018490529190911690633dc8ded790604401600060405180830381600087803b158015610cba57600080fd5b505af1158015610cce573d6000803e3d6000fd5b505050505050565b606081610cfa5750506040805180820190915260018152600360fc1b602082015290565b8160005b8115610d245780610d0e8161109f565b9150610d1d9050600a83611594565b9150610cfe565b60008167ffffffffffffffff811115610d3f57610d3f6110ba565b6040519080825280601f01601f191660200182016040528015610d69576020820181803683370190505b5090505b8415610dd457610d7e600183611051565b9150610d8b600a866115a8565b610d96906030611068565b60f81b818381518110610dab57610dab6115bc565b60200101906001600160f81b031916908160001a905350610dcd600a86611594565b9450610d6d565b949350505050565b6060610de782610e0d565b604051602001610df791906115d2565b6040516020818303038152906040529050919050565b6060815160001415610e2d57505060408051602081019091526000815290565b60006040518060600160405280604081526020016116186040913990506000600384516002610e5c9190611068565b610e669190611594565b610e71906004611080565b90506000610e80826020611068565b67ffffffffffffffff811115610e9857610e986110ba565b6040519080825280601f01601f191660200182016040528015610ec2576020820181803683370190505b509050818152600183018586518101602084015b81831015610f2e576003830192508251603f8160121c168501518253600182019150603f81600c1c168501518253600182019150603f8160061c168501518253600182019150603f8116850151825350600101610ed6565b600389510660018114610f485760028114610f5957610f65565b613d3d60f01b600119830152610f65565b603d60f81b6000198301525b509398975050505050505050565b600060208284031215610f8557600080fd5b5035919050565b60005b83811015610fa7578181015183820152602001610f8f565b83811115610fb6576000848401525b50505050565b6020815260008251806020840152610fdb816040850160208701610f8c565b601f01601f19169190910160400192915050565b60006020828403121561100157600080fd5b81516001600160a01b0381168114610ba357600080fd5b6020808252600990820152682737ba1037bbb732b960b91b604082015260600190565b634e487b7160e01b600052601160045260246000fd5b6000828210156110635761106361103b565b500390565b6000821982111561107b5761107b61103b565b500190565b600081600019048311821515161561109a5761109a61103b565b500290565b60006000198214156110b3576110b361103b565b5060010190565b634e487b7160e01b600052604160045260246000fd5b600082601f8301126110e157600080fd5b815167ffffffffffffffff808211156110fc576110fc6110ba565b604051601f8301601f19908116603f01168101908282118183101715611124576111246110ba565b8160405283815286602085880101111561113d57600080fd5b61114e846020830160208901610f8c565b9695505050505050565b600080600080600060a0868803121561117057600080fd5b855167ffffffffffffffff8082111561118857600080fd5b61119489838a016110d0565b965060208801519150808211156111aa57600080fd5b6111b689838a016110d0565b955060408801519150808211156111cc57600080fd5b6111d889838a016110d0565b945060608801519150808211156111ee57600080fd5b6111fa89838a016110d0565b9350608088015191508082111561121057600080fd5b5061121d888289016110d0565b9150509295509295909350565b6000815161123c818560208601610f8c565b9290920192915050565b6e2261747472696275746573223a205b60881b81527f7b2274726169745f74797065223a227374796c65222c2276616c7565223a2200600f820152855160009061129781602e850160208b01610f8c565b7f227d2c7b2274726169745f74797065223a226261636b67726f756e6420636f6c602e918401918201526c37b91116113b30b63ab2911d1160991b604e82015286516112ea81605b840160208b01610f8c565b7f227d2c7b2274726169745f74797065223a22666f6e7420636f6c6f72222c2276605b92909101918201526630b63ab2911d1160c91b607b8201528551611338816082840160208a01610f8c565b7f227d2c7b2274726169745f74797065223a226361666665696e61746564222c2260829290910191820152673b30b63ab2911d1160c11b60a28201526113d46113c56113bf61138a60aa85018961122a565b7f227d2c7b2274726169745f74797065223a22656666656374222c2276616c7565815262111d1160e91b602082015260230190565b8661122a565b62227d5d60e81b815260030190565b98975050505050505050565b7f7b226465736372697074696f6e223a2022676d2d6f6e636861696e206973206181527f20636f6c6c656374696f6e206f6620363936392072616e646f6d6c792067656e60208201527f6572617465642c206f6e636861696e2072656e646572696e6773206f66206f7560408201527f72206661766f726974652063727970746f207068726173652e20656e6a6f792e6060820152600061088b60f21b8060808401526c0113a34ba3632911d101133b69609d1b608284015285516114ac81608f860160208a01610f8c565b6c1116101134b6b0b3b2911d101160991b608f9185019182015285516114d981609c840160208a01610f8c565b01609c8101919091528351906114f682609e830160208801610f8c565b61150c609e83830101607d60f81b815260010190565b979650505050505050565b7f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c00000081526000825161154f81601d850160208701610f8c565b91909101601d0192915050565b60006020828403121561156e57600080fd5b81518015158114610ba357600080fd5b634e487b7160e01b600052601260045260246000fd5b6000826115a3576115a361157e565b500490565b6000826115b7576115b761157e565b500690565b634e487b7160e01b600052603260045260246000fd5b7f646174613a696d6167652f7376672b786d6c3b6261736536342c00000000000081526000825161160a81601a850160208701610f8c565b91909101601a019291505056fe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa26469706673582212208a752402cc66be9cc8a08365a08f7e87e02147c59acf447f21af126c0b90cd5664736f6c63430008090033
Constructor Arguments (ABI-Encoded and is the last bytes of the Contract Creation Code above)
00000000000000000000000043955024b1985e2b933a59021500ae5f55b04091000000000000000000000000bdfc8539bd9825ead5e57a5b3b0f92195fafc36f0000000000000000000000000000000000000000000000000000000000001b39
-----Decoded View---------------
Arg [0] : baseFactory (address): 0x43955024b1985E2b933A59021500aE5f55b04091
Arg [1] : _rendererAddress (address): 0xBdFc8539bD9825eaD5E57A5B3B0f92195FaFC36F
Arg [2] : _maxSupply (uint256): 6969
-----Encoded View---------------
3 Constructor Arguments found :
Arg [0] : 00000000000000000000000043955024b1985e2b933a59021500ae5f55b04091
Arg [1] : 000000000000000000000000bdfc8539bd9825ead5e57a5b3b0f92195fafc36f
Arg [2] : 0000000000000000000000000000000000000000000000000000000000001b39
Loading...
Loading
Loading...
Loading
[ Download: CSV Export ]
A token is a representation of an on-chain or off-chain asset. The token page shows information such as price, total supply, holders, transfers and social links. Learn more about this page in our Knowledge Base.