Address Contract Partially Verified
Address
0xb932a70A57673d89f4acfFBE830E8ed7f75Fb9e0
Balance
0 ETH
Nonce
1
Code Size
6611 bytes
Creator
0xb2D39DA3...391b at tx 0x25586336...e348e0
Indexed Transactions
0
Contract Bytecode
6611 bytes
0x6080604052600436106101745763ffffffff7c010000000000000000000000000000000000000000000000000000000060003504166301ffc9a78114610179578063040b6583146101c457806306fdde03146101e0578063081812fc1461026a578063095ea7b31461029e57806318160ddd146102c257806323b872dd146102e95780632cb2f52e146103135780632f745c59146103715780633af32abf1461039557806340c1a064146103b657806342842e0e146103ce5780634f6ccce7146103f85780636297c16c146104105780636352211e1461042857806370a0823114610440578063715018a6146104615780638ab1d681146104765780638da5cb5b146104975780638f32d59b146104ac57806395d89b41146104c1578063a22cb465146104d6578063b85ecf93146104fc578063b88d4fde14610551578063c87b56dd146105c0578063d9856c21146105d8578063e43252d714610631578063e985e9c514610652578063f2fde38b14610679575b600080fd5b34801561018557600080fd5b506101b07bffffffffffffffffffffffffffffffffffffffffffffffffffffffff196004351661069a565b604080519115158252519081900360200190f35b3480156101d057600080fd5b506101de60043515156106d2565b005b3480156101ec57600080fd5b506101f56106f8565b6040805160208082528351818301528351919283929083019185019080838360005b8381101561022f578181015183820152602001610217565b50505050905090810190601f16801561025c5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561027657600080fd5b5061028260043561078f565b60408051600160a060020a039092168252519081900360200190f35b3480156102aa57600080fd5b506101de600160a060020a03600435166024356107c1565b3480156102ce57600080fd5b506102d761086a565b60408051918252519081900360200190f35b3480156102f557600080fd5b506101de600160a060020a0360043581169060243516604435610870565b34801561031f57600080fd5b5060408051602060046024803582810135601f81018590048502860185019096528585526101de9583359536956044949193909101919081908401838280828437509497506108fe9650505050505050565b34801561037d57600080fd5b506102d7600160a060020a0360043516602435610a86565b3480156103a157600080fd5b506101b0600160a060020a0360043516610ad3565b3480156103c257600080fd5b50610282600435610b0b565b3480156103da57600080fd5b506101de600160a060020a0360043581169060243516604435610b26565b34801561040457600080fd5b506102d7600435610b47565b34801561041c57600080fd5b506101de600435610b7c565b34801561043457600080fd5b50610282600435610bf4565b34801561044c57600080fd5b506102d7600160a060020a0360043516610c1e565b34801561046d57600080fd5b506101de610c51565b34801561048257600080fd5b506101de600160a060020a0360043516610cae565b3480156104a357600080fd5b50610282610d01565b3480156104b857600080fd5b506101b0610d10565b3480156104cd57600080fd5b506101f5610d21565b3480156104e257600080fd5b506101de600160a060020a03600435166024351515610d82565b34801561050857600080fd5b50604080516020600480358082013583810280860185019096528085526101de95369593946024949385019291829185019084908082843750949750610e069650505050505050565b34801561055d57600080fd5b50604080516020601f6064356004818101359283018490048402850184019095528184526101de94600160a060020a038135811695602480359092169560443595369560849401918190840183828082843750949750610e679650505050505050565b3480156105cc57600080fd5b506101f5600435610e8f565b3480156105e457600080fd5b506040805160206004803580820135601f81018490048402850184019095528484526101de943694929360249392840191908190840183828082843750949750610f449650505050505050565b34801561063d57600080fd5b506101de600160a060020a0360043516610fd6565b34801561065e57600080fd5b506101b0600160a060020a0360043581169060243516611029565b34801561068557600080fd5b506101de600160a060020a0360043516611057565b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19811660009081526020819052604090205460ff165b919050565b6106da610d10565b15156106e557600080fd5b600e805460ff1916911515919091179055565b60098054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107845780601f1061075957610100808354040283529160200191610784565b820191906000526020600020905b81548152906001019060200180831161076757829003601f168201915b505050505090505b90565b600061079a82611076565b15156107a557600080fd5b50600090815260026020526040902054600160a060020a031690565b60006107cc82610bf4565b9050600160a060020a0383811690821614156107e757600080fd5b33600160a060020a038216148061080357506108038133611029565b151561080e57600080fd5b6000828152600260205260408082208054600160a060020a031916600160a060020a0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60075490565b61087a3382611093565b151561088557600080fd5b600160a060020a038216151561089a57600080fd5b6108a483826110f2565b6108ae8382611154565b6108b8828261125b565b8082600160a060020a031684600160a060020a03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b81600061090a82610bf4565b9050600160a060020a038116331461096c576040805160e560020a62461bcd02815260206004820152601e60248201527f6d75737420626520746865206f776e6572206f662074686520746f6b656e0000604482015290519081900360640190fd5b83600061097882610b0b565b9050600160a060020a03811633146109da576040805160e560020a62461bcd02815260206004820181905260248201527f6d757374206265207468652063726561746f72206f662074686520746f6b656e604482015290519081900360640190fd5b6109e486866112a4565b857f931f495b9a8e5d8e61946ea5d61e021f636cfe213a801f97589c18c152e408bd866040518080602001828103825283818151815260200191508051906020019080838360005b83811015610a44578181015183820152602001610a2c565b50505050905090810190601f168015610a715780820380516001836020036101000a031916815260200191505b509250505060405180910390a2505050505050565b6000610a9183610c1e565b8210610a9c57600080fd5b600160a060020a0383166000908152600560205260409020805483908110610ac057fe5b9060005260206000200154905092915050565b600e5460009060ff1615610b035750600160a060020a0381166000908152600d602052604090205460ff166106cd565b5060016106cd565b6000908152600f6020526040902054600160a060020a031690565b610b428383836020604051908101604052806000815250610e67565b505050565b6000610b5161086a565b8210610b5c57600080fd5b6007805483908110610b6a57fe5b90600052602060002001549050919050565b806000610b8882610bf4565b9050600160a060020a0381163314610bea576040805160e560020a62461bcd02815260206004820152601e60248201527f6d75737420626520746865206f776e6572206f662074686520746f6b656e0000604482015290519081900360640190fd5b610b4233846112d7565b600081815260016020526040812054600160a060020a0316801515610c1857600080fd5b92915050565b6000600160a060020a0382161515610c3557600080fd5b50600160a060020a031660009081526003602052604090205490565b610c59610d10565b1515610c6457600080fd5b600c54604051600091600160a060020a0316907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0908390a3600c8054600160a060020a0319169055565b610cb6610d10565b1515610cc157600080fd5b610cca8161131f565b604051600160a060020a038216907f1f756c8b089af6b33ee121fee8badac2553a2fa89c0575ea91ff8792617746c290600090a250565b600c54600160a060020a031690565b600c54600160a060020a0316331490565b600a8054604080516020601f60026000196101006001881615020190951694909404938401819004810282018101909252828152606093909290918301828280156107845780601f1061075957610100808354040283529160200191610784565b600160a060020a038216331415610d9857600080fd5b336000818152600460209081526040808320600160a060020a03871680855290835292819020805460ff1916861515908117909155815190815290519293927f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31929181900390910190a35050565b600080610e11610d10565b1515610e1c57600080fd5b600091505b8251821015610b42578282815181101515610e3857fe5b906020019060200201519050610e4d81610ad3565b1515610e5c57610e5c81611340565b600190910190610e21565b610e72848484610870565b610e7e84848484611364565b1515610e8957600080fd5b50505050565b6060610e9a82611076565b1515610ea557600080fd5b6000828152600b602090815260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529091830182828015610f385780601f10610f0d57610100808354040283529160200191610f38565b820191906000526020600020905b815481529060010190602001808311610f1b57829003601f168201915b50505050509050919050565b610f4d33610ad3565b1515610fc8576040805160e560020a62461bcd028152602060048201526024808201527f6d7573742062652077686974656c697374656420746f2063726561746520746f60448201527f6b656e7300000000000000000000000000000000000000000000000000000000606482015290519081900360840190fd5b610fd281336114e6565b5050565b610fde610d10565b1515610fe957600080fd5b610ff281611340565b604051600160a060020a038216907f75b2135d1c8c3519f3c09c43fe6527089ef09f40c7981ebf0ed46e79e79032c790600090a250565b600160a060020a03918216600090815260046020908152604080832093909416825291909152205460ff1690565b61105f610d10565b151561106a57600080fd5b61107381611519565b50565b600090815260016020526040902054600160a060020a0316151590565b60008061109f83610bf4565b905080600160a060020a031684600160a060020a031614806110da575083600160a060020a03166110cf8461078f565b600160a060020a0316145b806110ea57506110ea8185611029565b949350505050565b81600160a060020a031661110582610bf4565b600160a060020a03161461111857600080fd5b600081815260026020526040902054600160a060020a031615610fd25760009081526002602052604090208054600160a060020a031916905550565b6000806000611163858561158a565b600084815260066020908152604080832054600160a060020a038916845260059092529091205490935061119e90600163ffffffff61161316565b600160a060020a0386166000908152600560205260409020805491935090839081106111c657fe5b90600052602060002001549050806005600087600160a060020a0316600160a060020a031681526020019081526020016000208481548110151561120657fe5b6000918252602080832090910192909255600160a060020a038716815260059091526040902080549061123d9060001983016118ab565b50600093845260066020526040808520859055908452909220555050565b6000611267838361162a565b50600160a060020a039091166000908152600560209081526040808320805460018101825590845282842081018590559383526006909152902055565b6112ad82611076565b15156112b857600080fd5b6000828152600b602090815260409091208251610b42928401906118cf565b6112e182826116ad565b6000818152600b60205260409020546002600019610100600184161502019091160415610fd2576000818152600b60205260408120610fd29161194d565b600160a060020a03166000908152600d60205260409020805460ff19169055565b600160a060020a03166000908152600d60205260409020805460ff19166001179055565b60008061137985600160a060020a0316611769565b151561138857600191506114dd565b6040517f150b7a020000000000000000000000000000000000000000000000000000000081523360048201818152600160a060020a03898116602485015260448401889052608060648501908152875160848601528751918a169463150b7a0294938c938b938b93909160a490910190602085019080838360005b8381101561141b578181015183820152602001611403565b50505050905090810190601f1680156114485780820380516001836020036101000a031916815260200191505b5095505050505050602060405180830381600087803b15801561146a57600080fd5b505af115801561147e573d6000803e3d6000fd5b505050506040513d602081101561149457600080fd5b50517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1981167f150b7a020000000000000000000000000000000000000000000000000000000014925090505b50949350505050565b60108054600181019091556000906114fe8382611771565b61150881856112a4565b61151281846117c0565b9392505050565b600160a060020a038116151561152e57600080fd5b600c54604051600160a060020a038084169216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a3600c8054600160a060020a031916600160a060020a0392909216919091179055565b81600160a060020a031661159d82610bf4565b600160a060020a0316146115b057600080fd5b600160a060020a0382166000908152600360205260409020546115da90600163ffffffff61161316565b600160a060020a039092166000908152600360209081526040808320949094559181526001909152208054600160a060020a0319169055565b6000808383111561162357600080fd5b5050900390565b600081815260016020526040902054600160a060020a03161561164c57600080fd5b60008181526001602081815260408084208054600160a060020a031916600160a060020a038816908117909155845260039091529091205461168d916117ee565b600160a060020a0390921660009081526003602052604090209190915550565b60008060006116bc8585611800565b6000848152600860205260409020546007549093506116e290600163ffffffff61161316565b91506007828154811015156116f357fe5b906000526020600020015490508060078481548110151561171057fe5b6000918252602082200191909155600780548490811061172c57fe5b600091825260209091200155600780549061174b9060001983016118ab565b50600093845260086020526040808520859055908452909220555050565b6000903b1190565b61177b8282611850565b600780546000838152600860205260408120829055600182018355919091527fa66cc928b5edb82af9bd49922954155ab7b0942694bea4ce44661d9a8736c688015550565b6000918252600f60205260409091208054600160a060020a031916600160a060020a03909216919091179055565b60008282018381101561151257600080fd5b61180a82826110f2565b6118148282611154565b6040518190600090600160a060020a038516907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b600160a060020a038216151561186557600080fd5b61186f828261125b565b6040518190600160a060020a038416906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b815481835581811115610b4257600083815260209020610b4291810190830161198d565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061191057805160ff191683800117855561193d565b8280016001018555821561193d579182015b8281111561193d578251825591602001919060010190611922565b5061194992915061198d565b5090565b50805460018160011615610100020316600290046000825580601f106119735750611073565b601f01602090049060005260206000209081019061107391905b61078c91905b8082111561194957600081556001016119935600a165627a7a723058206ed640e2fef44710535bd8c8b3b4729dd93a83d35c51a083b80070528623b22c0029
Verified Source Code Partial Match
Compiler: v0.4.24+commit.e67f0147
EVM: byzantium
Optimization: Yes (200 runs)
SuperRareV2.sol 1137 lines
pragma solidity ^0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that revert on error
*/
library SafeMath {
/**
* @dev Multiplies two numbers, reverts on overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
/**
* @dev Integer division of two numbers truncating the quotient, reverts on division by zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity only automatically asserts 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 Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
uint256 c = a - b;
return c;
}
/**
* @dev Adds two numbers, reverts on overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
/**
* @dev Divides two numbers and returns the remainder (unsigned integer modulo),
* reverts when dividing by zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b != 0);
return a % b;
}
}
interface IERC165 {
/**
* @notice Query if a contract implements an interface
* @param interfaceId The interface identifier, as specified in ERC-165
* @dev Interface identification is specified in ERC-165. This function
* uses less than 30,000 gas.
*/
function supportsInterface(bytes4 interfaceId)
external
view
returns (bool);
}
interface ISuperRare {
/**
* @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);
/**
* @dev Returns whether the creator is whitelisted
* @param _creator address to check
* @return bool
*/
function isWhitelisted(address _creator) external view returns (bool);
/**
* @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);
/**
* @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);
/**
* @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);
}
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
contract IERC721Receiver {
/**
* @notice Handle the receipt of an NFT
* @dev The ERC721 smart contract calls this function on the recipient
* after a `safeTransfer`. This function MUST return the function selector,
* otherwise the caller will revert the transaction. The selector to be
* returned can be obtained as `this.onERC721Received.selector`. This
* function MAY throw to revert and reject the transfer.
* Note: the ERC721 contract address is always the message sender.
* @param operator The address which called `safeTransferFrom` function
* @param from The address which previously owned the token
* @param tokenId The NFT identifier which is being transferred
* @param data Additional data with no specified format
* @return `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes data
)
public
returns(bytes4);
}
contract IERC721 is IERC165 {
event Transfer(
address indexed from,
address indexed to,
uint256 indexed tokenId
);
event Approval(
address indexed owner,
address indexed approved,
uint256 indexed tokenId
);
event ApprovalForAll(
address indexed owner,
address indexed operator,
bool approved
);
function balanceOf(address owner) public view returns (uint256 balance);
function ownerOf(uint256 tokenId) public view returns (address owner);
function approve(address to, uint256 tokenId) public;
function getApproved(uint256 tokenId)
public view returns (address operator);
function setApprovalForAll(address operator, bool _approved) public;
function isApprovedForAll(address owner, address operator)
public view returns (bool);
function transferFrom(address from, address to, uint256 tokenId) public;
function safeTransferFrom(address from, address to, uint256 tokenId)
public;
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes data
)
public;
}
contract IERC721Creator is IERC721 {
/**
* @dev Gets the creator of the token
* @param _tokenId uint256 ID of the token
* @return address of the creator
*/
function tokenCreator(uint256 _tokenId) public view returns (address);
}
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract IERC721Metadata is IERC721 {
function name() external view returns (string);
function symbol() external view returns (string);
function tokenURI(uint256 tokenId) external view returns (string);
}
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract IERC721Enumerable is IERC721 {
function totalSupply() public view returns (uint256);
function tokenOfOwnerByIndex(
address owner,
uint256 index
)
public
view
returns (uint256 tokenId);
function tokenByIndex(uint256 index) public view returns (uint256);
}
/**
* Utility library of inline functions on addresses
*/
library Address {
/**
* Returns whether the target address is a contract
* @dev This function will return false if invoked during the constructor of a contract,
* as the code is not actually created until after the constructor finishes.
* @param account address of the account to check
* @return whether the target address is a contract
*/
function isContract(address account) internal view returns (bool) {
uint256 size;
// XXX Currently there is no better way to check if there is a contract in an address
// than to check the size of the code at that address.
// See https://ethereum.stackexchange.com/a/14016/36603
// for more details about how this works.
// TODO Check this again before the Serenity release, because all addresses will be
// contracts then.
// solium-disable-next-line security/no-inline-assembly
assembly { size := extcodesize(account) }
return size > 0;
}
}
/**
* @title ERC165
* @author Matt Condon (@shrugs)
* @dev Implements ERC165 using a lookup table.
*/
contract ERC165 is IERC165 {
bytes4 private constant _InterfaceId_ERC165 = 0x01ffc9a7;
/**
* 0x01ffc9a7 ===
* bytes4(keccak256('supportsInterface(bytes4)'))
*/
/**
* @dev a mapping of interface id to whether or not it's supported
*/
mapping(bytes4 => bool) private _supportedInterfaces;
/**
* @dev A contract implementing SupportsInterfaceWithLookup
* implement ERC165 itself
*/
constructor()
internal
{
_registerInterface(_InterfaceId_ERC165);
}
/**
* @dev implement supportsInterface(bytes4) using a lookup table
*/
function supportsInterface(bytes4 interfaceId)
external
view
returns (bool)
{
return _supportedInterfaces[interfaceId];
}
/**
* @dev internal method for registering an interface
*/
function _registerInterface(bytes4 interfaceId)
internal
{
require(interfaceId != 0xffffffff);
_supportedInterfaces[interfaceId] = true;
}
}
/**
* @title ERC721 Non-Fungible Token Standard basic implementation
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract ERC721 is ERC165, IERC721 {
using SafeMath for uint256;
using Address for address;
// Equals to `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
// which can be also obtained as `IERC721Receiver(0).onERC721Received.selector`
bytes4 private constant _ERC721_RECEIVED = 0x150b7a02;
// 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 number of owned token
mapping (address => uint256) private _ownedTokensCount;
// Mapping from owner to operator approvals
mapping (address => mapping (address => bool)) private _operatorApprovals;
bytes4 private constant _InterfaceId_ERC721 = 0x80ac58cd;
/*
* 0x80ac58cd ===
* bytes4(keccak256('balanceOf(address)')) ^
* bytes4(keccak256('ownerOf(uint256)')) ^
* bytes4(keccak256('approve(address,uint256)')) ^
* bytes4(keccak256('getApproved(uint256)')) ^
* bytes4(keccak256('setApprovalForAll(address,bool)')) ^
* bytes4(keccak256('isApprovedForAll(address,address)')) ^
* bytes4(keccak256('transferFrom(address,address,uint256)')) ^
* bytes4(keccak256('safeTransferFrom(address,address,uint256)')) ^
* bytes4(keccak256('safeTransferFrom(address,address,uint256,bytes)'))
*/
constructor()
public
{
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(_InterfaceId_ERC721);
}
/**
* @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) {
require(owner != address(0));
return _ownedTokensCount[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 Approves another address to transfer the given token ID
* The zero address indicates there is no approved address.
* There can only be one approved address per token at a given time.
* Can only be called by the token owner or an approved operator.
* @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 {
address owner = ownerOf(tokenId);
require(to != owner);
require(msg.sender == owner || isApprovedForAll(owner, msg.sender));
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Gets the approved address for a token ID, or zero if no address set
* Reverts if the token ID does not exist.
* @param tokenId uint256 ID of the token to query the approval of
* @return address currently approved for the given token ID
*/
function getApproved(uint256 tokenId) public view returns (address) {
require(_exists(tokenId));
return _tokenApprovals[tokenId];
}
/**
* @dev Sets or unsets the approval of a given operator
* An operator is allowed to transfer all tokens of the sender on their behalf
* @param to operator address to set the approval
* @param approved representing the status of the approval to be set
*/
function setApprovalForAll(address to, bool approved) public {
require(to != msg.sender);
_operatorApprovals[msg.sender][to] = approved;
emit ApprovalForAll(msg.sender, to, approved);
}
/**
* @dev Tells whether an operator is approved by a given owner
* @param owner owner address which you want to query the approval of
* @param operator operator address which you want to query the approval of
* @return bool whether the given operator is approved by the given owner
*/
function isApprovedForAll(
address owner,
address operator
)
public
view
returns (bool)
{
return _operatorApprovals[owner][operator];
}
/**
* @dev Transfers the ownership of a given token ID to another address
* Usage of this method is discouraged, use `safeTransferFrom` whenever possible
* Requires the msg sender to be the owner, approved, or operator
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
*/
function transferFrom(
address from,
address to,
uint256 tokenId
)
public
{
require(_isApprovedOrOwner(msg.sender, tokenId));
require(to != address(0));
_clearApproval(from, tokenId);
_removeTokenFrom(from, tokenId);
_addTokenTo(to, tokenId);
emit Transfer(from, to, tokenId);
}
/**
* @dev Safely transfers the ownership of a given token ID to another address
* If the target address is a contract, it must implement `onERC721Received`,
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
*
* Requires the msg sender to be the owner, approved, or operator
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
)
public
{
// solium-disable-next-line arg-overflow
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev Safely transfers the ownership of a given token ID to another address
* If the target address is a contract, it must implement `onERC721Received`,
* which is called upon a safe transfer, and return the magic value
* `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`; otherwise,
* the transfer is reverted.
* Requires the msg sender to be the owner, approved, or operator
* @param from current owner of the token
* @param to address to receive the ownership of the given token ID
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes data to send along with a safe transfer check
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes _data
)
public
{
transferFrom(from, to, tokenId);
// solium-disable-next-line arg-overflow
require(_checkOnERC721Received(from, to, tokenId, _data));
}
/**
* @dev Returns whether the specified token exists
* @param tokenId uint256 ID of the token to query the existence of
* @return whether the token exists
*/
function _exists(uint256 tokenId) internal view returns (bool) {
address owner = _tokenOwner[tokenId];
return owner != address(0);
}
/**
* @dev Returns whether the given spender can transfer a given token ID
* @param spender address of the spender to query
* @param tokenId uint256 ID of the token to be transferred
* @return bool whether the msg.sender is approved for the given token ID,
* is an operator of the owner, or is the owner of the token
*/
function _isApprovedOrOwner(
address spender,
uint256 tokenId
)
internal
view
returns (bool)
{
address owner = ownerOf(tokenId);
// Disable solium check because of
// https://github.com/duaraghav8/Solium/issues/175
// solium-disable-next-line operator-whitespace
return (
spender == owner ||
getApproved(tokenId) == spender ||
isApprovedForAll(owner, spender)
);
}
/**
* @dev Internal function to mint a new token
* Reverts if the given token ID already exists
* @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));
_addTokenTo(to, tokenId);
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Internal function to burn a specific token
* Reverts if the token does not exist
* @param tokenId uint256 ID of the token being burned by the msg.sender
*/
function _burn(address owner, uint256 tokenId) internal {
_clearApproval(owner, tokenId);
_removeTokenFrom(owner, tokenId);
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Internal function to add a token ID to the list of a given address
* Note that this function is left internal to make ERC721Enumerable possible, but is not
* intended to be called by custom derived contracts: in particular, it emits no Transfer event.
* @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 _addTokenTo(address to, uint256 tokenId) internal {
require(_tokenOwner[tokenId] == address(0));
_tokenOwner[tokenId] = to;
_ownedTokensCount[to] = _ownedTokensCount[to].add(1);
}
/**
* @dev Internal function to remove a token ID from the list of a given address
* Note that this function is left internal to make ERC721Enumerable possible, but is not
* intended to be called by custom derived contracts: in particular, it emits no Transfer event,
* and doesn't clear approvals.
* @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 _removeTokenFrom(address from, uint256 tokenId) internal {
require(ownerOf(tokenId) == from);
_ownedTokensCount[from] = _ownedTokensCount[from].sub(1);
_tokenOwner[tokenId] = address(0);
}
/**
* @dev Internal function to invoke `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 whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes _data
)
internal
returns (bool)
{
if (!to.isContract()) {
return true;
}
bytes4 retval = IERC721Receiver(to).onERC721Received(
msg.sender, from, tokenId, _data);
return (retval == _ERC721_RECEIVED);
}
/**
* @dev Private function to clear current approval of a given token ID
* Reverts if the given address is not indeed the owner of the token
* @param owner owner of the token
* @param tokenId uint256 ID of the token to be transferred
*/
function _clearApproval(address owner, uint256 tokenId) private {
require(ownerOf(tokenId) == owner);
if (_tokenApprovals[tokenId] != address(0)) {
_tokenApprovals[tokenId] = address(0);
}
}
}
contract ERC721Enumerable is ERC165, ERC721, IERC721Enumerable {
// 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;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
bytes4 private constant _InterfaceId_ERC721Enumerable = 0x780e9d63;
/**
* 0x780e9d63 ===
* bytes4(keccak256('totalSupply()')) ^
* bytes4(keccak256('tokenOfOwnerByIndex(address,uint256)')) ^
* bytes4(keccak256('tokenByIndex(uint256)'))
*/
/**
* @dev Constructor function
*/
constructor() public {
// register the supported interface to conform to ERC721 via ERC165
_registerInterface(_InterfaceId_ERC721Enumerable);
}
/**
* @dev Gets the token ID at a given index of the tokens list of the requested owner
* @param owner address owning the tokens list to be accessed
* @param index uint256 representing the index to be accessed of the requested tokens list
* @return uint256 token ID at the given index of the tokens list owned by the requested address
*/
function tokenOfOwnerByIndex(
address owner,
uint256 index
)
public
view
returns (uint256)
{
require(index < balanceOf(owner));
return _ownedTokens[owner][index];
}
/**
* @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 _allTokens.length;
}
/**
* @dev Gets the token ID at a given index of all the tokens in this contract
* Reverts if the index is greater or equal to the total number of tokens
* @param index uint256 representing the index to be accessed of the tokens list
* @return uint256 token ID at the given index of the tokens list
*/
function tokenByIndex(uint256 index) public view returns (uint256) {
require(index < totalSupply());
return _allTokens[index];
}
/**
* @dev Internal function to add a token ID to the list of a given address
* This function is internal due to language limitations, see the note in ERC721.sol.
* It is not intended to be called by custom derived contracts: in particular, it emits no Transfer event.
* @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 _addTokenTo(address to, uint256 tokenId) internal {
super._addTokenTo(to, tokenId);
uint256 length = _ownedTokens[to].length;
_ownedTokens[to].push(tokenId);
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Internal function to remove a token ID from the list of a given address
* This function is internal due to language limitations, see the note in ERC721.sol.
* It is not intended to be called by custom derived contracts: in particular, it emits no Transfer event,
* and doesn't clear approvals.
* @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 _removeTokenFrom(address from, uint256 tokenId) internal {
super._removeTokenFrom(from, tokenId);
// To prevent a gap in the array, we store the last token in the index of the token to delete, and
// then delete the last slot.
uint256 tokenIndex = _ownedTokensIndex[tokenId];
uint256 lastTokenIndex = _ownedTokens[from].length.sub(1);
uint256 lastToken = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastToken;
// This also deletes the contents at the last position of the array
_ownedTokens[from].length--;
// 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
_ownedTokensIndex[tokenId] = 0;
_ownedTokensIndex[lastToken] = tokenIndex;
}
/**
* @dev Internal function to mint a new token
* Reverts if the given token ID already exists
* @param to address the beneficiary 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 {
super._mint(to, tokenId);
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Internal function to burn a specific token
* Reverts if the token does not exist
* @param owner owner of the token to burn
* @param tokenId uint256 ID of the token being burned by the msg.sender
*/
function _burn(address owner, uint256 tokenId) internal {
super._burn(owner, tokenId);
// Reorg all tokens array
uint256 tokenIndex = _allTokensIndex[tokenId];
uint256 lastTokenIndex = _allTokens.length.sub(1);
uint256 lastToken = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastToken;
_allTokens[lastTokenIndex] = 0;
_allTokens.length--;
_allTokensIndex[tokenId] = 0;
_allTokensIndex[lastToken] = tokenIndex;
}
}
contract ERC721Metadata is ERC165, ERC721, IERC721Metadata {
// Token name
string private _name;
// Token symbol
string private _symbol;
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;
bytes4 private constant InterfaceId_ERC721Metadata = 0x5b5e139f;
/**
* 0x5b5e139f ===
* bytes4(keccak256('name()')) ^
* bytes4(keccak256('symbol()')) ^
* bytes4(keccak256('tokenURI(uint256)'))
*/
/**
* @dev Constructor function
*/
constructor(string name, string symbol) public {
_name = name;
_symbol = symbol;
// register the supported interfaces to conform to ERC721 via ERC165
_registerInterface(InterfaceId_ERC721Metadata);
}
/**
* @dev Gets the token name
* @return string representing the token name
*/
function name() external view returns (string) {
return _name;
}
/**
* @dev Gets the token symbol
* @return string representing the token symbol
*/
function symbol() external view returns (string) {
return _symbol;
}
/**
* @dev Returns an URI for a given token ID
* Throws if the token ID does not exist. May return an empty string.
* @param tokenId uint256 ID of the token to query
*/
function tokenURI(uint256 tokenId) external view returns (string) {
require(_exists(tokenId));
return _tokenURIs[tokenId];
}
/**
* @dev Internal function to set the token URI for a given token
* Reverts if the token ID does not exist
* @param tokenId uint256 ID of the token to set its URI
* @param uri string URI to assign
*/
function _setTokenURI(uint256 tokenId, string uri) internal {
require(_exists(tokenId));
_tokenURIs[tokenId] = uri;
}
/**
* @dev Internal function to burn a specific token
* Reverts if the token does not exist
* @param owner owner of the token to burn
* @param tokenId uint256 ID of the token being burned by the msg.sender
*/
function _burn(address owner, uint256 tokenId) internal {
super._burn(owner, tokenId);
// Clear metadata (if any)
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
}
}
/**
* @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 private _owner;
event OwnershipTransferred(
address indexed previousOwner,
address indexed newOwner
);
/**
* @dev The Ownable constructor sets the original `owner` of the contract to the sender
* account.
*/
constructor() internal {
_owner = msg.sender;
emit OwnershipTransferred(address(0), _owner);
}
/**
* @return the address of the owner.
*/
function owner() public view returns(address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(isOwner());
_;
}
/**
* @return true if `msg.sender` is the owner of the contract.
*/
function isOwner() public view returns(bool) {
return msg.sender == _owner;
}
/**
* @dev Allows the current owner to relinquish control of the contract.
* @notice Renouncing to ownership will leave the contract without an owner.
* It will not be possible to call the functions with the `onlyOwner`
* modifier anymore.
*/
function renounceOwnership() public onlyOwner {
emit OwnershipTransferred(_owner, address(0));
_owner = address(0);
}
/**
* @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 {
_transferOwnership(newOwner);
}
/**
* @dev Transfers control of the contract to a newOwner.
* @param newOwner The address to transfer ownership to.
*/
function _transferOwnership(address newOwner) internal {
require(newOwner != address(0));
emit OwnershipTransferred(_owner, newOwner);
_owner = newOwner;
}
}
contract Whitelist is Ownable {
// Mapping of address to boolean indicating whether the address is whitelisted
mapping(address => bool) private whitelistMap;
// flag controlling whether whitelist is enabled.
bool private whitelistEnabled = true;
event AddToWhitelist(address indexed _newAddress);
event RemoveFromWhitelist(address indexed _removedAddress);
/**
* @dev Enable or disable the whitelist
* @param _enabled bool of whether to enable the whitelist.
*/
function enableWhitelist(bool _enabled) public onlyOwner {
whitelistEnabled = _enabled;
}
/**
* @dev Adds the provided address to the whitelist
* @param _newAddress address to be added to the whitelist
*/
function addToWhitelist(address _newAddress) public onlyOwner {
_whitelist(_newAddress);
emit AddToWhitelist(_newAddress);
}
/**
* @dev Removes the provided address to the whitelist
* @param _removedAddress address to be removed from the whitelist
*/
function removeFromWhitelist(address _removedAddress) public onlyOwner {
_unWhitelist(_removedAddress);
emit RemoveFromWhitelist(_removedAddress);
}
/**
* @dev Returns whether the address is whitelisted
* @param _address address to check
* @return bool
*/
function isWhitelisted(address _address) public view returns (bool) {
if (whitelistEnabled) {
return whitelistMap[_address];
} else {
return true;
}
}
/**
* @dev Internal function for removing an address from the whitelist
* @param _removedAddress address to unwhitelisted
*/
function _unWhitelist(address _removedAddress) internal {
whitelistMap[_removedAddress] = false;
}
/**
* @dev Internal function for adding the provided address to the whitelist
* @param _newAddress address to be added to the whitelist
*/
function _whitelist(address _newAddress) internal {
whitelistMap[_newAddress] = true;
}
}
/**
* @title Full ERC721 Token
* This implementation includes all the required and some optional functionality of the ERC721 standard
* Moreover, it includes approve all functionality using operator terminology
* @dev see https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
*/
contract ERC721Full is ERC721, ERC721Enumerable, ERC721Metadata {
constructor(string name, string symbol) ERC721Metadata(name, symbol)
public
{
}
}
contract SuperRareV2 is ERC721Full, IERC721Creator, Ownable, Whitelist {
using SafeMath for uint256;
// Mapping from token ID to the creator's address.
mapping(uint256 => address) private tokenCreators;
// Counter for creating token IDs
uint256 private idCounter;
// Old SuperRare contract to look up token details.
ISuperRare private oldSuperRare;
// Event indicating metadata was updated.
event TokenURIUpdated(uint256 indexed _tokenId, string _uri);
constructor(
string _name,
string _symbol,
address _oldSuperRare
)
ERC721Full(_name, _symbol)
{
// Get reference to old SR contract.
oldSuperRare = ISuperRare(_oldSuperRare);
uint256 oldSupply = oldSuperRare.totalSupply();
// Set id counter to be continuous with SuperRare.
idCounter = oldSupply + 1;
}
/**
* @dev Whitelists a bunch of addresses.
* @param _whitelistees address[] of addresses to whitelist.
*/
function initWhitelist(address[] _whitelistees) public onlyOwner {
// Add all whitelistees.
for (uint256 i = 0; i < _whitelistees.length; i++) {
address creator = _whitelistees[i];
if (!isWhitelisted(creator)) {
_whitelist(creator);
}
}
}
/**
* @dev Checks that the token is owned by the sender.
* @param _tokenId uint256 ID of the token.
*/
modifier onlyTokenOwner(uint256 _tokenId) {
address owner = ownerOf(_tokenId);
require(owner == msg.sender, "must be the owner of the token");
_;
}
/**
* @dev Checks that the token was created by the sender.
* @param _tokenId uint256 ID of the token.
*/
modifier onlyTokenCreator(uint256 _tokenId) {
address creator = tokenCreator(_tokenId);
require(creator == msg.sender, "must be the creator of the token");
_;
}
/**
* @dev Adds a new unique token to the supply.
* @param _uri string metadata uri associated with the token.
*/
function addNewToken(string _uri) public {
require(isWhitelisted(msg.sender), "must be whitelisted to create tokens");
_createToken(_uri, msg.sender);
}
/**
* @dev Deletes the token with the provided ID.
* @param _tokenId uint256 ID of the token.
*/
function deleteToken(uint256 _tokenId) public onlyTokenOwner(_tokenId) {
_burn(msg.sender, _tokenId);
}
/**
* @dev Updates the token metadata if the owner is also the
* creator.
* @param _tokenId uint256 ID of the token.
* @param _uri string metadata URI.
*/
function updateTokenMetadata(uint256 _tokenId, string _uri)
public
onlyTokenOwner(_tokenId)
onlyTokenCreator(_tokenId)
{
_setTokenURI(_tokenId, _uri);
emit TokenURIUpdated(_tokenId, _uri);
}
/**
* @dev Gets the creator of the token.
* @param _tokenId uint256 ID of the token.
* @return address of the creator.
*/
function tokenCreator(uint256 _tokenId) public view returns (address) {
return tokenCreators[_tokenId];
}
/**
* @dev Internal function for setting the token's creator.
* @param _tokenId uint256 id of the token.
* @param _creator address of the creator of the token.
*/
function _setTokenCreator(uint256 _tokenId, address _creator) internal {
tokenCreators[_tokenId] = _creator;
}
/**
* @dev Internal function creating a new token.
* @param _uri string metadata uri associated with the token
* @param _creator address of the creator of the token.
*/
function _createToken(string _uri, address _creator) internal returns (uint256) {
uint256 newId = idCounter;
idCounter++;
_mint(_creator, newId);
_setTokenURI(newId, _uri);
_setTokenCreator(newId, _creator);
return newId;
}
}
Read Contract
balanceOf 0x70a08231 → uint256
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
isOwner 0x8f32d59b → bool
isWhitelisted 0x3af32abf → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenCreator 0x40c1a064 → address
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
Write Contract 14 functions
These functions modify contract state and require a wallet transaction to execute.
addNewToken 0xd9856c21
string _uri
addToWhitelist 0xe43252d7
address _newAddress
approve 0x095ea7b3
address to
uint256 tokenId
deleteToken 0x6297c16c
uint256 _tokenId
enableWhitelist 0x040b6583
bool _enabled
initWhitelist 0xb85ecf93
address[] _whitelistees
removeFromWhitelist 0x8ab1d681
address _removedAddress
renounceOwnership 0x715018a6
No parameters
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address to
bool approved
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
updateTokenMetadata 0x2cb2f52e
uint256 _tokenId
string _uri
Token Balances (1)
View Transfers →Recent Transactions
No transactions found for this address