Cryo Explorer Ethereum Mainnet

Address Contract Partially Verified

Address 0x41A322b28D0fF354040e2CbC676F0320d8c8850d
Balance 13.7278 ETH
Nonce 1
Code Size 6493 bytes
Indexed Transactions 0
External Etherscan · Sourcify

Contract Bytecode

6493 bytes
0x60606040526004361061017f5763ffffffff7c0100000000000000000000000000000000000000000000000000000000600035041663019871e98114610184578063053992c5146101de57806306fdde03146101f7578063095ea7b31461028157806318160ddd146102a35780631a289aea146102c85780632a6dd48f146102ff5780632b1fd58a146103315780633af32abf14610347578063454a2ab31461037a5780635a3f2672146103855780635c68a557146103f757806362f11dd21461040d5780636352211e1461042c578063653436fd1461044257806370a08231146104935780638da5cb5b146104b257806395d89b41146104c55780639703ef35146104d85780639f2a3c32146104ee578063a9059cbb14610504578063b2e6ceeb14610526578063c0ec93e71461053c578063c87b56dd14610552578063d5da8d4414610568578063d96a094a1461057e578063d9856c2114610589578063f071bf4f146105da578063f2bf6b8c146105ed578063f2fde38b14610600575b600080fd5b341561018f57600080fd5b6101dc60046024813581810190830135806020601f820181900481020160405190810160405281815292919060208401838380828437509496505084359460200135935061061f92505050565b005b34156101e957600080fd5b6101dc6004356024356107a4565b341561020257600080fd5b61020a610832565b60405160208082528190810183818151815260200191508051906020019080838360005b8381101561024657808201518382015260200161022e565b50505050905090810190601f1680156102735780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b341561028c57600080fd5b6101dc600160a060020a036004351660243561017f565b34156102ae57600080fd5b6102b6610874565b60405190815260200160405180910390f35b34156102d357600080fd5b6102de60043561087a565b604051918252600160a060020a031660208201526040908101905180910390f35b341561030a57600080fd5b6103156004356108a3565b604051600160a060020a03909116815260200160405180910390f35b341561033c57600080fd5b6101dc6004356108be565b341561035257600080fd5b610366600160a060020a03600435166109c6565b604051901515815260200160405180910390f35b6101dc6004356109e4565b341561039057600080fd5b6103a4600160a060020a0360043516610a98565b60405160208082528190810183818151815260200191508051906020019060200280838360005b838110156103e35780820151838201526020016103cb565b505050509050019250505060405180910390f35b341561040257600080fd5b6101dc600435610b1b565b341561041857600080fd5b6101dc600160a060020a0360043516610b3b565b341561043757600080fd5b610315600435610ba9565b341561044d57600080fd5b6102b660046024813581810190830135806020601f82018190048102016040519081016040528181529291906020840183838082843750949650610bd395505050505050565b341561049e57600080fd5b6102b6600160a060020a0360043516610c4e565b34156104bd57600080fd5b610315610c69565b34156104d057600080fd5b61020a610c78565b34156104e357600080fd5b6101dc600435610cb9565b34156104f957600080fd5b6102b6600435610d6d565b341561050f57600080fd5b6101dc600160a060020a0360043516602435610d7f565b341561053157600080fd5b6101dc600435610dda565b341561054757600080fd5b6101dc600435610e05565b341561055d57600080fd5b61020a600435610e25565b341561057357600080fd5b610315600435610ee0565b6101dc600435610efb565b341561059457600080fd5b6101dc60046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061102395505050505050565b34156105e557600080fd5b6102b661113a565b34156105f857600080fd5b6102b6611140565b341561060b57600080fd5b6101dc600160a060020a0360043516611146565b600080600085600d816040518082805190602001908083835b602083106106575780518252601f199092019160209182019101610638565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051908190039020541561069657600080fd5b600160a060020a0333166000908152600f602052604090205460ff1615156001146106c057600080fd5b6106ca87336111d4565b935083600d886040518082805190602001908083835b602083106106ff5780518252601f1990920191602091820191016106e0565b6001836020036101000a03801982511681845116808217855250505050505090500191505090815260200160405190819003902055600092505b8583101561079b5761074b87336111d4565b6000818152600a602052604090819020879055909250859083907fe23ea816dce6d7f5c0b85cbd597e7c3b97b2453791152c0b94e5e5c5f314d2f0905160405180910390a3600190920191610739565b50505050505050565b60008233600160a060020a03166107ba82610ba9565b600160a060020a0316146107cd57600080fd5b60008481526009602052604090205491508183116107ea57600080fd5b6000848152600a602052604090819020849055839085907fe23ea816dce6d7f5c0b85cbd597e7c3b97b2453791152c0b94e5e5c5f314d2f0905160405180910390a350505050565b61083a611867565b60408051908101604052600881527f5375706552617265000000000000000000000000000000000000000000000000602082015290505b90565b60005490565b600081815260096020908152604080832054600890925290912054600160a060020a0316915091565b600090815260026020526040902054600160a060020a031690565b6000806000808433600160a060020a03166108d882610ba9565b600160a060020a0316146108eb57600080fd5b600086815260096020908152604080832054600890925290912054909550600160a060020a0316935061091d86610ba9565b6000878152600b6020526040902054909350600160a060020a03169150610945338588611238565b60055461095f908690600160a060020a031684868a6112fe565b61096886611442565b8583600160a060020a031685600160a060020a03167fd6deddb2e105b46d4644d24aac8c58493a0f107e7973b2fe8d8fa7931a2912be8860405190815260200160405180910390a450505060009283525050600a6020526040812055565b600160a060020a03166000908152600f602052604090205460ff1690565b8033600160a060020a03166109f882610ba9565b600160a060020a03161415610a0c57600080fd5b610a158261146b565b1515610a2057600080fd5b610a298261147f565b60008281526008602090815260408083208054600160a060020a03191633600160a060020a0316908117909155600990925291829020349081905584929091907f19421268847f42dd61705778018ddfc43bcdce8517e7a630acb12f122c709481905160405180910390a45050565b610aa0611867565b6003600083600160a060020a0316600160a060020a03168152602001908152602001600020805480602002602001604051908101604052809291908181526020018280548015610b0f57602002820191906000526020600020905b815481526020019060010190808311610afb575b50505050509050919050565b60055433600160a060020a03908116911614610b3657600080fd5b600655565b60055433600160a060020a03908116911614610b5657600080fd5b600160a060020a0381166000818152600f602052604090819020805460ff191660011790557f55eed0aed3ec6e015b9ad5e984675fe36c0ce3aebdcb70f467670773f19f7f8d905160405180910390a250565b600081815260016020526040812054600160a060020a0316801515610bcd57600080fd5b92915050565b600080600d836040518082805190602001908083835b60208310610c085780518252601f199092019160209182019101610be9565b6001836020036101000a0380198251168184511680821785525050505050509050019150509081526020016040518091039020549050610c4781610ba9565b5092915050565b600160a060020a031660009081526003602052604090205490565b600554600160a060020a031681565b610c80611867565b60408051908101604052600481527f53555052000000000000000000000000000000000000000000000000000000006020820152905090565b600081815260086020526040812054600160a060020a03908116919033168214610ce257600080fd5b50600082815260096020526040908190205490600160a060020a0333169082156108fc0290839051600060405180830381858888f193505050501515610d2757600080fd5b610d3083611442565b828183600160a060020a03167f09dcebe16a733e22cc47e4959c50d4f21624d9f1815db32c2e439fbbd7b3eda060405160405180910390a4505050565b6000908152600a602052604090205490565b8033600160a060020a0316610d9382610ba9565b600160a060020a031614610da657600080fd5b6000828152600e60209081526040808320805460ff19166001179055600a909152812055610dd5338484611238565b505050565b610de433826114da565b1515610def57600080fd5b610e02610dfb82610ba9565b3383611238565b50565b60055433600160a060020a03908116911614610e2057600080fd5b600755565b610e2d611867565b610e3682610ba9565b50600c60008381526020019081526020016000208054600181600116156101000203166002900480601f016020809104026020016040519081016040528092919081815260200182805460018160011615610100020316600290048015610b0f5780601f10610eb357610100808354040283529160200191610b0f565b820191906000526020600020905b815481529060010190602001808311610ec15750939695505050505050565b6000908152600b6020526040902054600160a060020a031690565b60008060008060008533600160a060020a0316610f1782610ba9565b600160a060020a03161415610f2b57600080fd5b6000878152600a60205260409020549550349450339350610f4b87610ba9565b6000888152600b6020526040812054919450600160a060020a0390911692508611610f7557600080fd5b85851015610f8257600080fd5b610f8b8761147f565b610f9487611442565b610f9f838589611238565b600554610fb9908690600160a060020a031684868b6112fe565b6000600a6000898152602001908152602001600020819055508683600160a060020a031685600160a060020a03167f16dd16959a056953a63cf14bf427881e762e54f03d86b864efea8238dd3b822f8860405190815260200160405180910390a450505050505050565b600081600d816040518082805190602001908083835b602083106110585780518252601f199092019160209182019101611039565b6001836020036101000a038019825116818451168082178552505050505050905001915050908152602001604051908190039020541561109757600080fd5b600160a060020a0333166000908152600f602052604090205460ff1615156001146110c157600080fd5b6110cb83336111d4565b915081600d846040518082805190602001908083835b602083106111005780518252601f1990920191602091820191016110e1565b6001836020036101000a03801982511681845116808217855250505050505090500191505090815260200160405190819003902055505050565b60075481565b60065481565b60055433600160a060020a0390811691161461116157600080fd5b600160a060020a038116151561117657600080fd5b600554600160a060020a0380831691167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a360058054600160a060020a031916600160a060020a0392909216919091179055565b6000806111df610874565b60010190506111ee8382611500565b6000818152600b602090815260408083208054600160a060020a031916600160a060020a038816179055600c9091529020848051611230929160200190611879565b509392505050565b600160a060020a038216151561124d57600080fd5b61125681610ba9565b600160a060020a038381169116141561126e57600080fd5b82600160a060020a031661128182610ba9565b600160a060020a03161461129457600080fd5b61129e8382611562565b6112a883826115e7565b6112b28282611745565b81600160a060020a031683600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405190815260200160405180910390a3505050565b6000818152600e60205260408120548190819060ff1615611386576113406103e86113346006548b6117fd90919063ffffffff16565b9063ffffffff61182f16565b925061135d6103e86113346007548b6117fd90919063ffffffff16565b915061137f836113738a8563ffffffff61184616565b9063ffffffff61184616565b90506113a5565b5050506000818152600e60205260408120805460ff1916600117905585815b600160a060020a03871683156108fc0284604051600060405180830381858888f1935050505015156113d657600080fd5b600160a060020a03861682156108fc0283604051600060405180830381858888f19350505050151561140757600080fd5b600160a060020a03851681156108fc0282604051600060405180830381858888f19350505050151561143857600080fd5b5050505050505050565b60009081526008602090815260408083208054600160a060020a03191690556009909152812055565b600090815260096020526040902054341190565b600081815260096020908152604080832054600890925290912054600160a060020a03168015610dd557600160a060020a03811682156108fc0283604051600060405180830381858888f193505050501515610dd557600080fd5b600082600160a060020a03166114ef836108a3565b600160a060020a0316149392505050565b600160a060020a038216151561151557600080fd5b61151f8282611745565b81600160a060020a031660007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8360405190815260200160405180910390a35050565b81600160a060020a031661157582610ba9565b600160a060020a03161461158857600080fd5b6000818152600260205260408082208054600160a060020a0319169055600160a060020a038416907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9259084905190815260200160405180910390a35050565b600080600084600160a060020a03166115ff85610ba9565b600160a060020a03161461161257600080fd5b6000848152600460205260409020549250611631600161137387610c4e565b600160a060020a03861660009081526003602052604090208054919350908390811061165957fe5b60009182526020808320909101548683526001825260408084208054600160a060020a0319169055600160a060020a03891684526003909252912080549192508291859081106116a557fe5b6000918252602080832090910192909255600160a060020a03871681526003909152604081208054849081106116d757fe5b6000918252602080832090910192909255600160a060020a038716815260039091526040902080549061170e9060001983016118f7565b5060008481526004602052604080822082905582825281208490555461173b90600163ffffffff61184616565b6000555050505050565b600081815260016020526040812054600160a060020a03161561176757600080fd5b60008281526001602052604090208054600160a060020a031916600160a060020a03851617905561179783610c4e565b600160a060020a0384166000908152600360205260409020805491925090600181016117c383826118f7565b5060009182526020808320919091018490558382526004905260408120829055546117f590600163ffffffff61185816565b600055505050565b6000808315156118105760009150610c47565b5082820282848281151561182057fe5b041461182857fe5b9392505050565b600080828481151561183d57fe5b04949350505050565b60008282111561185257fe5b50900390565b60008282018381101561182857fe5b60206040519081016040526000815290565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106118ba57805160ff19168380011785556118e7565b828001600101855582156118e7579182015b828111156118e75782518255916020019190600101906118cc565b506118f3929150611917565b5090565b815481835581811511610dd557600083815260209020610dd59181019083015b61087191905b808211156118f3576000815560010161191d5600a165627a7a72305820a5a90035ddc72fcfd3293a41dad9a688e046d74d8130c2dda9fc71bd5ebf65450029

