Address Contract Verified
Address
0x3ac8254BBe043EBE31ea2e6231FaD279800C6E63
Balance
0 ETH
Nonce
1
Code Size
9061 bytes
Creator
0xb8aaB114...Fb9a at tx 0x5c0a8ae2...8d492c
Indexed Transactions
0
Contract Bytecode
9061 bytes
0x608060405234801561001057600080fd5b50600436106102115760003560e01c8063715018a611610125578063a74bd013116100ad578063ca7fa9851161007c578063ca7fa985146104b2578063e2e784d5146104c5578063e985e9c5146104d8578063f2fde38b146104eb578063fd4fe8a8146104fe57600080fd5b8063a74bd01314610470578063b88d4fde14610483578063c63adb2b14610496578063c87b56dd1461049f57600080fd5b80638da5cb5b116100f45780638da5cb5b1461041957806395d89b411461042f5780639b0ceee114610437578063a22cb4651461044a578063a574cea41461045d57600080fd5b8063715018a6146103a457806374b036f2146103ac57806380c35009146103b55780638456cb591461041157600080fd5b806342842e0e116101a85780635a99e6ec116101775780635a99e6ec1461033f5780635c975abb146103525780636352211e1461035d578063703199701461037057806370a082311461038357600080fd5b806342842e0e146102f35780634d0664bd146103065780635507bb71146103195780635a6de3881461032c57600080fd5b806323b872dd116101e457806323b872dd146102935780632a55205a146102a657806335a55caa146102d85780633f4ba83a146102eb57600080fd5b806301ffc9a71461021657806306fdde031461023e578063081812fc14610253578063095ea7b31461027e575b600080fd5b610229610224366004611c61565b610511565b60405190151581526020015b60405180910390f35b61024661053c565b6040516102359190611cd5565b610266610261366004611ce8565b6105ce565b6040516001600160a01b039091168152602001610235565b61029161028c366004611d16565b6105f5565b005b6102916102a1366004611d42565b61070f565b6102b96102b4366004611d83565b610740565b604080516001600160a01b039093168352602083019190915201610235565b6102296102e6366004611ce8565b610776565b6102916107a4565b610291610301366004611d42565b6107b6565b610291610314366004611da5565b6107d1565b600a54610266906001600160a01b031681565b61029161033a366004611ce8565b610a3f565b61029161034d366004611da5565b610c1a565b60065460ff16610229565b61026661036b366004611ce8565b610d84565b600854610266906001600160a01b031681565b610396610391366004611dd9565b610de4565b604051908152602001610235565b610291610e6a565b610396600c5481565b6104006103c3366004611ce8565b60096020526000908152604090205460ff808216916101008104821691620100008204169061ffff63010000008204811691600160281b90041685565b604051610235959493929190611e40565b610291610e7c565b60065461010090046001600160a01b0316610266565b610246610e8c565b600754610266906001600160a01b031681565b610291610458366004611e86565b610e9b565b61024661046b366004611ce8565b610eaa565b61029161047e366004611dd9565b610f37565b610291610491366004611f28565b611069565b610396600b5481565b6102466104ad366004611ce8565b61109b565b6102916104c0366004611fd7565b6110e3565b6102916104d3366004611d16565b6111e6565b6102296104e6366004612000565b611214565b6102916104f9366004611dd9565b611242565b61029161050c366004611dd9565b6112bb565b60006001600160e01b0319821663152a902d60e11b14806105365750610536826112e5565b92915050565b60606000805461054b9061202e565b80601f01602080910402602001604051908101604052809291908181526020018280546105779061202e565b80156105c45780601f10610599576101008083540402835291602001916105c4565b820191906000526020600020905b8154815290600101906020018083116105a757829003601f168201915b5050505050905090565b60006105d982611335565b506000908152600460205260409020546001600160a01b031690565b600061060082610d84565b9050806001600160a01b0316836001600160a01b0316036106725760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061068e575061068e8133611214565b6107005760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608401610669565b61070a8383611394565b505050565b6107193382611402565b6107355760405162461bcd60e51b815260040161066990612068565b61070a838383611461565b600a54600b546001600160a01b03909116906000906127109061076390856120cc565b61076d91906120eb565b90509250929050565b60008060008381526009602052604090205460ff16600581111561079c5761079c611df6565b141592915050565b6107ac6115fd565b6107b461165d565b565b61070a83838360405180602001604052806000815250611069565b816107db81610776565b156107e557600080fd5b6007546040516331a9108f60e11b81526004810183905233916001600160a01b031690636352211e90602401602060405180830381865afa15801561082e573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610852919061210d565b6001600160a01b03161461086557600080fd5b60038381610872826116af565b600581111561088357610883611df6565b146108a05760405162461bcd60e51b81526004016106699061212a565b6108a8611794565b60018460088111156108bc576108bc611df6565b101580156108dc575060048460088111156108d9576108d9611df6565b11155b6109285760405162461bcd60e51b815260206004820152601760248201527f4e6f7420616e205072696d65204261636b67726f756e640000000000000000006044820152606401610669565b6040805160a081019091528060035b815260200185600881111561094e5761094e611df6565b815260200160005b815261ffff87166020808301829052604092830191909152600088815260099091522081518154829060ff1916600183600581111561099757610997611df6565b021790555060208201518154829061ff0019166101008360088111156109bf576109bf611df6565b021790555060408201518154829062ff00001916620100008360028111156109e9576109e9611df6565b02179055506060820151815460809093015166ffffffff00000019909316630100000061ffff9283160266ffff0000000000191617600160281b9190931602919091179055610a3833866117da565b5050505050565b80610a4981610776565b15610a5357600080fd5b6007546040516331a9108f60e11b81526004810183905233916001600160a01b031690636352211e90602401602060405180830381865afa158015610a9c573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610ac0919061210d565b6001600160a01b031614610ad357600080fd5b60018281610ae0826116af565b6005811115610af157610af1611df6565b14610b0e5760405162461bcd60e51b81526004016106699061212a565b610b16611794565b6040805160a081019091528060018152602001600081526020016000815261ffff86166020808301829052604092830191909152600087815260099091522081518154829060ff19166001836005811115610b7357610b73611df6565b021790555060208201518154829061ff001916610100836008811115610b9b57610b9b611df6565b021790555060408201518154829062ff0000191662010000836002811115610bc557610bc5611df6565b02179055506060820151815460809093015166ffffffff00000019909316630100000061ffff9283160266ffff0000000000191617600160281b9190931602919091179055610c1433856117da565b50505050565b81610c2481610776565b15610c2e57600080fd5b6007546040516331a9108f60e11b81526004810183905233916001600160a01b031690636352211e90602401602060405180830381865afa158015610c77573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610c9b919061210d565b6001600160a01b031614610cae57600080fd5b60048381610cbb826116af565b6005811115610ccc57610ccc611df6565b14610ce95760405162461bcd60e51b81526004016106699061212a565b610cf1611794565b6005846008811115610d0557610d05611df6565b10158015610d2557506008846008811115610d2257610d22611df6565b11155b610d715760405162461bcd60e51b815260206004820152601b60248201527f4e6f7420616e205265706c6963616e74204261636b67726f756e6400000000006044820152606401610669565b6040805160a08101909152806004610937565b6000818152600260205260408120546001600160a01b0316806105365760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610669565b60006001600160a01b038216610e4e5760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610669565b506001600160a01b031660009081526003602052604090205490565b610e726115fd565b6107b4600061191c565b610e846115fd565b6107b4611976565b60606001805461054b9061202e565b610ea63383836119b3565b5050565b6060610eb582611335565b600854600083815260096020526040908190209051637b644a0360e01b81526001600160a01b0390921691637b644a0391610ef291600401612151565b600060405180830381865afa158015610f0f573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405261053691908101906121ac565b610f3f6115fd565b610f47611794565b600c805460009182610f5883612223565b90915550610f689061c4e061223c565b6040805160a081019091529091508060058152602001600081526020016000815261ffff83166020808301919091526000604092830181905284815260099091522081518154829060ff19166001836005811115610fc857610fc8611df6565b021790555060208201518154829061ff001916610100836008811115610ff057610ff0611df6565b021790555060408201518154829062ff000019166201000083600281111561101a5761101a611df6565b02179055506060820151815460809093015166ffffffff00000019909316630100000061ffff9283160266ffff0000000000191617600160281b9190931602919091179055610ea68282611a81565b6110733383611402565b61108f5760405162461bcd60e51b815260040161066990612068565b610c1484848484611a9b565b60606110a682611335565b6008546000838152600960205260409081902090516344ec7b7b60e01b81526001600160a01b03909216916344ec7b7b91610ef291600401612151565b816110ed81610776565b156110f757600080fd5b6007546040516331a9108f60e11b81526004810183905233916001600160a01b031690636352211e90602401602060405180830381865afa158015611140573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611164919061210d565b6001600160a01b03161461117757600080fd5b60028381611184826116af565b600581111561119557611195611df6565b146111b25760405162461bcd60e51b81526004016106699061212a565b6111ba611794565b6040805160a0810190915280600281526020016000815260200185600281111561095657610956611df6565b6111ee6115fd565b600a80546001600160a01b0319166001600160a01b039390931692909217909155600b55565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b61124a6115fd565b6001600160a01b0381166112af5760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610669565b6112b88161191c565b50565b6112c36115fd565b600880546001600160a01b0319166001600160a01b0392909216919091179055565b60006001600160e01b031982166380ac58cd60e01b148061131657506001600160e01b03198216635b5e139f60e01b145b8061053657506301ffc9a760e01b6001600160e01b0319831614610536565b6000818152600260205260409020546001600160a01b03166112b85760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610669565b600081815260046020526040902080546001600160a01b0319166001600160a01b03841690811790915581906113c982610d84565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008061140e83610d84565b9050806001600160a01b0316846001600160a01b0316148061143557506114358185611214565b806114595750836001600160a01b031661144e846105ce565b6001600160a01b0316145b949350505050565b826001600160a01b031661147482610d84565b6001600160a01b0316146114d85760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610669565b6001600160a01b03821661153a5760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610669565b611545600082611394565b6001600160a01b038316600090815260036020526040812080546001929061156e90849061224f565b90915550506001600160a01b038216600090815260036020526040812080546001929061159c90849061223c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6006546001600160a01b036101009091041633146107b45760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610669565b611665611ace565b6006805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa335b6040516001600160a01b03909116815260200160405180910390a1565b600754604051635b11294560e11b81526004810183905260009182916001600160a01b039091169063b622528a90602401602060405180830381865afa1580156116fd573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117219190612262565b9050600081600181111561173757611737611df6565b0361176957606483101561174e5750600192915050565b60c88310156117605750600292915050565b50600392915050565b600181600181111561177d5761177d611df6565b0361178b5750600492915050565b50600092915050565b60065460ff16156107b45760405162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b6044820152606401610669565b6001600160a01b0382166118305760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610669565b6000818152600260205260409020546001600160a01b0316156118955760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610669565b6001600160a01b03821660009081526003602052604081208054600192906118be90849061223c565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b600680546001600160a01b03838116610100818102610100600160a81b031985161790945560405193909204169182907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b61197e611794565b6006805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a2586116923390565b816001600160a01b0316836001600160a01b031603611a145760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610669565b6001600160a01b03838116600081815260056020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b610ea6828260405180602001604052806000815250611b17565b611aa6848484611461565b611ab284848484611b4a565b610c145760405162461bcd60e51b815260040161066990612283565b60065460ff166107b45760405162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b6044820152606401610669565b611b2183836117da565b611b2e6000848484611b4a565b61070a5760405162461bcd60e51b815260040161066990612283565b60006001600160a01b0384163b15611c4057604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290611b8e9033908990889088906004016122d5565b6020604051808303816000875af1925050508015611bc9575060408051601f3d908101601f19168201909252611bc691810190612312565b60015b611c26573d808015611bf7576040519150601f19603f3d011682016040523d82523d6000602084013e611bfc565b606091505b508051600003611c1e5760405162461bcd60e51b815260040161066990612283565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611459565b506001949350505050565b6001600160e01b0319811681146112b857600080fd5b600060208284031215611c7357600080fd5b8135611c7e81611c4b565b9392505050565b60005b83811015611ca0578181015183820152602001611c88565b50506000910152565b60008151808452611cc1816020860160208601611c85565b601f01601f19169290920160200192915050565b602081526000611c7e6020830184611ca9565b600060208284031215611cfa57600080fd5b5035919050565b6001600160a01b03811681146112b857600080fd5b60008060408385031215611d2957600080fd5b8235611d3481611d01565b946020939093013593505050565b600080600060608486031215611d5757600080fd5b8335611d6281611d01565b92506020840135611d7281611d01565b929592945050506040919091013590565b60008060408385031215611d9657600080fd5b50508035926020909101359150565b60008060408385031215611db857600080fd5b82359150602083013560098110611dce57600080fd5b809150509250929050565b600060208284031215611deb57600080fd5b8135611c7e81611d01565b634e487b7160e01b600052602160045260246000fd5b60068110611e1c57611e1c611df6565b9052565b60098110611e1c57611e1c611df6565b60038110611e1c57611e1c611df6565b60a08101611e4e8288611e0c565b611e5b6020830187611e20565b611e686040830186611e30565b61ffff80851660608401528084166080840152509695505050505050565b60008060408385031215611e9957600080fd5b8235611ea481611d01565b915060208301358015158114611dce57600080fd5b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff81118282101715611ef857611ef8611eb9565b604052919050565b600067ffffffffffffffff821115611f1a57611f1a611eb9565b50601f01601f191660200190565b60008060008060808587031215611f3e57600080fd5b8435611f4981611d01565b93506020850135611f5981611d01565b925060408501359150606085013567ffffffffffffffff811115611f7c57600080fd5b8501601f81018713611f8d57600080fd5b8035611fa0611f9b82611f00565b611ecf565b818152886020838501011115611fb557600080fd5b8160208401602083013760006020838301015280935050505092959194509250565b60008060408385031215611fea57600080fd5b82359150602083013560038110611dce57600080fd5b6000806040838503121561201357600080fd5b823561201e81611d01565b91506020830135611dce81611d01565b600181811c9082168061204257607f821691505b60208210810361206257634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b634e487b7160e01b600052601160045260246000fd5b60008160001904831182151516156120e6576120e66120b6565b500290565b60008261210857634e487b7160e01b600052601260045260246000fd5b500490565b60006020828403121561211f57600080fd5b8151611c7e81611d01565b6020808252600d908201526c2bb937b7339020bb30b9ba30b960991b604082015260600190565b815460a08201906121658360ff8316611e0c565b6121786020840160ff8360081c16611e20565b61218b6040840160ff8360101c16611e30565b61ffff808260181c166060850152808260281c166080850152505092915050565b6000602082840312156121be57600080fd5b815167ffffffffffffffff8111156121d557600080fd5b8201601f810184136121e657600080fd5b80516121f4611f9b82611f00565b81815285602083850101111561220957600080fd5b61221a826020830160208601611c85565b95945050505050565b600060018201612235576122356120b6565b5060010190565b80820180821115610536576105366120b6565b81810381811115610536576105366120b6565b60006020828403121561227457600080fd5b815160028110611c7e57600080fd5b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061230890830184611ca9565b9695505050505050565b60006020828403121561232457600080fd5b8151611c7e81611c4b56fea264697066735822122021949e559192e5ac78cb0d6a29692d1ee3a2ca28085042e5f4d54d196a4361fc64736f6c63430008100033
Verified Source Code Full Match
Compiler: v0.8.16+commit.07a7930e
EVM: london
Optimization: Yes (200 runs)
IERC721.sol 6 lines
// SPDX-License-Identifier: MIT // OpenZeppelin Contracts v4.4.1 (interfaces/IERC721.sol) pragma solidity ^0.8.0; import "../token/ERC721/IERC721.sol";
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (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 IERC721Receiver {
/**
* @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 `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.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 ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @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);
}
IERC165.sol 25 lines
// 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 IERC165 {
/**
* @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);
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @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
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 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 Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(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
/// @solidity memory-safe-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
IERC2981.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (interfaces/IERC2981.sol)
pragma solidity ^0.8.0;
import "../utils/introspection/IERC165.sol";
/**
* @dev Interface for the NFT Royalty Standard.
*
* A standardized way to retrieve royalty payment information for non-fungible tokens (NFTs) to enable universal
* support for royalty payments across all NFT marketplaces and ecosystem participants.
*
* _Available since v4.5._
*/
interface IERC2981 is IERC165 {
/**
* @dev Returns how much royalty is owed and to whom, based on a sale price that may be denominated in any unit of
* exchange. The royalty amount is denominated and should be paid in that same unit of exchange.
*/
function royaltyInfo(uint256 tokenId, uint256 salePrice)
external
view
returns (address receiver, uint256 royaltyAmount);
}
ERC721.sol 454 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.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 ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings 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.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: address zero is not a valid owner");
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: invalid token ID");
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) {
_requireMinted(tokenId);
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 overridden 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 = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not token owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
_requireMinted(tokenId);
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: caller is not token 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: caller is not token 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) {
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || isApprovedForAll(owner, spender) || getApproved(tokenId) == 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);
_afterTokenTransfer(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 = ERC721.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);
_afterTokenTransfer(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(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
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);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits an {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits an {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 Reverts if the `tokenId` has not been minted yet.
*/
function _requireMinted(uint256 tokenId) internal view virtual {
require(_exists(tokenId), "ERC721: invalid token ID");
}
/**
* @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 IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
/// @solidity memory-safe-assembly
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 {}
/**
* @dev Hook that is called after any transfer of tokens. This includes
* minting and burning.
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _afterTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
Strings.sol 75 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
uint8 private constant _ADDRESS_LENGTH = 20;
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
/**
* @dev Converts an `address` with fixed length of 20 bytes to its not checksummed ASCII `string` hexadecimal representation.
*/
function toHexString(address addr) internal pure returns (string memory) {
return toHexString(uint256(uint160(addr)), _ADDRESS_LENGTH);
}
}
AvastarMemoryBanners.sol 228 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/interfaces/IERC721.sol';
import '@openzeppelin/contracts/interfaces/IERC2981.sol';
import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
import '@openzeppelin/contracts/security/Pausable.sol';
import './IMetadataRenderer.sol';
interface IAvastarsFactory is IERC721 {
enum Wave {
PRIME,
REPLICANT
}
function getAvastarWaveByTokenId(uint256 _tokenId) external view returns (Wave wave);
}
/**
* @title Avastar Memory Banner NFTs
*/
contract AvastarMemoryBanners is ERC721, IERC2981, Pausable, Ownable {
IAvastarsFactory public avastars;
IMetadataRenderer public metadataRenderer;
mapping (uint256 => IMetadataRenderer.Metadata) public tokenMetadataById;
address payable public royaltyBenefactor;
uint256 public royaltyBps; // static denominator of 10000
uint256 public secretBannerCount;
constructor(IAvastarsFactory _avastars, IMetadataRenderer _metadataRenderer) ERC721('Avastar Memory Banners', 'AMB')
{
avastars = _avastars;
metadataRenderer = _metadataRenderer;
royaltyBenefactor = payable(msg.sender);
royaltyBps = 250; // default of 2.5%
secretBannerCount = 0;
}
modifier onlyAvastarType(IMetadataRenderer.BannerType bannerType, uint256 avastarId) {
require(getAvastarType(avastarId) == bannerType, 'Wrong Avastar');
_;
}
modifier onlyClaimable( uint256 avastarId ) {
require(checkClaimed(avastarId) == false); // must be unclaimed
require(avastars.ownerOf(avastarId) == msg.sender); // must be the owner
_;
}
/**
* Return the BannerType for a given avastar ID
* @param avastarId the avastar Id
* @return bannerType the bannerType for that avastar (if any)
* @dev see {IMetadataRenderer-BannerType}.
*/
function getAvastarType(uint256 avastarId) internal view returns ( IMetadataRenderer.BannerType bannerType) {
IAvastarsFactory.Wave wave = avastars.getAvastarWaveByTokenId(avastarId);
if (wave == IAvastarsFactory.Wave.PRIME) {
if (avastarId < 100) {
return IMetadataRenderer.BannerType.FOUNDER;
} else if (avastarId < 200) {
return IMetadataRenderer.BannerType.EXCLUSIVE;
}
return IMetadataRenderer.BannerType.PRIME;
} else if (wave == IAvastarsFactory.Wave.REPLICANT) {
return IMetadataRenderer.BannerType.REPLICANT;
}
return IMetadataRenderer.BannerType.INVALID;
}
/**
* Set the contract used to render the on-chain metadata
* @param _metadataRenderer the new IMetadataRendere to use
*/
function setMetadataRenderer(IMetadataRenderer _metadataRenderer) public onlyOwner {
metadataRenderer = _metadataRenderer;
}
/**
* Set the colleciton wide royalty information
* @param _royaltyBenefactor the wallet that will receive future royalties
* @param _royaltyBps the basis points for the royalty (denominmator is 10000)
*/
function setRoyaltyInfo(address payable _royaltyBenefactor, uint256 _royaltyBps) public onlyOwner {
royaltyBenefactor = _royaltyBenefactor;
royaltyBps = _royaltyBps;
}
/**
* Mint a founders banner to the current owner of the founder avastar
* @param avastarId which avastarId the banner is associated with
* @dev only the owner of this avastar can invoke this
*/
function mintFounders(uint256 avastarId) onlyClaimable(avastarId) onlyAvastarType(IMetadataRenderer.BannerType.FOUNDER, avastarId) whenNotPaused public {
tokenMetadataById[avastarId] = IMetadataRenderer.Metadata(
IMetadataRenderer.BannerType.FOUNDER,
IMetadataRenderer.BackgroundType.INVALID,
IMetadataRenderer.AvastarImageType.INVALID,
uint16(avastarId),
uint16(avastarId)
);
_mint(msg.sender, avastarId);
}
/**
* Mint an exclusive banner to the current owner of the exclusive avastar
* @param avastarId which avastarId the banner is associated with
* @dev only the owner of this avastar can invoke this
*/
function mintExclusive(uint256 avastarId, IMetadataRenderer.AvastarImageType avastarImageChoice) onlyClaimable(avastarId) onlyAvastarType(IMetadataRenderer.BannerType.EXCLUSIVE, avastarId) whenNotPaused public {
tokenMetadataById[avastarId] = IMetadataRenderer.Metadata(
IMetadataRenderer.BannerType.EXCLUSIVE,
IMetadataRenderer.BackgroundType.INVALID,
avastarImageChoice,
uint16(avastarId),
uint16(avastarId)
);
_mint(msg.sender, avastarId);
}
/**
* Mint a prime banner to the current owner of the prime
* @param avastarId which avastarId the banner is associated with
* @param bgChoice which choice of background color the owner has made
* @dev only the owner of this avastar can invoke this
*/
function mintPrime(uint256 avastarId, IMetadataRenderer.BackgroundType bgChoice) onlyClaimable(avastarId) onlyAvastarType(IMetadataRenderer.BannerType.PRIME, avastarId) whenNotPaused public {
require(uint(bgChoice) >= uint(IMetadataRenderer.BackgroundType.P1) && uint(bgChoice) <= uint(IMetadataRenderer.BackgroundType.P4), 'Not an Prime Background');
tokenMetadataById[avastarId] = IMetadataRenderer.Metadata(
IMetadataRenderer.BannerType.PRIME,
bgChoice,
IMetadataRenderer.AvastarImageType.INVALID,
uint16(avastarId),
uint16(avastarId)
);
_mint(msg.sender, avastarId);
}
/**
* Mint a replicant banner to the current owner of the replicant
* @param avastarId which avastarId the banner is associated with
* @param bgChoice which choice of background color the owner has made
* @dev only the owner of this avastar can invoke this
*/
function mintReplicant(uint256 avastarId, IMetadataRenderer.BackgroundType bgChoice) onlyClaimable(avastarId) onlyAvastarType(IMetadataRenderer.BannerType.REPLICANT, avastarId) whenNotPaused public {
require(uint(bgChoice) >= uint(IMetadataRenderer.BackgroundType.R1) && uint(bgChoice) <= uint(IMetadataRenderer.BackgroundType.R4), 'Not an Replicant Background');
tokenMetadataById[avastarId] = IMetadataRenderer.Metadata(
IMetadataRenderer.BannerType.REPLICANT,
bgChoice,
IMetadataRenderer.AvastarImageType.INVALID,
uint16(avastarId),
uint16(avastarId)
);
_mint(msg.sender, avastarId);
}
/**
* Mint the secret banner
* @param to the lucky first owner of the secret banner
* @dev only the owner of the banner contract can invoke this
*/
function mintSecret(address to) onlyOwner whenNotPaused public {
uint secretTokenId = 50400 + secretBannerCount++;
tokenMetadataById[secretTokenId] = IMetadataRenderer.Metadata(
IMetadataRenderer.BannerType.SECRET,
IMetadataRenderer.BackgroundType.INVALID,
IMetadataRenderer.AvastarImageType.INVALID,
uint16(secretTokenId),
uint16(0)
);
_safeMint(to, secretTokenId);
}
/**
* Check to see if the given avastar ID has claimed it's banner
* @param avastarId the avastar ID to check
* @return claimed true if the avastar has already claimed a banner, false otherwise
*/
function checkClaimed(uint256 avastarId) public view returns (bool claimed) {
claimed = tokenMetadataById[avastarId].bannerType != IMetadataRenderer.BannerType.INVALID;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view override returns (string memory) {
_requireMinted(tokenId);
return metadataRenderer.renderTokenURI(tokenMetadataById[tokenId]);
}
/**
* Access the on-chain metadata IF the metadata renderer supports it
* @param tokenId the tokenId of the token whose metadata is returned
* @return metadata JSON-encoded metadata compatible with standards
*/
function getMetadata(uint256 tokenId) public view returns (string memory) {
_requireMinted(tokenId);
return metadataRenderer.renderMetadata(tokenMetadataById[tokenId]);
}
/**
* @dev See {IERC2981-royaltyInfo}
*/
function royaltyInfo(uint256, uint256 salePrice) public view returns (address receiver, uint256 royaltyAmount) {
receiver = royaltyBenefactor;
royaltyAmount = (salePrice * royaltyBps) / 10000;
}
function pause() public onlyOwner {
_pause();
}
function unpause() public onlyOwner {
_unpause();
}
/**
* indicate support for ERC2981
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165, ERC721) returns (bool) {
return interfaceId == type(IERC2981).interfaceId || super.supportsInterface(interfaceId);
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.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 Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
import "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @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`.
*
* 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;
/**
* @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 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 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 the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @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);
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
IMetadataRenderer.sol 38 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.16;
interface IMetadataRenderer {
enum BannerType {
INVALID,
FOUNDER,
EXCLUSIVE,
PRIME,
REPLICANT,
SECRET
}
enum BackgroundType {
INVALID,
P1, P2, P3, P4,
R1, R2, R3, R4
}
enum AvastarImageType {
INVALID,
PRISTINE,
STYLED
}
struct Metadata {
BannerType bannerType;
BackgroundType backgroundType;
AvastarImageType avastarImageType;
uint16 tokenId;
uint16 avastarId;
}
function renderMetadata(Metadata memory ) external view returns (string memory);
function renderTokenURI(Metadata memory ) external view returns (string memory);
}
Pausable.sol 105 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (security/Pausable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor() {
_paused = false;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_requireNotPaused();
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
_requirePaused();
_;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual returns (bool) {
return _paused;
}
/**
* @dev Throws if the contract is paused.
*/
function _requireNotPaused() internal view virtual {
require(!paused(), "Pausable: paused");
}
/**
* @dev Throws if the contract is not paused.
*/
function _requirePaused() internal view virtual {
require(paused(), "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
Read Contract
avastars 0x9b0ceee1 → address
balanceOf 0x70a08231 → uint256
checkClaimed 0x35a55caa → bool
getApproved 0x081812fc → address
getMetadata 0xa574cea4 → string
isApprovedForAll 0xe985e9c5 → bool
metadataRenderer 0x70319970 → address
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
royaltyBenefactor 0x5507bb71 → address
royaltyBps 0xc63adb2b → uint256
royaltyInfo 0x2a55205a → address, uint256
secretBannerCount 0x74b036f2 → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenMetadataById 0x80c35009 → uint8, uint8, uint8, uint16, uint16
tokenURI 0xc87b56dd → string
Write Contract 16 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
mintExclusive 0xca7fa985
uint256 avastarId
uint8 avastarImageChoice
mintFounders 0x5a6de388
uint256 avastarId
mintPrime 0x4d0664bd
uint256 avastarId
uint8 bgChoice
mintReplicant 0x5a99e6ec
uint256 avastarId
uint8 bgChoice
mintSecret 0xa74bd013
address to
pause 0x8456cb59
No parameters
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 operator
bool approved
setMetadataRenderer 0xfd4fe8a8
address _metadataRenderer
setRoyaltyInfo 0xe2e784d5
address _royaltyBenefactor
uint256 _royaltyBps
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
unpause 0x3f4ba83a
No parameters
Recent Transactions
No transactions found for this address