Address Contract Verified
Address
0x0b1d6565d88F9Bf6473e21c2AB58D28A495d7BB5
Balance
0 ETH
Nonce
1
Code Size
10450 bytes
Creator
0xBc915e93...C367 at tx 0xe744ee1c...2c443d
Indexed Transactions
0
Contract Bytecode
10450 bytes
0x608060405234801561001057600080fd5b50600436106101825760003560e01c8063715018a6116100d8578063aa27780f1161008c578063e985e9c511610066578063e985e9c5146102fc578063f2fde38b1461030f578063f6bf2a591461032257610182565b8063aa27780f146102b4578063b88d4fde146102d6578063c87b56dd146102e957610182565b806395d89b41116100bd57806395d89b41146102865780639e34070f1461028e578063a22cb465146102a157610182565b8063715018a6146102765780638da5cb5b1461027e57610182565b806323b872dd1161013a57806359a817ef1161011457806359a817ef1461023d5780636352211e1461025057806370a082311461026357610182565b806323b872dd1461020f5780632eb4a7ab1461022257806342842e0e1461022a57610182565b806306fdde031161016b57806306fdde03146101c5578063081812fc146101da578063095ea7b3146101fa57610182565b806301ffc9a71461018757806306661abd146101b0575b600080fd5b61019a610195366004611ad2565b610335565b6040516101a79190612134565b60405180910390f35b6101b86103af565b6040516101a7919061213f565b6101cd6103b5565b6040516101a79190612148565b6101ed6101e8366004611b3d565b610447565b6040516101a791906120ee565b61020d610208366004611aa9565b610493565b005b61020d61021d3660046119bb565b61052b565b6101b8610563565b61020d6102383660046119bb565b610587565b6101cd61024b366004611b0a565b6105a2565b6101ed61025e366004611b3d565b610647565b6101b861027136600461196f565b61067c565b61020d6106c0565b6101ed61070b565b6101cd61071a565b61019a61029c366004611b3d565b610729565b61020d6102af366004611a6f565b61076a565b6102c76102c2366004611b3d565b610780565b6040516101a7939291906126e3565b61020d6102e43660046119f6565b61082b565b6101cd6102f7366004611b3d565b61086a565b61019a61030a366004611989565b610ad2565b61020d61031d36600461196f565b610b00565b61020d610330366004611b55565b610b71565b60006001600160e01b031982167f80ac58cd00000000000000000000000000000000000000000000000000000000148061039857506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806103a757506103a782610d2d565b90505b919050565b60075481565b6060600080546103c49061279a565b80601f01602080910402602001604051908101604052809291908181526020018280546103f09061279a565b801561043d5780601f106104125761010080835404028352916020019161043d565b820191906000526020600020905b81548152906001019060200180831161042057829003601f168201915b5050505050905090565b600061045282610d5f565b6104775760405162461bcd60e51b815260040161046e906124e6565b60405180910390fd5b506000908152600460205260409020546001600160a01b031690565b600061049e82610647565b9050806001600160a01b0316836001600160a01b031614156104d25760405162461bcd60e51b815260040161046e906125c4565b806001600160a01b03166104e4610d7c565b6001600160a01b0316148061050057506105008161030a610d7c565b61051c5760405162461bcd60e51b815260040161046e9061239a565b6105268383610d80565b505050565b61053c610536610d7c565b82610dfb565b6105585760405162461bcd60e51b815260040161046e90612621565b610526838383610e80565b7f96aaea16a6b418f92ac445af7c98da897e035ea230510a187567e19895ad915781565b6105268383836040518060200160405280600081525061082b565b8051602081830181018051600982529282019190930120915280546105c69061279a565b80601f01602080910402602001604051908101604052809291908181526020018280546105f29061279a565b801561063f5780601f106106145761010080835404028352916020019161063f565b820191906000526020600020905b81548152906001019060200180831161062257829003601f168201915b505050505081565b6000818152600260205260408120546001600160a01b0316806103a75760405162461bcd60e51b815260040161046e90612454565b60006001600160a01b0382166106a45760405162461bcd60e51b815260040161046e906123f7565b506001600160a01b031660009081526003602052604090205490565b6106c8610d7c565b6001600160a01b03166106d961070b565b6001600160a01b0316146106ff5760405162461bcd60e51b815260040161046e90612532565b6107096000610fba565b565b6006546001600160a01b031690565b6060600180546103c49061279a565b60008061073861010084612724565b90506000610748610100856127f0565b60009283526008602052604090922054600190921b9182169091149392505050565b61077c610775610d7c565b8383611019565b5050565b600a60205260009081526040902080546001820180549192916107a29061279a565b80601f01602080910402602001604051908101604052809291908181526020018280546107ce9061279a565b801561081b5780601f106107f05761010080835404028352916020019161081b565b820191906000526020600020905b8154815290600101906020018083116107fe57829003601f168201915b5050505050908060020154905083565b61083c610836610d7c565b83610dfb565b6108585760405162461bcd60e51b815260040161046e90612621565b610864848484846110bc565b50505050565b60606000600a6000848152602001908152602001600020604051806060016040529081600082015481526020016001820180546108a69061279a565b80601f01602080910402602001604051908101604052809291908181526020018280546108d29061279a565b801561091f5780601f106108f45761010080835404028352916020019161091f565b820191906000526020600020905b81548152906001019060200180831161090257829003601f168201915b505050505081526020016002820154815250509050600061094382600001516110ef565b90506000826020015182610956876111b0565b60405160200161096893929190611cfe565b604051602081830303815290604052905060006009846020015184604051602001610994929190611ccf565b60408051601f19818403018152908290526109ae91611cb3565b908152602001604051809103902080546109c79061279a565b80601f01602080910402602001604051908101604052809291908181526020018280546109f39061279a565b8015610a405780601f10610a1557610100808354040283529160200191610a40565b820191906000526020600020905b815481529060010190602001808311610a2357829003601f168201915b505050505090506000610aa48383610a5b88600001516111b0565b6020808a0151604051610a7193928b9101611d95565b60408051601f1981840301815290829052610a90939291602001611ee1565b6040516020818303038152906040526112ff565b905080604051602001610ab79190612063565b60405160208183030381529060405295505050505050919050565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b610b08610d7c565b6001600160a01b0316610b1961070b565b6001600160a01b031614610b3f5760405162461bcd60e51b815260040161046e90612532565b6001600160a01b038116610b655760405162461bcd60e51b815260040161046e906121b8565b610b6e81610fba565b50565b610b7a86610729565b15610b975760405162461bcd60e51b815260040161046e90612283565b61271060075410610bba5760405162461bcd60e51b815260040161046e9061224c565b600086868686604051602001610bd394939291906120a8565b604051602081830303815290604052805190602001209050610c4b8383808060200260200160405190810160405280939291908181526020018383602002808284376000920191909152507f96aaea16a6b418f92ac445af7c98da897e035ea230510a187567e19895ad915792508591506114aa9050565b610c675760405162461bcd60e51b815260040161046e9061267e565b600160076000828254610c7a919061270c565b90915550610c899050876114c0565b610c95866007546114fe565b6040805160608101825286815260208082018781528284018b90526007546000908152600a8352939093208251815592518051929392610cdb9260018501920190611829565b50604091820151600290910155517fee563d8e532abc293fca2fdeb41c25180305bddcf9206c167dab3e155aaf171390610d1c9089908990899089906126b5565b60405180910390a150505050505050565b6001600160e01b031981167f01ffc9a70000000000000000000000000000000000000000000000000000000014919050565b6000908152600260205260409020546001600160a01b0316151590565b3390565b6000818152600460205260409020805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0384169081179091558190610dc282610647565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000610e0682610d5f565b610e225760405162461bcd60e51b815260040161046e9061234e565b6000610e2d83610647565b9050806001600160a01b0316846001600160a01b03161480610e685750836001600160a01b0316610e5d84610447565b6001600160a01b0316145b80610e785750610e788185610ad2565b949350505050565b826001600160a01b0316610e9382610647565b6001600160a01b031614610eb95760405162461bcd60e51b815260040161046e90612567565b6001600160a01b038216610edf5760405162461bcd60e51b815260040161046e906122ba565b610eea838383610526565b610ef5600082610d80565b6001600160a01b0383166000908152600360205260408120805460019290610f1e908490612757565b90915550506001600160a01b0382166000908152600360205260408120805460019290610f4c90849061270c565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b600680546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b816001600160a01b0316836001600160a01b0316141561104b5760405162461bcd60e51b815260040161046e90612317565b6001600160a01b0383811660008181526005602090815260408083209487168084529490915290819020805460ff1916851515179055517f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31906110af908590612134565b60405180910390a3505050565b6110c7848484610e80565b6110d384848484611518565b6108645760405162461bcd60e51b815260040161046e9061215b565b60606107d08210611134575060408051808201909152600481527f476f6c640000000000000000000000000000000000000000000000000000000060208201526103aa565b6103e88210611177575060408051808201909152600681527f53696c766572000000000000000000000000000000000000000000000000000060208201526103aa565b505060408051808201909152600681527f42726f6e7a650000000000000000000000000000000000000000000000000000602082015290565b6060816111f1575060408051808201909152600181527f300000000000000000000000000000000000000000000000000000000000000060208201526103aa565b8160005b811561121b5780611205816127d5565b91506112149050600a83612724565b91506111f5565b60008167ffffffffffffffff81111561124457634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f19166020018201604052801561126e576020820181803683370190505b5090505b8415610e7857611283600183612757565b9150611290600a866127f0565b61129b90603061270c565b60f81b8183815181106112be57634e487b7160e01b600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506112f8600a86612724565b9450611272565b80516060908061131f5750506040805160208101909152600081526103aa565b6000600361132e83600261270c565b6113389190612724565b611343906004612738565b9050600061135282602061270c565b67ffffffffffffffff81111561137857634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156113a2576020820181803683370190505b509050600060405180606001604052806040815260200161285d604091399050600181016020830160005b8681101561142e576003818a01810151603f601282901c8116860151600c83901c8216870151600684901c831688015192909316870151600891821b60ff94851601821b92841692909201901b91160160e01b8352600490920191016113cd565b50600386066001811461144857600281146114745761149c565b7f3d3d00000000000000000000000000000000000000000000000000000000000060011983015261149c565b7f3d000000000000000000000000000000000000000000000000000000000000006000198301525b505050918152949350505050565b6000826114b7858461164c565b14949350505050565b60006114ce61010083612724565b905060006114de610100846127f0565b6000928352600860205260409092208054600190931b9092179091555050565b61077c828260405180602001604052806000815250611704565b600061152c846001600160a01b0316611737565b1561164157836001600160a01b031663150b7a02611548610d7c565b8786866040518563ffffffff1660e01b815260040161156a9493929190612102565b602060405180830381600087803b15801561158457600080fd5b505af19250505080156115b4575060408051601f3d908101601f191682019092526115b191810190611aee565b60015b61160e573d8080156115e2576040519150601f19603f3d011682016040523d82523d6000602084013e6115e7565b606091505b5080516116065760405162461bcd60e51b815260040161046e9061215b565b805181602001fd5b6001600160e01b0319167f150b7a0200000000000000000000000000000000000000000000000000000000149050610e78565b506001949350505050565b600081815b84518110156116fc57600085828151811061167c57634e487b7160e01b600052603260045260246000fd5b602002602001015190508083116116bd5782816040516020016116a0929190611ca5565b6040516020818303038152906040528051906020012092506116e9565b80836040516020016116d0929190611ca5565b6040516020818303038152906040528051906020012092505b50806116f4816127d5565b915050611651565b509392505050565b61170e838361173d565b61171b6000848484611518565b6105265760405162461bcd60e51b815260040161046e9061215b565b3b151590565b6001600160a01b0382166117635760405162461bcd60e51b815260040161046e906124b1565b61176c81610d5f565b156117895760405162461bcd60e51b815260040161046e90612215565b61179560008383610526565b6001600160a01b03821660009081526003602052604081208054600192906117be90849061270c565b9091555050600081815260026020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b8280546118359061279a565b90600052602060002090601f016020900481019282611857576000855561189d565b82601f1061187057805160ff191683800117855561189d565b8280016001018555821561189d579182015b8281111561189d578251825591602001919060010190611882565b506118a99291506118ad565b5090565b5b808211156118a957600081556001016118ae565b600067ffffffffffffffff808411156118dd576118dd612830565b604051601f8501601f19168101602001828111828210171561190157611901612830565b60405284815291508183850186101561191957600080fd5b8484602083013760006020868301015250509392505050565b80356001600160a01b03811681146103aa57600080fd5b600082601f830112611959578081fd5b611968838335602085016118c2565b9392505050565b600060208284031215611980578081fd5b61196882611932565b6000806040838503121561199b578081fd5b6119a483611932565b91506119b260208401611932565b90509250929050565b6000806000606084860312156119cf578081fd5b6119d884611932565b92506119e660208501611932565b9150604084013590509250925092565b60008060008060808587031215611a0b578081fd5b611a1485611932565b9350611a2260208601611932565b925060408501359150606085013567ffffffffffffffff811115611a44578182fd5b8501601f81018713611a54578182fd5b611a63878235602084016118c2565b91505092959194509250565b60008060408385031215611a81578182fd5b611a8a83611932565b915060208301358015158114611a9e578182fd5b809150509250929050565b60008060408385031215611abb578182fd5b611ac483611932565b946020939093013593505050565b600060208284031215611ae3578081fd5b813561196881612846565b600060208284031215611aff578081fd5b815161196881612846565b600060208284031215611b1b578081fd5b813567ffffffffffffffff811115611b31578182fd5b610e7884828501611949565b600060208284031215611b4e578081fd5b5035919050565b60008060008060008060a08789031215611b6d578182fd5b86359550611b7d60208801611932565b945060408701359350606087013567ffffffffffffffff80821115611ba0578384fd5b611bac8a838b01611949565b94506080890135915080821115611bc1578384fd5b818901915089601f830112611bd4578384fd5b813581811115611be2578485fd5b8a60208083028501011115611bf5578485fd5b6020830194508093505050509295509295509295565b60008151808452611c2381602086016020860161276e565b601f01601f19169290920160200192915050565b60008151611c4981856020860161276e565b9290920192915050565b7f227d000000000000000000000000000000000000000000000000000000000000815260020190565b7f5d7d000000000000000000000000000000000000000000000000000000000000815260020190565b918252602082015260400190565b60008251611cc581846020870161276e565b9190910192915050565b60008351611ce181846020880161276e565b835190830190611cf581836020880161276e565b01949350505050565b60008451611d1081846020890161276e565b7f20000000000000000000000000000000000000000000000000000000000000009083019081528451611d4a81600184016020890161276e565b7f2023000000000000000000000000000000000000000000000000000000000000600192909101918201528351611d8881600384016020880161276e565b0160030195945050505050565b60007f7b2274726169745f74797065223a202273636f7265222c202276616c7565223a82527f202200000000000000000000000000000000000000000000000000000000000060208301528451611df381602285016020890161276e565b80830190507f227d2c00000000000000000000000000000000000000000000000000000000008060228301527f7b2274726169745f74797065223a20226372656174757265222c202276616c7560258301527f65223a20220000000000000000000000000000000000000000000000000000008060458401528651611e7f81604a860160208b0161276e565b604a9301928301919091527f7b2274726169745f74797065223a20226d6174657269616c222c202276616c75604d830152606d8201528351611ec881607284016020880161276e565b611ed6607282840101611c53565b979650505050505050565b60007f7b226e616d65223a20220000000000000000000000000000000000000000000082528451611f1981600a85016020890161276e565b80830190507f222c00000000000000000000000000000000000000000000000000000000000080600a8301527f226465736372697074696f6e223a20224d696e6563726166742062696f6d6520600c8301527f6d6564616c7320686174636865642066726f6d206f6e2d636861696e20747261602c8301527f6e73616374696f6e732e20416c736f20617661696c61626c65206173204d6574604c8301527f6163726166742773203230323220536561736f6e20506173732e222c00000000606c8301527f22696d616765223a22000000000000000000000000000000000000000000000060888301528551612016816091850160208a0161276e565b60919201918201527f2261747472696275746573223a205b0000000000000000000000000000000000609382015261205961205460a2830186611c37565b611c7c565b9695505050505050565b60007f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000008252825161209b81601d85016020870161276e565b91909101601d0192915050565b60008582526bffffffffffffffffffffffff198560601b16602083015283603483015282516120de81605485016020870161276e565b9190910160540195945050505050565b6001600160a01b0391909116815260200190565b60006001600160a01b038087168352808616602084015250836040830152608060608301526120596080830184611c0b565b901515815260200190565b90815260200190565b6000602082526119686020830184611c0b565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527f63656976657220696d706c656d656e7465720000000000000000000000000000606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201527f6464726573730000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526013908201527f6d617820737570706c7920697320313030303000000000000000000000000000604082015260600190565b60208082526015908201527f44726f7020616c726561647920636c61696d65642e0000000000000000000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f2061646460408201527f7265737300000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a6560408201527f726f206164647265737300000000000000000000000000000000000000000000606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201527f656e7420746f6b656e0000000000000000000000000000000000000000000000606082015260800190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b60208082526029908201527f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960408201527f73206e6f74206f776e0000000000000000000000000000000000000000000000606082015260800190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560408201527f7200000000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60408201527f776e6572206e6f7220617070726f766564000000000000000000000000000000606082015260800190565b6020808252600e908201527f496e76616c69642070726f6f662e000000000000000000000000000000000000604082015260600190565b60008582526001600160a01b0385166020830152836040830152608060608301526120596080830184611c0b565b6000848252606060208301526126fc6060830185611c0b565b9050826040830152949350505050565b6000821982111561271f5761271f612804565b500190565b6000826127335761273361281a565b500490565b600081600019048311821515161561275257612752612804565b500290565b60008282101561276957612769612804565b500390565b60005b83811015612789578181015183820152602001612771565b838111156108645750506000910152565b6002810460018216806127ae57607f821691505b602082108114156127cf57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156127e9576127e9612804565b5060010190565b6000826127ff576127ff61281a565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b6001600160e01b031981168114610b6e57600080fdfe4142434445464748494a4b4c4d4e4f505152535455565758595a6162636465666768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2fa26469706673582212209c633221e2e17e2e70cb24a02377289b98e7233666d11f48037be20b1d5c5b5864736f6c63430008000033
Verified Source Code Full Match
Compiler: v0.8.0+commit.c7dfd78e
EVM: istanbul
Optimization: Yes (1000 runs)
Library.sol 69 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
library Base64 {
bytes internal constant TABLE =
'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
/// @notice Encodes some bytes to the base64 representation
function encode(bytes memory data) internal pure returns (string memory) {
uint256 len = data.length;
if (len == 0) return '';
// multiply by 4/3 rounded up
uint256 encodedLen = 4 * ((len + 2) / 3);
// Add some extra buffer at the end
bytes memory result = new bytes(encodedLen + 32);
bytes memory table = TABLE;
assembly {
let tablePtr := add(table, 1)
let resultPtr := add(result, 32)
for {
let i := 0
} lt(i, len) {
} {
i := add(i, 3)
let input := and(mload(add(data, i)), 0xffffff)
let out := mload(add(tablePtr, and(shr(18, input), 0x3F)))
out := shl(8, out)
out := add(
out,
and(mload(add(tablePtr, and(shr(12, input), 0x3F))), 0xFF)
)
out := shl(8, out)
out := add(
out,
and(mload(add(tablePtr, and(shr(6, input), 0x3F))), 0xFF)
)
out := shl(8, out)
out := add(
out,
and(mload(add(tablePtr, and(input, 0x3F))), 0xFF)
)
out := shl(224, out)
mstore(resultPtr, out)
resultPtr := add(resultPtr, 4)
}
switch mod(len, 3)
case 1 {
mstore(sub(resultPtr, 2), shl(240, 0x3d3d))
}
case 2 {
mstore(sub(resultPtr, 1), shl(248, 0x3d))
}
mstore(result, encodedLen)
}
return string(result);
}
}
MerkleDistributor.sol 168 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;
// import "@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol";
import '@openzeppelin/contracts/token/ERC721/ERC721.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/utils/cryptography/MerkleProof.sol';
import './interfaces/IMerkleDistributor.sol';
import './Library.sol';
contract MerkleDistributor is IMerkleDistributor, ERC721, Ownable {
struct Summary {
uint256 score;
string creature;
uint256 index;
}
uint256 public count = 0; // counter of token number
bytes32 public immutable override merkleRoot;
// This is a packed array of booleans.
mapping(uint256 => uint256) private claimedBitMap;
mapping(string => string) public urlMap;
mapping(uint256 => Summary) public tokenSummary;
constructor(bytes32 merkleRoot_) public ERC721('Metacraft Season Pass 2022', 'MC2022') Ownable() {
merkleRoot = merkleRoot_;
urlMap['SlimeGold'] = 'ar://7vpBOE3GJ4kJp63W8kWTnfGvkGGxqF0qVOlTYKm_bEw';
urlMap['SlimeSilver'] = 'ar://rde367iRyDFJgn9-43UfuAKLbNv-EufF7VKfCb-uPUo';
urlMap['SlimeBronze'] = 'ar://gdP5kjV_fc8jC3UB7dunit_vyI0P0ZLWSWElsIs0o98';
urlMap['BeeGold'] = 'ar://_2PeWFSVKhwrZUvR7h38JkXmvlcB9EM6x1D9aqfFjh8';
urlMap['BeeSilver'] = 'ar://T8RAlB9mOY2CYh8LxoVP6NBPKlzl-GCkZbfpsb7lkCs';
urlMap['BeeBronze'] = 'ar://zhVYdySVzfjyQkLx0YWcXuLwxLkLJ09Q3OFVurU01eY';
urlMap['CowGold'] = 'ar://pswhfVTmMh9SB9VXunZ9NrItB3Zqz4ICz-io2cGefbI';
urlMap['CowSilver'] = 'ar://8qnOSFqMNm_Isi9b9gF4_A_uKuxOR_35r0NsS4LspJw';
urlMap['CowBronze'] = 'ar://EqM8vIUKF-sGiz-ShInXjzcmsToKPPqbyLdggMiAiJc';
urlMap['CreeperGold'] = 'ar://gThiSTBd8n3NwsLZo6dgbEWHGymE1e-7WNh_O6IsINY';
urlMap['CreeperSilver'] = 'ar://r0GvIh0Or23Qmjo3lNK9vzdm3414Ct7wGqC9u0tqjhk';
urlMap['CreeperBronze'] = 'ar://yuE5FdjAHNINqnP14ZWFlKdJ3kVQrmXFGCj_ku0nB-4';
urlMap['DolphinGold'] = 'ar://xQtK4EsopUVdleWc8Gw-8aPGH-zJ9spuyvEuhxNtYN8';
urlMap['DolphinSilver'] = 'ar://JLhjPuom7wzddo5-qgDlkLXZIuhuJTEJiy85e_kFKz8';
urlMap['DolphinBronze'] = 'ar://D3wwZckyOQ1NLVMzJ3CrXlww4fiS4qXn8HQGuP09qgg';
urlMap['EnderDragonGold'] = 'ar://C0zfXnXu3jIYe6gbJzr4MCNaLi9ndqGc_DZOKLJebpE';
urlMap['EnderDragonSilver'] = 'ar://bW_B1qid-blKGSBRvqTFFIZkV1l2obnQ5DQ8SanAacQ';
urlMap['EnderDragonBronze'] = 'ar://lrzrNtuIGa4i28hJY81uWSif-Rt_Ug4LJ3ZLCqn8G90';
urlMap['EndermanGold'] = 'ar://RVZOfVPgegqYnvCpsI4BDa69XREiZmSlsSm7H_6gU0o';
urlMap['EndermanSilver'] = 'ar://_KYzopNYjSYcsAFUEovjUYfD8dwnqlwUcoxsWDpQK7g';
urlMap['EndermanBronze'] = 'ar://71eGx6A_RvMcldnFB0nqU2UA3NgvicbJo22DOJJlLYs';
urlMap['IronGolemGold'] = 'ar://GRKyE3ZvgXjilrdQ5__1NL6RTiqW5-kTwR5kyt4jf68';
urlMap['IronGolemSilver'] = 'ar://1-_sf-2Xxi00hGxv15k7EbVChDkEp6h9bmFuQCkLsms';
urlMap['IronGolemBronze'] = 'ar://MUs64O0K72jpsq6gqShuKygzlLqOyZiZbmDIUJ0M7hg';
urlMap['TurtleGold'] = 'ar://4g2MqEi-8b-Lh2F__jtM55dxSKUZpc5IJG2VlFJd7V4';
urlMap['TurtleSilver'] = 'ar://g4H3kqjAfshjBEoIkX6Ks2ViRtL88aqyfag5Si0JD4I';
urlMap['TurtleBronze'] = 'ar://0PfeXImbImNFWv0J6nYMrnAKZjuQAvZn7HqZe2TNoZ8';
urlMap['WitherGold'] = 'ar://EMLrsR5vvB6i8mgg71A_RAH-kBA44be-jTeNFIaUmpc';
urlMap['WitherSilver'] = 'ar://PcSYjwvWQx-JoMUEIPidnwPectQjKg25lrTXI4xULrQ';
urlMap['WitherBronze'] = 'ar://_dIP9gZrnIjeQUqsF7w8dppU0qbXdQyEvIimxg4spsY';
urlMap['AxolotlGold'] = 'ar://ZVMqJEThT2vs_cYL7CMd4ijLvUqC9Koz2D6sdI1WvGc';
urlMap['AxolotlSilver'] = 'ar://EubG1GY0nYD3mpAWx69mX_30m3eZKCF6O77cS_beqMU';
urlMap['AxolotlBronze'] = 'ar://UpTJnmJpVtD2oAqcW2mM2UH8WtzLcLNQHw6SWy027hg';
urlMap['PigGold'] = 'ar://7O2OuLHESc5zjwVTCrBeu7Un9TWUAVNcYNeao3tqJmg';
urlMap['PigSilver'] = 'ar://MLfajgCbkynn2QCttTYpxrkCD0p4Ve2p0hVYPVqfeCg';
urlMap['PigBronze'] = 'ar://NJKtswIpy8tnARbpPUgai0RNehgjkFfVoVyIsiS-VwU';
}
function isClaimed(uint256 index) public view override returns (bool) {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
uint256 claimedWord = claimedBitMap[claimedWordIndex];
uint256 mask = (1 << claimedBitIndex);
return claimedWord & mask == mask;
}
function _setClaimed(uint256 index) private {
uint256 claimedWordIndex = index / 256;
uint256 claimedBitIndex = index % 256;
claimedBitMap[claimedWordIndex] = claimedBitMap[claimedWordIndex] | (1 << claimedBitIndex);
}
function claim(
uint256 index,
address account,
uint256 score,
string memory creature,
bytes32[] calldata merkleProof
) external override {
require(!isClaimed(index), 'Drop already claimed.');
require(count < 10000, 'max supply is 10000');
// Verify the merkle proof.
bytes32 node = keccak256(abi.encodePacked(index, account, score, creature));
require(MerkleProof.verify(merkleProof, merkleRoot, node), 'Invalid proof.');
// Mark it claimed and send the token.
count += 1;
_setClaimed(index);
_safeMint(account, count);
tokenSummary[count] = Summary({score: score, creature: creature, index: index});
emit Claimed(index, account, score, creature);
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
Summary memory summary = tokenSummary[tokenId];
string memory level = scoreLevel(summary.score);
string memory name = string(abi.encodePacked(summary.creature, ' ', level, ' #', toString(tokenId)));
string memory url = urlMap[string(abi.encodePacked(summary.creature, level))];
string memory json = Base64.encode(
bytes(
string(
abi.encodePacked(
'{"name": "',
name,
'",',
'"description": "Minecraft biome medals hatched from on-chain transactions. Also available as Metacraft\'s 2022 Season Pass.",',
'"image":"',
url,
'",',
'"attributes": [',
abi.encodePacked(
'{"trait_type": "score", "value": "',
toString(summary.score),
'"},',
'{"trait_type": "creature", "value": "',
summary.creature,
'"},',
'{"trait_type": "material", "value": "',
level,
'"}'
),
']}'
)
)
)
);
return string(abi.encodePacked('data:application/json;base64,', json));
}
function scoreLevel(uint256 score) internal pure returns (string memory) {
if (score >= 2000) {
return 'Gold';
}
if (score >= 1000) {
return 'Silver';
}
return 'Bronze';
}
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT license
// 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);
}
}
Address.sol 217 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library 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
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev 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
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
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;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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 Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IMerkleDistributor.sol 15 lines
// SPDX-License-Identifier: UNLICENSED
pragma solidity >=0.5.0;
// Allows anyone to claim a token if they exist in a merkle root.
interface IMerkleDistributor {
// Returns the merkle root of the merkle tree containing account balances available to claim.
function merkleRoot() external view returns (bytes32);
// Returns true if the index has been marked claimed.
function isClaimed(uint256 index) external view returns (bool);
// Claim the given amount of the token to the given address. Reverts if the inputs are invalid.
function claim(uint256 index, address account, uint256 score, string memory creatue, bytes32[] calldata merkleProof) external;
// This event is triggered whenever a call to #claim succeeds.
event Claimed(uint256 index, address account, uint256 score, string creature);
}
ERC721.sol 424 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
require(!_exists(tokenId), "ERC721: token already minted");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = 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);
}
/**
* @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 of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try 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 {
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 {}
}
IERC721.sol 143 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (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`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
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;
}
}
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);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface 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 `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
MerkleProof.sol 52 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Trees proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash;
}
}
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);
}
Read Contract
balanceOf 0x70a08231 → uint256
count 0x06661abd → uint256
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
isClaimed 0x9e34070f → bool
merkleRoot 0x2eb4a7ab → bytes32
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenSummary 0xaa27780f → uint256, string, uint256
tokenURI 0xc87b56dd → string
urlMap 0x59a817ef → string
Write Contract 8 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
claim 0xf6bf2a59
uint256 index
address account
uint256 score
string creature
bytes32[] merkleProof
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
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address