Verified Source Code Partial Match

Compiler: v0.4.21+commit.dfe3193c EVM: byzantium Optimization: Yes (200 runs)
SupeRare.sol 688 lines
pragma solidity ^0.4.18;



/**
 * @title ERC721 interface
 * @dev see https://github.com/ethereum/eips/issues/721
 */
contract ERC721 {
  event Transfer(address indexed _from, address indexed _to, uint256 _tokenId);
  event Approval(address indexed _owner, address indexed _approved, uint256 _tokenId);

  function balanceOf(address _owner) public view returns (uint256 _balance);
  function ownerOf(uint256 _tokenId) public view returns (address _owner);
  function transfer(address _to, uint256 _tokenId) public;
  function approve(address _to, uint256 _tokenId) public;
  function takeOwnership(uint256 _tokenId) public;
}

/**
 * @title SafeMath
 * @dev Math operations with safety checks that throw on error
 */
library SafeMath {

  /**
  * @dev Multiplies two numbers, throws on overflow.
  */
  function mul(uint256 a, uint256 b) internal pure returns (uint256) {
    if (a == 0) {
      return 0;
    }
    uint256 c = a * b;
    assert(c / a == b);
    return c;
  }

  /**
  * @dev Integer division of two numbers, truncating the quotient.
  */
  function div(uint256 a, uint256 b) internal pure returns (uint256) {
    // assert(b > 0); // Solidity automatically throws when dividing by 0
    uint256 c = a / b;
    // assert(a == b * c + a % b); // There is no case in which this doesn't hold
    return c;
  }

  /**
  * @dev Substracts two numbers, throws on overflow (i.e. if subtrahend is greater than minuend).
  */
  function sub(uint256 a, uint256 b) internal pure returns (uint256) {
    assert(b <= a);
    return a - b;
  }

  /**
  * @dev Adds two numbers, throws on overflow.
  */
  function add(uint256 a, uint256 b) internal pure returns (uint256) {
    uint256 c = a + b;
    assert(c >= a);
    return c;
  }
}


/**
 * @title ERC721Token
 * Generic implementation for the required functionality of the ERC721 standard
 */
contract ERC721Token is ERC721 {
  using SafeMath for uint256;

  // Total amount of tokens
  uint256 private totalTokens;

  // Mapping from token ID to owner
  mapping (uint256 => address) private tokenOwner;

  // Mapping from token ID to approved address
  mapping (uint256 => address) private tokenApprovals;

  // Mapping from owner to list of owned token IDs
  mapping (address => uint256[]) private ownedTokens;

  // Mapping from token ID to index of the owner tokens list
  mapping(uint256 => uint256) private ownedTokensIndex;

  /**
  * @dev Guarantees msg.sender is owner of the given token
  * @param _tokenId uint256 ID of the token to validate its ownership belongs to msg.sender
  */
  modifier onlyOwnerOf(uint256 _tokenId) {
    require(ownerOf(_tokenId) == msg.sender);
    _;
  }

  /**
  * @dev Gets the total amount of tokens stored by the contract
  * @return uint256 representing the total amount of tokens
  */
  function totalSupply() public view returns (uint256) {
    return totalTokens;
  }

  /**
  * @dev Gets the balance of the specified address
  * @param _owner address to query the balance of
  * @return uint256 representing the amount owned by the passed address
  */
  function balanceOf(address _owner) public view returns (uint256) {
    return ownedTokens[_owner].length;
  }

  /**
  * @dev Gets the list of tokens owned by a given address
  * @param _owner address to query the tokens of
  * @return uint256[] representing the list of tokens owned by the passed address
  */
  function tokensOf(address _owner) public view returns (uint256[]) {
    return ownedTokens[_owner];
  }

  /**
  * @dev Gets the owner of the specified token ID
  * @param _tokenId uint256 ID of the token to query the owner of
  * @return owner address currently marked as the owner of the given token ID
  */
  function ownerOf(uint256 _tokenId) public view returns (address) {
    address owner = tokenOwner[_tokenId];
    require(owner != address(0));
    return owner;
  }

  /**
   * @dev Gets the approved address to take ownership of a given token ID
   * @param _tokenId uint256 ID of the token to query the approval of
   * @return address currently approved to take ownership of the given token ID
   */
  function approvedFor(uint256 _tokenId) public view returns (address) {
    return tokenApprovals[_tokenId];
  }

  /**
  * @dev Transfers the ownership of a given token ID to another address
  * @param _to address to receive the ownership of the given token ID
  * @param _tokenId uint256 ID of the token to be transferred
  */
  function transfer(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
    clearApprovalAndTransfer(msg.sender, _to, _tokenId);
  }

  /**
  * @dev Approves another address to claim for the ownership of the given token ID
  * @param _to address to be approved for the given token ID
  * @param _tokenId uint256 ID of the token to be approved
  */
  function approve(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
    address owner = ownerOf(_tokenId);
    require(_to != owner);
    if (approvedFor(_tokenId) != 0 || _to != 0) {
      tokenApprovals[_tokenId] = _to;
      Approval(owner, _to, _tokenId);
    }
  }

  /**
  * @dev Claims the ownership of a given token ID
  * @param _tokenId uint256 ID of the token being claimed by the msg.sender
  */
  function takeOwnership(uint256 _tokenId) public {
    require(isApprovedFor(msg.sender, _tokenId));
    clearApprovalAndTransfer(ownerOf(_tokenId), msg.sender, _tokenId);
  }

  /**
  * @dev Mint token function
  * @param _to The address that will own the minted token
  * @param _tokenId uint256 ID of the token to be minted by the msg.sender
  */
  function _mint(address _to, uint256 _tokenId) internal {
    require(_to != address(0));
    addToken(_to, _tokenId);
    Transfer(0x0, _to, _tokenId);
  }

  /**
  * @dev Burns a specific token
  * @param _tokenId uint256 ID of the token being burned by the msg.sender
  */
  function _burn(uint256 _tokenId) onlyOwnerOf(_tokenId) internal {
    if (approvedFor(_tokenId) != 0) {
      clearApproval(msg.sender, _tokenId);
    }
    removeToken(msg.sender, _tokenId);
    Transfer(msg.sender, 0x0, _tokenId);
  }

  /**
   * @dev Tells whether the msg.sender is approved for the given token ID or not
   * This function is not private so it can be extended in further implementations like the operatable ERC721
   * @param _owner address of the owner to query the approval of
   * @param _tokenId uint256 ID of the token to query the approval of
   * @return bool whether the msg.sender is approved for the given token ID or not
   */
  function isApprovedFor(address _owner, uint256 _tokenId) internal view returns (bool) {
    return approvedFor(_tokenId) == _owner;
  }

  /**
  * @dev Internal function to clear current approval and transfer the ownership of a given token ID
  * @param _from address which you want to send tokens from
  * @param _to address which you want to transfer the token to
  * @param _tokenId uint256 ID of the token to be transferred
  */
  function clearApprovalAndTransfer(address _from, address _to, uint256 _tokenId) internal {
    require(_to != address(0));
    require(_to != ownerOf(_tokenId));
    require(ownerOf(_tokenId) == _from);

    clearApproval(_from, _tokenId);
    removeToken(_from, _tokenId);
    addToken(_to, _tokenId);
    Transfer(_from, _to, _tokenId);
  }

  /**
  * @dev Internal function to clear current approval of a given token ID
  * @param _tokenId uint256 ID of the token to be transferred
  */
  function clearApproval(address _owner, uint256 _tokenId) private {
    require(ownerOf(_tokenId) == _owner);
    tokenApprovals[_tokenId] = 0;
    Approval(_owner, 0, _tokenId);
  }

  /**
  * @dev Internal function to add a token ID to the list of a given address
  * @param _to address representing the new owner of the given token ID
  * @param _tokenId uint256 ID of the token to be added to the tokens list of the given address
  */
  function addToken(address _to, uint256 _tokenId) private {
    require(tokenOwner[_tokenId] == address(0));
    tokenOwner[_tokenId] = _to;
    uint256 length = balanceOf(_to);
    ownedTokens[_to].push(_tokenId);
    ownedTokensIndex[_tokenId] = length;
    totalTokens = totalTokens.add(1);
  }

  /**
  * @dev Internal function to remove a token ID from the list of a given address
  * @param _from address representing the previous owner of the given token ID
  * @param _tokenId uint256 ID of the token to be removed from the tokens list of the given address
  */
  function removeToken(address _from, uint256 _tokenId) private {
    require(ownerOf(_tokenId) == _from);

    uint256 tokenIndex = ownedTokensIndex[_tokenId];
    uint256 lastTokenIndex = balanceOf(_from).sub(1);
    uint256 lastToken = ownedTokens[_from][lastTokenIndex];

    tokenOwner[_tokenId] = 0;
    ownedTokens[_from][tokenIndex] = lastToken;
    ownedTokens[_from][lastTokenIndex] = 0;
    // Note that this will handle single-element arrays. In that case, both tokenIndex and lastTokenIndex are going to
    // be zero. Then we can make sure that we will remove _tokenId from the ownedTokens list since we are first swapping
    // the lastToken to the first position, and then dropping the element placed in the last position of the list

    ownedTokens[_from].length--;
    ownedTokensIndex[_tokenId] = 0;
    ownedTokensIndex[lastToken] = tokenIndex;
    totalTokens = totalTokens.sub(1);
  }
}



/**
 * @title Ownable
 * @dev The Ownable contract has an owner address, and provides basic authorization control
 * functions, this simplifies the implementation of "user permissions".
 */
contract Ownable {
  address public owner;


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


  /**
   * @dev The Ownable constructor sets the original `owner` of the contract to the sender
   * account.
   */
  function Ownable() public {
    owner = msg.sender;
  }

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

  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param newOwner The address to transfer ownership to.
   */
  function transferOwnership(address newOwner) public onlyOwner {
    require(newOwner != address(0));
    OwnershipTransferred(owner, newOwner);
    owner = newOwner;
  }

}

/// @title ERC-721 Non-Fungible Token Standard, optional metadata extension
/// @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
///  Note: the ERC-165 identifier for this interface is 0x5b5e139f
interface ERC721Metadata /* is ERC721 */ {
  /// @notice A descriptive name for a collection of NFTs in this contract
  function name() external pure returns (string _name);

  /// @notice An abbreviated name for NFTs in this contract
  function symbol() external pure returns (string _symbol);

  /// @notice A distinct Uniform Resource Identifier (URI) for a given asset.
  /// @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC
  ///  3986. The URI may point to a JSON file that conforms to the "ERC721
  ///  Metadata JSON Schema".
  function tokenURI(uint256 _tokenId) external view returns (string);
}


contract SupeRare is ERC721Token, Ownable, ERC721Metadata {
    using SafeMath for uint256;
    
    // Percentage to owner of SupeRare. (* 10) to allow for < 1% 
    uint256 public maintainerPercentage = 30; 
    
    // Percentage to creator of artwork. (* 10) to allow for tens decimal. 
    uint256 public creatorPercentage = 100; 
    
    // Mapping from token ID to the address bidding
    mapping(uint256 => address) private tokenBidder;

    // Mapping from token ID to the current bid amount
    mapping(uint256 => uint256) private tokenCurrentBid;
    
    // Mapping from token ID to the owner sale price
    mapping(uint256 => uint256) private tokenSalePrice;

    // Mapping from token ID to the creator's address
    mapping(uint256 => address) private tokenCreator;
  
    // Mapping from token ID to the metadata uri
    mapping(uint256 => string) private tokenToURI;
    
    // Mapping from metadata uri to the token ID
    mapping(string => uint256) private uriOriginalToken;
    
    // Mapping from token ID to whether the token has been sold before.
    mapping(uint256 => bool) private tokenSold;

    // Mapping of address to boolean indicating whether the add
    mapping(address => bool) private creatorWhitelist;


    event WhitelistCreator(address indexed _creator);
    event Bid(address indexed _bidder, uint256 indexed _amount, uint256 indexed _tokenId);
    event AcceptBid(address indexed _bidder, address indexed _seller, uint256 _amount, uint256 indexed _tokenId);
    event CancelBid(address indexed _bidder, uint256 indexed _amount, uint256 indexed _tokenId);
    event Sold(address indexed _buyer, address indexed _seller, uint256 _amount, uint256 indexed _tokenId);
    event SalePriceSet(uint256 indexed _tokenId, uint256 indexed _price);

    /**
     * @dev Guarantees _uri has not been used with a token already
     * @param _uri string of the metadata uri associated with the token
     */
    modifier uniqueURI(string _uri) {
        require(uriOriginalToken[_uri] == 0);
        _;
    }

    /**
     * @dev Guarantees msg.sender is not the owner of the given token
     * @param _tokenId uint256 ID of the token to validate its ownership does not belongs to msg.sender
     */
    modifier notOwnerOf(uint256 _tokenId) {
        require(ownerOf(_tokenId) != msg.sender);
        _;
    }

    /**
     * @dev Guarantees msg.sender is a whitelisted creator of SupeRare
     */
    modifier onlyCreator() {
        require(creatorWhitelist[msg.sender] == true);
        _;
    }

    /**
     * @dev Transfers the ownership of a given token ID to another address.
     * Sets the token to be on its second sale.
     * @param _to address to receive the ownership of the given token ID
     * @param _tokenId uint256 ID of the token to be transferred
     */
    function transfer(address _to, uint256 _tokenId) public onlyOwnerOf(_tokenId) {
        tokenSold[_tokenId] = true;
        tokenSalePrice[_tokenId] = 0;
        clearApprovalAndTransfer(msg.sender, _to, _tokenId);
    }

    /**
     * @dev Adds a new unique token to the supply
     * @param _uri string metadata uri associated with the token
     */
    function addNewToken(string _uri) public uniqueURI(_uri) onlyCreator {
        uint256 newId = createToken(_uri, msg.sender);
        uriOriginalToken[_uri] = newId;
    }

    /**
     * @dev Adds a new unique token to the supply with N editions. The sale price is set for all editions
     * @param _uri string metadata uri associated with the token.
     * @param _editions uint256 number of editions to create.
     * @param _salePrice uint256 wei price of editions.
     */
    function addNewTokenWithEditions(string _uri, uint256 _editions, uint256 _salePrice) public uniqueURI(_uri) onlyCreator {
      uint256 originalId = createToken(_uri, msg.sender);
      uriOriginalToken[_uri] = originalId;

      for (uint256 i=0; i<_editions; i++){
        uint256 newId = createToken(_uri, msg.sender);
        tokenSalePrice[newId] = _salePrice;
        SalePriceSet(newId, _salePrice);
      }
    }

    /**
    * @dev Bids on the token, replacing the bid if the bid is higher than the current bid. You cannot bid on a token you already own.
    * @param _tokenId uint256 ID of the token to bid on
    */
    function bid(uint256 _tokenId) public payable notOwnerOf(_tokenId) {
        require(isGreaterBid(_tokenId));
        returnCurrentBid(_tokenId);
        tokenBidder[_tokenId] = msg.sender;
        tokenCurrentBid[_tokenId] = msg.value;
        Bid(msg.sender, msg.value, _tokenId);
    }

    /**
     * @dev Accept the bid on the token, transferring ownership to the current bidder and paying out the owner.
     * @param _tokenId uint256 ID of the token with the standing bid
     */
    function acceptBid(uint256 _tokenId) public onlyOwnerOf(_tokenId) {
        uint256 currentBid = tokenCurrentBid[_tokenId];
        address currentBidder = tokenBidder[_tokenId];
        address tokenOwner = ownerOf(_tokenId);
        address creator = tokenCreator[_tokenId];
        clearApprovalAndTransfer(msg.sender, currentBidder, _tokenId);
        payout(currentBid, owner, creator, tokenOwner, _tokenId);
        clearBid(_tokenId);
        AcceptBid(currentBidder, tokenOwner, currentBid, _tokenId);
        tokenSalePrice[_tokenId] = 0;
    }
    
    /**
     * @dev Cancels the bid on the token, returning the bid amount to the bidder.
     * @param _tokenId uint256 ID of the token with a bid
     */
    function cancelBid(uint256 _tokenId) public {
        address bidder = tokenBidder[_tokenId];
        require(msg.sender == bidder);
        uint256 bidAmount = tokenCurrentBid[_tokenId];
        msg.sender.transfer(bidAmount);
        clearBid(_tokenId);
        CancelBid(bidder, bidAmount, _tokenId);
    }
    
    /**
     * @dev Purchase the token if there is a sale price; transfers ownership to buyer and pays out owner.
     * @param _tokenId uint256 ID of the token to be purchased
     */
    function buy(uint256 _tokenId) public payable notOwnerOf(_tokenId) {
        uint256 salePrice = tokenSalePrice[_tokenId];
        uint256 sentPrice = msg.value;
        address buyer = msg.sender;
        address tokenOwner = ownerOf(_tokenId);
        address creator = tokenCreator[_tokenId];
        require(salePrice > 0);
        require(sentPrice >= salePrice);
        returnCurrentBid(_tokenId);
        clearBid(_tokenId);
        clearApprovalAndTransfer(tokenOwner, buyer, _tokenId);
        payout(sentPrice, owner, creator, tokenOwner, _tokenId);
        tokenSalePrice[_tokenId] = 0;
        Sold(buyer, tokenOwner, sentPrice, _tokenId);
    }

    /**
     * @dev Set the sale price of the token
     * @param _tokenId uint256 ID of the token with the standing bid
     */
    function setSalePrice(uint256 _tokenId, uint256 _salePrice) public onlyOwnerOf(_tokenId) {
        uint256 currentBid = tokenCurrentBid[_tokenId];
        require(_salePrice > currentBid);
        tokenSalePrice[_tokenId] = _salePrice;
        SalePriceSet(_tokenId, _salePrice);
    }

    /**
     * @dev Adds the provided address to the whitelist of creators
     * @param _creator address to be added to the whitelist
     */
    function whitelistCreator(address _creator) public onlyOwner {
      creatorWhitelist[_creator] = true;
      WhitelistCreator(_creator);
    }
    
    /**
     * @dev Set the maintainer Percentage. Needs to be 10 * target percentage
     * @param _percentage uint256 percentage * 10.
     */
    function setMaintainerPercentage(uint256 _percentage) public onlyOwner() {
       maintainerPercentage = _percentage;
    }
    
    /**
     * @dev Set the creator Percentage. Needs to be 10 * target percentage
     * @param _percentage uint256 percentage * 10.
     */
    function setCreatorPercentage(uint256 _percentage) public onlyOwner() {
       creatorPercentage = _percentage;
    }
    
    /**
     * @notice A descriptive name for a collection of NFTs in this contract
     */
    function name() external pure returns (string _name) {
        return 'SupeRare';
    }

    /**
     * @notice An abbreviated name for NFTs in this contract
     */
    function symbol() external pure returns (string _symbol) {
        return 'SUPR';
    }

    /**
     * @notice approve is not a supported function for this contract
     */
    function approve(address _to, uint256 _tokenId) public {
        revert();
    }

    /** 
     * @dev Returns whether the creator is whitelisted
     * @param _creator address to check
     * @return bool 
     */
    function isWhitelisted(address _creator) external view returns (bool) {
      return creatorWhitelist[_creator];
    }

    /** 
     * @notice A distinct Uniform Resource Identifier (URI) for a given asset.
     * @dev Throws if `_tokenId` is not a valid NFT. URIs are defined in RFC
     * 3986. The URI may point to a JSON file that conforms to the "ERC721
     * Metadata JSON Schema".
     */
    function tokenURI(uint256 _tokenId) external view returns (string) {
        ownerOf(_tokenId);
        return tokenToURI[_tokenId];
    }

    /**
    * @dev Gets the specified token ID of the uri. It only
    * returns ids of originals.
    * Throw if not connected to a token ID.
    * @param _uri string uri of metadata
    * @return uint256 token ID
    */
    function originalTokenOfUri(string _uri) public view returns (uint256) {
        uint256 tokenId = uriOriginalToken[_uri];
        ownerOf(tokenId);
        return tokenId;
    }

    /**
    * @dev Gets the current bid and bidder of the token
    * @param _tokenId uint256 ID of the token to get bid details
    * @return bid amount and bidder address of token
    */
    function currentBidDetailsOfToken(uint256 _tokenId) public view returns (uint256, address) {
        return (tokenCurrentBid[_tokenId], tokenBidder[_tokenId]);
    }

    /**
    * @dev Gets the creator of the token
    * @param _tokenId uint256 ID of the token
    * @return address of the creator
    */
    function creatorOfToken(uint256 _tokenId) public view returns (address) {
        return tokenCreator[_tokenId];
    }
    
    /**
    * @dev Gets the sale price of the token
    * @param _tokenId uint256 ID of the token
    * @return sale price of the token
    */
    function salePriceOfToken(uint256 _tokenId) public view returns (uint256) {
        return tokenSalePrice[_tokenId];
    }
    
    /**
    * @dev Internal function to return funds to current bidder.
    * @param _tokenId uint256 ID of the token with the standing bid
    */
    function returnCurrentBid(uint256 _tokenId) private {
        uint256 currentBid = tokenCurrentBid[_tokenId];
        address currentBidder = tokenBidder[_tokenId];
        if(currentBidder != address(0)) {
            currentBidder.transfer(currentBid);
        }
    }
    
    /**
    * @dev Internal function to check that the bid is larger than current bid
    * @param _tokenId uint256 ID of the token with the standing bid
    */
    function isGreaterBid(uint256 _tokenId) private view returns (bool) {
        return msg.value > tokenCurrentBid[_tokenId];
    }
    
    /**
    * @dev Internal function to clear bid
    * @param _tokenId uint256 ID of the token with the standing bid
    */
    function clearBid(uint256 _tokenId) private {
        tokenBidder[_tokenId] = address(0);
        tokenCurrentBid[_tokenId] = 0;
    }
    
    /**
    * @dev Internal function to pay the bidder, creator, and maintainer
    * @param _val uint256 value to be split
    * @param _maintainer address of account maintaining SupeRare
    * @param _creator address of the creator of token
    * @param _maintainer address of the owner of token
    */
    function payout(uint256 _val, address _maintainer, address _creator, address _tokenOwner, uint256 _tokenId) private {
        uint256 maintainerPayment;
        uint256 creatorPayment;
        uint256 ownerPayment;
        if (tokenSold[_tokenId]) {
            maintainerPayment = _val.mul(maintainerPercentage).div(1000);
            creatorPayment = _val.mul(creatorPercentage).div(1000);
            ownerPayment = _val.sub(creatorPayment).sub(maintainerPayment); 
        } else {
            maintainerPayment = 0;
            creatorPayment = _val;
            ownerPayment = 0;
            tokenSold[_tokenId] = true;
        }
        _maintainer.transfer(maintainerPayment);
        _creator.transfer(creatorPayment);
        _tokenOwner.transfer(ownerPayment);
      
    }

    /**
     * @dev Internal function creating a new token.
     * @param _uri string metadata uri associated with the token
     */
    function createToken(string _uri, address _creator) private  returns (uint256){
      uint256 newId = totalSupply() + 1;
      _mint(_creator, newId);
      tokenCreator[newId] = _creator;
      tokenToURI[newId] = _uri;
      return newId;
    }

}

Read Contract

approvedFor 0x2a6dd48f → address
balanceOf 0x70a08231 → uint256
creatorOfToken 0xd5da8d44 → address
creatorPercentage 0xf071bf4f → uint256
currentBidDetailsOfToken 0x1a289aea → uint256, address
isWhitelisted 0x3af32abf → bool
maintainerPercentage 0xf2bf6b8c → uint256
name 0x06fdde03 → string
originalTokenOfUri 0x653436fd → uint256
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
salePriceOfToken 0x9f2a3c32 → uint256
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
tokensOf 0x5a3f2672 → uint256[]
totalSupply 0x18160ddd → uint256

Write Contract 14 functions

These functions modify contract state and require a wallet transaction to execute.

acceptBid 0x2b1fd58a
uint256 _tokenId
addNewToken 0xd9856c21
string _uri
addNewTokenWithEditions 0x019871e9
string _uri
uint256 _editions
uint256 _salePrice
approve 0x095ea7b3
address _to
uint256 _tokenId
bid 0x454a2ab3
uint256 _tokenId
buy 0xd96a094a
uint256 _tokenId
cancelBid 0x9703ef35
uint256 _tokenId
setCreatorPercentage 0xc0ec93e7
uint256 _percentage
setMaintainerPercentage 0x5c68a557
uint256 _percentage
setSalePrice 0x053992c5
uint256 _tokenId
uint256 _salePrice
takeOwnership 0xb2e6ceeb
uint256 _tokenId
transfer 0xa9059cbb
address _to
uint256 _tokenId
transferOwnership 0xf2fde38b
address newOwner
whitelistCreator 0x62f11dd2
address _creator

Token Balances (1)

View Transfers →
WETH 0

Recent Transactions

No transactions found for this address