Address Contract Verified
Address
0x78A3B30f90f9a39272C1CB3e558fcD1CBe5Fb791
Balance
0 ETH
Nonce
1
Code Size
14142 bytes
Creator
0xcF297b45...94b5 at tx 0xa286df4a...fa920e
Indexed Transactions
0
Contract Bytecode
14142 bytes
0x608060405234801561001057600080fd5b50600436106101fb5760003560e01c80635c975abb1161011a578063a22cb465116100ad578063c87d2cd71161007c578063c87d2cd714610430578063e19e55de14610457578063e985e9c51461046a578063f2c05b2e146104a6578063f38c363f146104b957600080fd5b8063a22cb465146103ee578063a9f52e7b14610401578063b88d4fde1461040a578063c87b56dd1461041d57600080fd5b806379502c55116100e957806379502c55146103a457806385668a21146103b757806395d89b41146103de5780639abc8320146103e657600080fd5b80635c975abb146103595780636352211e1461036b5780636ba7afc71461037e57806370a082311461039157600080fd5b80632f745c591161019257806347ce80d31161016157806347ce80d31461030d5780634f6ccce71461032057806355f804b3146103335780635c6d8da11461034657600080fd5b80632f745c59146102c157806336fe0da6146102d457806342842e0e146102e757806342966c68146102fa57600080fd5b80631249c58b116101ce5780631249c58b1461027d57806316c38b3c1461029357806318160ddd146102a657806323b872dd146102ae57600080fd5b806301ffc9a71461020057806306fdde0314610228578063081812fc1461023d578063095ea7b314610268575b600080fd5b61021361020e366004612ca3565b6104cc565b60405190151581526020015b60405180910390f35b6102306104f7565b60405161021f9190612d18565b61025061024b366004612d2b565b610589565b6040516001600160a01b03909116815260200161021f565b61027b610276366004612d59565b6105b0565b005b6102856106cb565b60405190815260200161021f565b61027b6102a1366004612d93565b6107e3565b609c54610285565b61027b6102bc366004612db0565b6108b9565b6102856102cf366004612d59565b6108eb565b61027b6102e2366004612d2b565b610981565b61027b6102f5366004612db0565b610a84565b61027b610308366004612d2b565b610a9f565b61021361031b366004612ea4565b610c80565b61028561032e366004612d2b565b610e85565b61027b610341366004612fd6565b610f18565b61027b61035436600461300a565b61102c565b600054600160a01b900460ff16610213565b610250610379366004612d2b565b61114f565b61021361038c366004612ea4565b6111af565b61028561039f3660046130a4565b611486565b600054610250906001600160a01b031681565b6102857fec13d6d12b88433319b64e1065a96ea19cd330ef6603f5f6fb685dde3959a32081565b61023061150c565b61023061151b565b61027b6103fc3660046130c1565b6115a9565b61028560cd5481565b61027b6104183660046130fa565b6115b8565b61023061042b366004612d2b565b6115f0565b6102857f421683f821a0574472445355be6d2b769119e8515f8376a1d7878523dfdecf7b81565b610213610465366004613165565b61162a565b61021361047836600461322b565b6001600160a01b039182166000908152606d6020908152604080832093909416825291909152205460ff1690565b6102856104b43660046130a4565b6117fc565b6102506104c7366004613259565b6119cc565b60006001600160e01b0319821663780e9d6360e01b14806104f157506104f182611a4e565b92915050565b6060606880546105069061329f565b80601f01602080910402602001604051908101604052809291908181526020018280546105329061329f565b801561057f5780601f106105545761010080835404028352916020019161057f565b820191906000526020600020905b81548152906001019060200180831161056257829003601f168201915b5050505050905090565b600061059482611a9e565b506000908152606c60205260409020546001600160a01b031690565b60006105bb8261114f565b9050806001600160a01b0316836001600160a01b0316141561062e5760405162461bcd60e51b815260206004820152602160248201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656044820152603960f91b60648201526084015b60405180910390fd5b336001600160a01b038216148061064a575061064a8133610478565b6106bc5760405162461bcd60e51b815260206004820152603e60248201527f4552433732313a20617070726f76652063616c6c6572206973206e6f7420746f60448201527f6b656e206f776e6572206e6f7220617070726f76656420666f7220616c6c00006064820152608401610625565b6106c68383611afd565b505050565b6000600260015414156106f05760405162461bcd60e51b8152600401610625906132da565b6002600155600054604051632474521560e21b81527fd9d808b7856857a3760215b224352383987bacfc5008c9dca860116bcc2c8f0c60048201523360248201526001600160a01b03909116906391d148549060440160206040518083038186803b15801561075e57600080fd5b505afa158015610772573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107969190613311565b6107b25760405162461bcd60e51b81526004016106259061332e565b60006107bc611b6b565b90506107cc60cc80546001019055565b60cc5491506107db8183611c01565b506001805590565b600054604051632474521560e21b81527fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177560048201523360248201526001600160a01b03909116906391d148549060440160206040518083038186803b15801561084c57600080fd5b505afa158015610860573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108849190613311565b6108a05760405162461bcd60e51b815260040161062590613372565b80156108b1576108ae611c1b565b50565b6108ae611cae565b6108c4335b82611d38565b6108e05760405162461bcd60e51b8152600401610625906133b5565b6106c6838383611db7565b60006108f683611486565b82106109585760405162461bcd60e51b815260206004820152602b60248201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560448201526a74206f6620626f756e647360a81b6064820152608401610625565b506001600160a01b03919091166000908152609a60209081526040808320938352929052205490565b600054604051632474521560e21b81527fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177560048201523360248201526001600160a01b03909116906391d148549060440160206040518083038186803b1580156109ea57600080fd5b505afa1580156109fe573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610a229190613311565b610a3e5760405162461bcd60e51b815260040161062590613372565b60cd819055807fa5950b03b3e84483f8afdd0ad20d492dc6f151135571ec72a9dcea83bc4aa805336040516001600160a01b03909116815260200160405180910390a250565b6106c6838383604051806020016040528060008152506115b8565b60008054604051637290585560e01b81527f75194dd2030e024bec7157fbb11d88254cd93866bea6f28460cb1a3f4ece16a8600482015282916001600160a01b03169063729058559060240160006040518083038186803b158015610b0357600080fd5b505afa158015610b17573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052610b3f9190810190613403565b90925090507fec13d6d12b88433319b64e1065a96ea19cd330ef6603f5f6fb685dde3959a3208214610ba95760405162461bcd60e51b8152602060048201526013602482015272115490cc8c0e881ddc9bdb99c81d1e5c195251606a1b6044820152606401610625565b80806020019051810190610bbd9190613485565b600114610c175760405162461bcd60e51b815260206004820152602260248201527f45524332303a206e6f7420616c6c6f77656420746f2073656c662d6275726e696044820152616e6760f01b6064820152608401610625565b33610c218461114f565b6001600160a01b031614610c775760405162461bcd60e51b815260206004820152601960248201527f534e3131363a20796f7520646f206e6f742068617665206974000000000000006044820152606401610625565b6106c683611f5e565b600060026001541415610ca55760405162461bcd60e51b8152600401610625906132da565b6002600155600054604051632474521560e21b81527fd9d808b7856857a3760215b224352383987bacfc5008c9dca860116bcc2c8f0c60048201523360248201526001600160a01b03909116906391d148549060440160206040518083038186803b158015610d1357600080fd5b505afa158015610d27573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610d4b9190613311565b610d675760405162461bcd60e51b81526004016106259061332e565b6000825111610db45760405162461bcd60e51b8152602060048201526019602482015278534e3131303a20696e76616c696420706172616d657465727360381b6044820152606401610625565b6000610dbe611b6b565b905060005b8351811015610e78576000848281518110610de057610de061349e565b6020026020010151600001519050848281518110610e0057610e0061349e565b602002602001015160200151600114610e5b5760405162461bcd60e51b815260206004820181905260248201527f534e3131313a20616d6f756e74206d75737420626520657175616c20746f20316044820152606401610625565b610e658382611c01565b5080610e70816134ca565b915050610dc3565b5060018080559392505050565b6000610e90609c5490565b8210610ef35760405162461bcd60e51b815260206004820152602c60248201527f455243373231456e756d657261626c653a20676c6f62616c20696e646578206f60448201526b7574206f6620626f756e647360a01b6064820152608401610625565b609c8281548110610f0657610f0661349e565b90600052602060002001549050919050565b600054604051632474521560e21b81527fa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c2177560048201523360248201526001600160a01b03909116906391d148549060440160206040518083038186803b158015610f8157600080fd5b505afa158015610f95573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610fb99190613311565b610fd55760405162461bcd60e51b815260040161062590613372565b8051610fe8906002906020840190612bf4565b5080604051610ff791906134e5565b6040519081900381209033907fe7e6d2e694e925d1996aaef24328f8c8b026ccc5dd0a1c2397509d5d31de8cbb90600090a350565b600354610100900460ff161580801561104c5750600354600160ff909116105b806110665750303b158015611066575060035460ff166001145b6110c95760405162461bcd60e51b815260206004820152602e60248201527f496e697469616c697a61626c653a20636f6e747261637420697320616c72656160448201526d191e481a5b9a5d1a585b1a5e995960921b6064820152608401610625565b6003805460ff1916600117905580156110ec576003805461ff0019166101001790555b6110f885858585612005565b6111028585612022565b8015611148576003805461ff0019169055604051600181527f7f26b83ff96e1f2b6a682f133852f6798a09c465da95921460cefb38474024989060200160405180910390a15b5050505050565b6000818152606a60205260408120546001600160a01b0316806104f15760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610625565b6000600260015414156111d45760405162461bcd60e51b8152600401610625906132da565b6002600155600054604051632474521560e21b81527fe83fe28a8b39dca556b6801067344bab81e98ce23ce9aff4628a4103b6b6bb2d60048201523360248201526001600160a01b03909116906391d148549060440160206040518083038186803b15801561124257600080fd5b505afa158015611256573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061127a9190613311565b6112d25760405162461bcd60e51b8152602060048201526024808201527f534e3130343a2063616c6c6572206973206e6f7420746865206275726e657220604482015263726f6c6560e01b6064820152608401610625565b600082511161131f5760405162461bcd60e51b8152602060048201526019602482015278534e3131303a20696e76616c696420706172616d657465727360381b6044820152606401610625565b6000611329611b6b565b905060005b8351811015610e7857600084828151811061134b5761134b61349e565b602002602001015160000151905084828151811061136b5761136b61349e565b6020026020010151602001516001146113c65760405162461bcd60e51b815260206004820181905260248201527f534e3131313a20616d6f756e74206d75737420626520657175616c20746f20316044820152606401610625565b6113cf336108be565b6114315760405162461bcd60e51b815260206004820152602d60248201527f534e3131323a2063616c6c6572206973206e6f7420746f6b656e206f776e657260448201526c081b9bdc88185c1c1c9bdd9959609a1b6064820152608401610625565b826001600160a01b03166114448261114f565b6001600160a01b03161461146a5760405162461bcd60e51b815260040161062590613501565b61147381611f5e565b508061147e816134ca565b91505061132e565b60006001600160a01b0382166114f05760405162461bcd60e51b815260206004820152602960248201527f4552433732313a2061646472657373207a65726f206973206e6f7420612076616044820152683634b21037bbb732b960b91b6064820152608401610625565b506001600160a01b03166000908152606b602052604090205490565b6060606980546105069061329f565b600280546115289061329f565b80601f01602080910402602001604051908101604052809291908181526020018280546115549061329f565b80156115a15780601f10611576576101008083540402835291602001916115a1565b820191906000526020600020905b81548152906001019060200180831161158457829003601f168201915b505050505081565b6115b4338383612053565b5050565b6115c23383611d38565b6115de5760405162461bcd60e51b8152600401610625906133b5565b6115ea84848484612122565b50505050565b60606115fa612155565b61160383612164565b604051602001611614929190613542565b6040516020818303038152906040529050919050565b60006002600154141561164f5760405162461bcd60e51b8152600401610625906132da565b6002600155600054604051632474521560e21b81527fdc24745d8f4fef6bd3d099210f61e8dbf7dc40d6062869098e8607ba57770b1560048201523360248201526001600160a01b03909116906391d148549060440160206040518083038186803b1580156116bd57600080fd5b505afa1580156116d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906116f59190613311565b6117525760405162461bcd60e51b815260206004820152602860248201527f534e3130353a2063616c6c6572206973206e6f7420746865207472616e73666560448201526772657220726f6c6560c01b6064820152608401610625565b3360005b8351811015610e785760008482815181106117735761177361349e565b602002602001015160000151905060008583815181106117955761179561349e565b6020026020010151602001519050836001600160a01b03166117b68261114f565b6001600160a01b0316146117dc5760405162461bcd60e51b815260040161062590613501565b6117e7848383610a84565b505080806117f4906134ca565b915050611756565b60008054604051632474521560e21b81527f0767cc7d475698a20da8b9c9ab30101036be6749f2bf86a72d06268a5b3f1e5a60048201523360248201526001600160a01b03909116906391d148549060440160206040518083038186803b15801561186657600080fd5b505afa15801561187a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061189e9190613311565b6118f95760405162461bcd60e51b815260206004820152602660248201527f534e3130333a2063616c6c6572206973206e6f742074686520667265656d696e6044820152657420726f6c6560d01b6064820152608401610625565b61190760cc80546001019055565b5060cc5460cd548111156119755760405162461bcd60e51b815260206004820152602f60248201527f4552433732313a206578636565646564207570706572206c696d6974206f662060448201526e746f6b656e4964206d696e74696e6760881b6064820152608401610625565b61197f8282611c01565b806001600160a01b0383167f6a5c2355a1d2998cebb149bde380fefe8067022b42cb9fad162478e57a6dbfcc336040516001600160a01b03909116815260200160405180910390a3919050565b60007f421683f821a0574472445355be6d2b769119e8515f8376a1d7878523dfdecf7b8314611a335760405162461bcd60e51b815260206004820152601360248201527214d38c4c0c4e881ddc9bdb99c81d1e5c195251606a1b6044820152606401610625565b81806020019051810190611a479190613571565b9392505050565b60006001600160e01b031982166380ac58cd60e01b1480611a7f57506001600160e01b03198216635b5e139f60e01b145b806104f157506301ffc9a760e01b6001600160e01b03198316146104f1565b6000818152606a60205260409020546001600160a01b03166108ae5760405162461bcd60e51b8152602060048201526018602482015277115490cdcc8c4e881a5b9d985b1a59081d1bdad95b88125160421b6044820152606401610625565b6000818152606c6020526040902080546001600160a01b0319166001600160a01b0384169081179091558190611b328261114f565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60007fc33c8716707b901a5897f5b0eb3bfd4928388fae53a418d46ab0875723c1dcd581611b9882612261565b90506001600160a01b0381166104f15760405162461bcd60e51b815260206004820152602860248201527f534e3130303a20706c6174666f726d20617373657420636f6e7472616374206e6044820152671bdd08199bdd5b9960c21b6064820152608401610625565b6115b48282604051806020016040528060008152506122f4565b600054600160a01b900460ff1615611c655760405162461bcd60e51b815260206004820152600d60248201526c14d38c4c0e0e881c185d5cd959609a1b6044820152606401610625565b6000805460ff60a01b1916600160a01b1790556040513381527f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258906020015b60405180910390a1565b600054600160a01b900460ff16611cfb5760405162461bcd60e51b815260206004820152601160248201527014d38c4c0e4e881b9bdd081c185d5cd959607a1b6044820152606401610625565b6000805460ff60a01b191690556040513381527f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa90602001611ca4565b600080611d448361114f565b9050806001600160a01b0316846001600160a01b03161480611d8b57506001600160a01b038082166000908152606d602090815260408083209388168352929052205460ff165b80611daf5750836001600160a01b0316611da484610589565b6001600160a01b0316145b949350505050565b826001600160a01b0316611dca8261114f565b6001600160a01b031614611e2e5760405162461bcd60e51b815260206004820152602560248201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060448201526437bbb732b960d91b6064820152608401610625565b6001600160a01b038216611e905760405162461bcd60e51b8152602060048201526024808201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646044820152637265737360e01b6064820152608401610625565b611e9b838383612327565b611ea6600082611afd565b6001600160a01b0383166000908152606b60205260408120805460019290611ecf90849061358e565b90915550506001600160a01b0382166000908152606b60205260408120805460019290611efd9084906135a5565b90915550506000818152606a602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4505050565b6000611f698261114f565b9050611f7781600084612327565b611f82600083611afd565b6001600160a01b0381166000908152606b60205260408120805460019290611fab90849061358e565b90915550506000828152606a602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a45050565b8151612018906002906020850190612bf4565b506115ea81612592565b600354610100900460ff166120495760405162461bcd60e51b8152600401610625906135bd565b6115b48282612703565b816001600160a01b0316836001600160a01b031614156120b55760405162461bcd60e51b815260206004820152601960248201527f4552433732313a20617070726f766520746f2063616c6c6572000000000000006044820152606401610625565b6001600160a01b038381166000818152606d6020908152604080832094871680845294825291829020805460ff191686151590811790915591519182527f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a3505050565b61212d848484611db7565b61213984848484612751565b6115ea5760405162461bcd60e51b815260040161062590613608565b6060600280546105069061329f565b6060816121885750506040805180820190915260018152600360fc1b602082015290565b8160005b81156121b2578061219c816134ca565b91506121ab9050600a83613670565b915061218c565b6000816001600160401b038111156121cc576121cc612df1565b6040519080825280601f01601f1916602001820160405280156121f6576020820181803683370190505b5090505b8415611daf5761220b60018361358e565b9150612218600a86613684565b6122239060306135a5565b60f81b8183815181106122385761223861349e565b60200101906001600160f81b031916908160001a90535061225a600a86613670565b94506121fa565b60008054604051637290585560e01b815260048101849052829182916001600160a01b039091169063729058559060240160006040518083038186803b1580156122aa57600080fd5b505afa1580156122be573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526122e69190810190613403565b91509150611daf82826119cc565b6122fe838361285e565b61230b6000848484612751565b6106c65760405162461bcd60e51b815260040161062590613608565b600054600160a01b900460ff16156123715760405162461bcd60e51b815260206004820152600d60248201526c14d38c4c0e0e881c185d5cd959609a1b6044820152606401610625565b600054604051632474521560e21b81527fec0348d8f67c17b6a4f0d5fe690f13320db186c52b5d6496aada586aef1fba0960048201526001600160a01b038086166024830152859216906391d148549060440160206040518083038186803b1580156123dc57600080fd5b505afa1580156123f0573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906124149190613311565b1561247d5760405162461bcd60e51b815260206004820152603360248201527f534e3131383a207468652066726f6d20616464726573732069732072657374726044820152721a58dd195908185d081d1a19481b5bdb595b9d606a1b6064820152608401610625565b600054604051632474521560e21b81527fba36acc39ec3d3132500f85961bb78d126e633601d0ab49bb3612560538a7e2a60048201526001600160a01b038086166024830152859216906391d148549060440160206040518083038186803b1580156124e857600080fd5b505afa1580156124fc573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906125209190613311565b156125875760405162461bcd60e51b815260206004820152603160248201527f534e3131393a2074686520746f206164647265737320697320726573747269636044820152701d195908185d081d1a19481b5bdb595b9d607a1b6064820152608401610625565b6111488585856129ac565b6000816001600160a01b03166354fd4d506040518163ffffffff1660e01b815260040160206040518083038186803b1580156125cd57600080fd5b505afa1580156125e1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906126059190613485565b118061268a57506040516301ffc9a760e01b8152635b21ca7b60e11b60048201526001600160a01b038216906301ffc9a79060240160206040518083038186803b15801561265257600080fd5b505afa158015612666573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061268a9190613311565b6126e15760405162461bcd60e51b815260206004820152602260248201527f534e3130373a206e6f7420612076616c696420636f6e66696720636f6e74726160448201526118dd60f21b6064820152608401610625565b600080546001600160a01b0319166001600160a01b0392909216919091179055565b600354610100900460ff1661272a5760405162461bcd60e51b8152600401610625906135bd565b815161273d906068906020850190612bf4565b5080516106c6906069906020840190612bf4565b60006001600160a01b0384163b1561285357604051630a85bd0160e11b81526001600160a01b0385169063150b7a0290612795903390899088908890600401613698565b602060405180830381600087803b1580156127af57600080fd5b505af19250505080156127df575060408051601f3d908101601f191682019092526127dc918101906136d5565b60015b612839573d80801561280d576040519150601f19603f3d011682016040523d82523d6000602084013e612812565b606091505b5080516128315760405162461bcd60e51b815260040161062590613608565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050611daf565b506001949350505050565b6001600160a01b0382166128b45760405162461bcd60e51b815260206004820181905260248201527f4552433732313a206d696e7420746f20746865207a65726f20616464726573736044820152606401610625565b6000818152606a60205260409020546001600160a01b0316156129195760405162461bcd60e51b815260206004820152601c60248201527f4552433732313a20746f6b656e20616c7265616479206d696e746564000000006044820152606401610625565b61292560008383612327565b6001600160a01b0382166000908152606b6020526040812080546001929061294e9084906135a5565b90915550506000818152606a602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a45050565b6001600160a01b038316612a0757612a0281609c80546000838152609d60205260408120829055600182018355919091527faf85b9071dfafeac1409d3f1d19bafc9bc7c37974cde8df0ee6168f0086e539c0155565b612a2a565b816001600160a01b0316836001600160a01b031614612a2a57612a2a8382612a64565b6001600160a01b038216612a41576106c681612b01565b826001600160a01b0316826001600160a01b0316146106c6576106c68282612bb0565b60006001612a7184611486565b612a7b919061358e565b6000838152609b6020526040902054909150808214612ace576001600160a01b0384166000908152609a602090815260408083208584528252808320548484528184208190558352609b90915290208190555b506000918252609b602090815260408084208490556001600160a01b039094168352609a81528383209183525290812055565b609c54600090612b139060019061358e565b6000838152609d6020526040812054609c8054939450909284908110612b3b57612b3b61349e565b9060005260206000200154905080609c8381548110612b5c57612b5c61349e565b6000918252602080832090910192909255828152609d9091526040808220849055858252812055609c805480612b9457612b946136f2565b6001900381819060005260206000200160009055905550505050565b6000612bbb83611486565b6001600160a01b039093166000908152609a602090815260408083208684528252808320859055938252609b9052919091209190915550565b828054612c009061329f565b90600052602060002090601f016020900481019282612c225760008555612c68565b82601f10612c3b57805160ff1916838001178555612c68565b82800160010185558215612c68579182015b82811115612c68578251825591602001919060010190612c4d565b50612c74929150612c78565b5090565b5b80821115612c745760008155600101612c79565b6001600160e01b0319811681146108ae57600080fd5b600060208284031215612cb557600080fd5b8135611a4781612c8d565b60005b83811015612cdb578181015183820152602001612cc3565b838111156115ea5750506000910152565b60008151808452612d04816020860160208601612cc0565b601f01601f19169290920160200192915050565b602081526000611a476020830184612cec565b600060208284031215612d3d57600080fd5b5035919050565b6001600160a01b03811681146108ae57600080fd5b60008060408385031215612d6c57600080fd5b8235612d7781612d44565b946020939093013593505050565b80151581146108ae57600080fd5b600060208284031215612da557600080fd5b8135611a4781612d85565b600080600060608486031215612dc557600080fd5b8335612dd081612d44565b92506020840135612de081612d44565b929592945050506040919091013590565b634e487b7160e01b600052604160045260246000fd5b604080519081016001600160401b0381118282101715612e2957612e29612df1565b60405290565b604051606081016001600160401b0381118282101715612e2957612e29612df1565b604051601f8201601f191681016001600160401b0381118282101715612e7957612e79612df1565b604052919050565b60006001600160401b03821115612e9a57612e9a612df1565b5060051b60200190565b60006020808385031215612eb757600080fd5b82356001600160401b03811115612ecd57600080fd5b8301601f81018513612ede57600080fd5b8035612ef1612eec82612e81565b612e51565b81815260069190911b82018301908381019087831115612f1057600080fd5b928401925b82841015612f535760408489031215612f2e5760008081fd5b612f36612e07565b843581528585013586820152825260409093019290840190612f15565b979650505050505050565b60006001600160401b03821115612f7757612f77612df1565b50601f01601f191660200190565b600082601f830112612f9657600080fd5b8135612fa4612eec82612f5e565b818152846020838601011115612fb957600080fd5b816020850160208301376000918101602001919091529392505050565b600060208284031215612fe857600080fd5b81356001600160401b03811115612ffe57600080fd5b611daf84828501612f85565b6000806000806080858703121561302057600080fd5b84356001600160401b038082111561303757600080fd5b61304388838901612f85565b9550602087013591508082111561305957600080fd5b61306588838901612f85565b9450604087013591508082111561307b57600080fd5b5061308887828801612f85565b925050606085013561309981612d44565b939692955090935050565b6000602082840312156130b657600080fd5b8135611a4781612d44565b600080604083850312156130d457600080fd5b82356130df81612d44565b915060208301356130ef81612d85565b809150509250929050565b6000806000806080858703121561311057600080fd5b843561311b81612d44565b9350602085013561312b81612d44565b92506040850135915060608501356001600160401b0381111561314d57600080fd5b61315987828801612f85565b91505092959194509250565b6000602080838503121561317857600080fd5b82356001600160401b0381111561318e57600080fd5b8301601f8101851361319f57600080fd5b80356131ad612eec82612e81565b818152606091820283018401918482019190888411156131cc57600080fd5b938501935b8385101561321f5780858a0312156131e95760008081fd5b6131f1612e2f565b85356131fc81612d44565b8152858701358782015260408087013590820152835293840193918501916131d1565b50979650505050505050565b6000806040838503121561323e57600080fd5b823561324981612d44565b915060208301356130ef81612d44565b6000806040838503121561326c57600080fd5b8235915060208301356001600160401b0381111561328957600080fd5b61329585828601612f85565b9150509250929050565b600181811c908216806132b357607f821691505b602082108114156132d457634e487b7160e01b600052602260045260246000fd5b50919050565b6020808252601f908201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604082015260600190565b60006020828403121561332357600080fd5b8151611a4781612d85565b60208082526024908201527f534e3130333a2063616c6c6572206973206e6f7420746865206d696e74657220604082015263726f6c6560e01b606082015260800190565b60208082526023908201527f534e3130323a2063616c6c6572206973206e6f74207468652061646d696e20726040820152626f6c6560e81b606082015260800190565b6020808252602e908201527f4552433732313a2063616c6c6572206973206e6f7420746f6b656e206f776e6560408201526d1c881b9bdc88185c1c1c9bdd995960921b606082015260800190565b6000806040838503121561341657600080fd5b8251915060208301516001600160401b0381111561343357600080fd5b8301601f8101851361344457600080fd5b8051613452612eec82612f5e565b81815286602083850101111561346757600080fd5b613478826020830160208601612cc0565b8093505050509250929050565b60006020828403121561349757600080fd5b5051919050565b634e487b7160e01b600052603260045260246000fd5b634e487b7160e01b600052601160045260246000fd5b60006000198214156134de576134de6134b4565b5060010190565b600082516134f7818460208701612cc0565b9190910192915050565b60208082526021908201527f534e3131333a20746f6b656e496420616e64206f776e6572206d69736d6174636040820152600d60fb1b606082015260800190565b60008351613554818460208801612cc0565b835190830190613568818360208801612cc0565b01949350505050565b60006020828403121561358357600080fd5b8151611a4781612d44565b6000828210156135a0576135a06134b4565b500390565b600082198211156135b8576135b86134b4565b500190565b6020808252602b908201527f496e697469616c697a61626c653a20636f6e7472616374206973206e6f74206960408201526a6e697469616c697a696e6760a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b634e487b7160e01b600052601260045260246000fd5b60008261367f5761367f61365a565b500490565b6000826136935761369361365a565b500690565b6001600160a01b03858116825284166020820152604081018390526080606082018190526000906136cb90830184612cec565b9695505050505050565b6000602082840312156136e757600080fd5b8151611a4781612c8d565b634e487b7160e01b600052603160045260246000fdfea2646970667358221220a3f42b37d6f2ef5a8d238850282c3d349745bef53cae09bda7dc77312d9a18dc64736f6c63430008090033
Verified Source Code Full Match
Compiler: v0.8.9+commit.e5eed63a
EVM: london
Optimization: Yes (200 runs)
IConfig.sol 9 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
interface IConfig {
function version() external pure returns (uint256 v);
function getRawValue(bytes32 key) external view returns(bytes32 typeID, bytes memory data);
function hasRole(bytes32 role, address account) external view returns(bool has);
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
ERC721Upgradeable.sol 466 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721Upgradeable.sol";
import "./IERC721ReceiverUpgradeable.sol";
import "./extensions/IERC721MetadataUpgradeable.sol";
import "../../utils/AddressUpgradeable.sol";
import "../../utils/ContextUpgradeable.sol";
import "../../utils/StringsUpgradeable.sol";
import "../../utils/introspection/ERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721Upgradeable is Initializable, ContextUpgradeable, ERC165Upgradeable, IERC721Upgradeable, IERC721MetadataUpgradeable {
using AddressUpgradeable for address;
using StringsUpgradeable for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
function __ERC721_init(string memory name_, string memory symbol_) internal onlyInitializing {
__ERC721_init_unchained(name_, symbol_);
}
function __ERC721_init_unchained(string memory name_, string memory symbol_) internal onlyInitializing {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165Upgradeable, IERC165Upgradeable) returns (bool) {
return
interfaceId == type(IERC721Upgradeable).interfaceId ||
interfaceId == type(IERC721MetadataUpgradeable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: 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 = ERC721Upgradeable.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 = ERC721Upgradeable.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 = ERC721Upgradeable.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_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(ERC721Upgradeable.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(ERC721Upgradeable.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 IERC721ReceiverUpgradeable(to).onERC721Received(_msgSender(), from, tokenId, data) returns (bytes4 retval) {
return retval == IERC721ReceiverUpgradeable.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
/// @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 {}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[44] private __gap;
}
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);
}
}
IERC721EnumerableUpgradeable.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../IERC721Upgradeable.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721EnumerableUpgradeable is IERC721Upgradeable {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
StringsUpgradeable.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 StringsUpgradeable {
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);
}
}
IERC721MetadataUpgradeable.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721Upgradeable.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721MetadataUpgradeable is IERC721Upgradeable {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
AddressUpgradeable.sol 195 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 AddressUpgradeable {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*
* [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 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);
}
}
}
}
ERC165Upgradeable.sol 42 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165Upgradeable.sol";
import "../../proxy/utils/Initializable.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165Upgradeable is Initializable, IERC165Upgradeable {
function __ERC165_init() internal onlyInitializing {
}
function __ERC165_init_unchained() internal onlyInitializing {
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165Upgradeable).interfaceId;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
NFT.sol 51 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
import "./Context.sol";
import "../Pausable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
contract NFT is Context, Pausable, ReentrancyGuard {
string public baseUri;
struct NFTParam {
uint256 tokenId;
uint256 amount;
}
struct TransferParam {
address to;
uint256 tokenId;
uint256 amount;
}
event SetBaseURI(address indexed sender, string indexed uri);
function initialize(string memory, string memory, string memory uri_, address config_) public virtual {
baseUri = uri_;
_checkConfig(IConfig(config_));
}
function setPaused(bool isPaused) public onlyAdmin {
if (isPaused) {
_pause();
} else {
_unpause();
}
}
function mintNFT(NFTParam[] memory) public virtual returns (bool) {
return true;
}
function burnNFT(NFTParam[] memory) public virtual returns (bool) {
return true;
}
function transferNFT(TransferParam[] memory) public virtual returns (bool) {
return true;
}
}
ERC721EnumerableUpgradeable.sol 176 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../ERC721Upgradeable.sol";
import "./IERC721EnumerableUpgradeable.sol";
import "../../../proxy/utils/Initializable.sol";
/**
* @dev This implements an optional extension of {ERC721} defined in the EIP that adds
* enumerability of all the token ids in the contract as well as all token ids owned by each
* account.
*/
abstract contract ERC721EnumerableUpgradeable is Initializable, ERC721Upgradeable, IERC721EnumerableUpgradeable {
function __ERC721Enumerable_init() internal onlyInitializing {
}
function __ERC721Enumerable_init_unchained() internal onlyInitializing {
}
// Mapping from owner to list of owned token IDs
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
// Mapping from token ID to index of the owner tokens list
mapping(uint256 => uint256) private _ownedTokensIndex;
// Array with all token ids, used for enumeration
uint256[] private _allTokens;
// Mapping from token id to position in the allTokens array
mapping(uint256 => uint256) private _allTokensIndex;
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(IERC165Upgradeable, ERC721Upgradeable) returns (bool) {
return interfaceId == type(IERC721EnumerableUpgradeable).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view virtual override returns (uint256) {
require(index < ERC721Upgradeable.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view virtual override returns (uint256) {
return _allTokens.length;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view virtual override returns (uint256) {
require(index < ERC721EnumerableUpgradeable.totalSupply(), "ERC721Enumerable: global index out of bounds");
return _allTokens[index];
}
/**
* @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` cannot be the zero address.
* - `to` cannot be the zero address.
*
* 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 override {
super._beforeTokenTransfer(from, to, tokenId);
if (from == address(0)) {
_addTokenToAllTokensEnumeration(tokenId);
} else if (from != to) {
_removeTokenFromOwnerEnumeration(from, tokenId);
}
if (to == address(0)) {
_removeTokenFromAllTokensEnumeration(tokenId);
} else if (to != from) {
_addTokenToOwnerEnumeration(to, tokenId);
}
}
/**
* @dev Private function to add a token to this extension's ownership-tracking data structures.
* @param to address representing the new owner of the given token ID
* @param tokenId uint256 ID of the token to be added to the tokens list of the given address
*/
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721Upgradeable.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
/**
* @dev Private function to add a token to this extension's token tracking data structures.
* @param tokenId uint256 ID of the token to be added to the tokens list
*/
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
/**
* @dev Private function to remove a token from this extension's ownership-tracking data structures. Note that
* while the token is not assigned a new owner, the `_ownedTokensIndex` mapping is _not_ updated: this allows for
* gas optimizations e.g. when performing a transfer operation (avoiding double writes).
* This has O(1) time complexity, but alters the order of the _ownedTokens array.
* @param from address representing the previous owner of the given token ID
* @param tokenId uint256 ID of the token to be removed from the tokens list of the given address
*/
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
// To prevent a gap in from's tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = ERC721Upgradeable.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary
if (tokenIndex != lastTokenIndex) {
uint256 lastTokenId = _ownedTokens[from][lastTokenIndex];
_ownedTokens[from][tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_ownedTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
}
// This also deletes the contents at the last position of the array
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
/**
* @dev Private function to remove a token from this extension's token tracking data structures.
* This has O(1) time complexity, but alters the order of the _allTokens array.
* @param tokenId uint256 ID of the token to be removed from the tokens list
*/
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
// To prevent a gap in the tokens array, we store the last token in the index of the token to delete, and
// then delete the last slot (swap and pop).
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
// When the token to delete is the last token, the swap operation is unnecessary. However, since this occurs so
// rarely (when the last minted token is burnt) that we still do the swap here to avoid the gas cost of adding
// an 'if' statement (like in _removeTokenFromOwnerEnumeration)
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId; // Move the last token to the slot of the to-delete token
_allTokensIndex[lastTokenId] = tokenIndex; // Update the moved token's index
// This also deletes the contents at the last position of the array
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[46] private __gap;
}
Context.sol 81 lines
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
import "../Registry.sol";
import "../IConfig.sol";
contract Context {
// keccak256("address");
bytes32 public constant ADDRESS_HASH = 0x421683f821a0574472445355be6d2b769119e8515f8376a1d7878523dfdecf7b;
// keccak256("uint256");
bytes32 public constant UINT256_HASH = 0xec13d6d12b88433319b64e1065a96ea19cd330ef6603f5f6fb685dde3959a320;
IConfig public config;
function _getPlatformAssetContract() internal view returns (address) {
bytes32 _key = Registry.PLATFORM_ASSETS_CONTRACT_KEY;
address to = _getContractAddress(_key);
require(to != address(0), "SN100: platform asset contract not found");
return to;
}
function _getContractAddress(bytes32 key) internal view returns (address) {
(bytes32 typeID, bytes memory data) = config.getRawValue(key);
return bytesToAddress(typeID, data);
}
function bytesToAddress(bytes32 typeID, bytes memory data) public pure returns (address addr) {
require(typeID == ADDRESS_HASH, "SN101: wrong typeID");
addr = abi.decode(data, (address));
}
modifier onlyAdmin() {
require(config.hasRole(Registry.ADMIN_ROLE, msg.sender), "SN102: caller is not the admin role");
_;
}
modifier allowFreemint() {
require(config.hasRole(Registry.NFT_FREE_MINT_ROLE, msg.sender), "SN103: caller is not the freemint role");
_;
}
modifier isMinter() {
require(config.hasRole(Registry.NFT_GROUP_MINTER_ROLE, msg.sender), "SN103: caller is not the minter role");
_;
}
modifier isBurner() {
require(config.hasRole(Registry.NFT_GROUP_BURNER_ROLE, msg.sender), "SN104: caller is not the burner role");
_;
}
modifier isTransferer() {
require(config.hasRole(Registry.NFT_GROUP_TRANSFER_ROLE, msg.sender), "SN105: caller is not the transferer role");
_;
}
modifier isNotInTheFromBlacklist(address from) {
require(!config.hasRole(Registry.BLACKLIST_RESTRICTIONS_FROM_ROLE, from), "SN118: the from address is restricted at the moment");
_;
}
modifier isNotInTheToBlacklist(address to) {
require(!config.hasRole(Registry.BLACKLIST_RESTRICTIONS_TO_ROLE, to), "SN119: the to address is restricted at the moment");
_;
}
modifier selfBurn() {
(bytes32 typeID, bytes memory data) = config.getRawValue(Registry.SELF_BURN_KEY);
require(typeID == UINT256_HASH, "ERC20: wrong typeID");
require(abi.decode(data, (uint256)) == 1, "ERC20: not allowed to self-burning");
_;
}
function _checkConfig(IConfig config_) internal {
require(config_.version() > 0 || config_.supportsInterface(type(IConfig).interfaceId), "SN107: not a valid config contract");
config = config_;
}
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
Initializable.sol 138 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (proxy/utils/Initializable.sol)
pragma solidity ^0.8.2;
import "../../utils/AddressUpgradeable.sol";
/**
* @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed
* behind a proxy. Since proxied contracts do not make use of a constructor, it's common to move constructor logic to an
* external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer
* function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.
*
* The initialization functions use a version number. Once a version number is used, it is consumed and cannot be
* reused. This mechanism prevents re-execution of each "step" but allows the creation of new initialization steps in
* case an upgrade adds a module that needs to be initialized.
*
* For example:
*
* [.hljs-theme-light.nopadding]
* ```
* contract MyToken is ERC20Upgradeable {
* function initialize() initializer public {
* __ERC20_init("MyToken", "MTK");
* }
* }
* contract MyTokenV2 is MyToken, ERC20PermitUpgradeable {
* function initializeV2() reinitializer(2) public {
* __ERC20Permit_init("MyToken");
* }
* }
* ```
*
* TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as
* possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.
*
* CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure
* that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.
*
* [CAUTION]
* ====
* Avoid leaving a contract uninitialized.
*
* An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation
* contract, which may impact the proxy. To prevent the implementation contract from being used, you should invoke
* the {_disableInitializers} function in the constructor to automatically lock it when it is deployed:
*
* [.hljs-theme-light.nopadding]
* ```
* /// @custom:oz-upgrades-unsafe-allow constructor
* constructor() {
* _disableInitializers();
* }
* ```
* ====
*/
abstract contract Initializable {
/**
* @dev Indicates that the contract has been initialized.
* @custom:oz-retyped-from bool
*/
uint8 private _initialized;
/**
* @dev Indicates that the contract is in the process of being initialized.
*/
bool private _initializing;
/**
* @dev Triggered when the contract has been initialized or reinitialized.
*/
event Initialized(uint8 version);
/**
* @dev A modifier that defines a protected initializer function that can be invoked at most once. In its scope,
* `onlyInitializing` functions can be used to initialize parent contracts. Equivalent to `reinitializer(1)`.
*/
modifier initializer() {
bool isTopLevelCall = !_initializing;
require(
(isTopLevelCall && _initialized < 1) || (!AddressUpgradeable.isContract(address(this)) && _initialized == 1),
"Initializable: contract is already initialized"
);
_initialized = 1;
if (isTopLevelCall) {
_initializing = true;
}
_;
if (isTopLevelCall) {
_initializing = false;
emit Initialized(1);
}
}
/**
* @dev A modifier that defines a protected reinitializer function that can be invoked at most once, and only if the
* contract hasn't been initialized to a greater version before. In its scope, `onlyInitializing` functions can be
* used to initialize parent contracts.
*
* `initializer` is equivalent to `reinitializer(1)`, so a reinitializer may be used after the original
* initialization step. This is essential to configure modules that are added through upgrades and that require
* initialization.
*
* Note that versions can jump in increments greater than 1; this implies that if multiple reinitializers coexist in
* a contract, executing them in the right order is up to the developer or operator.
*/
modifier reinitializer(uint8 version) {
require(!_initializing && _initialized < version, "Initializable: contract is already initialized");
_initialized = version;
_initializing = true;
_;
_initializing = false;
emit Initialized(version);
}
/**
* @dev Modifier to protect an initialization function so that it can only be invoked by functions with the
* {initializer} and {reinitializer} modifiers, directly or indirectly.
*/
modifier onlyInitializing() {
require(_initializing, "Initializable: contract is not initializing");
_;
}
/**
* @dev Locks the contract, preventing any future reinitialization. This cannot be part of an initializer call.
* Calling this in the constructor of a contract will prevent that contract from being initialized or reinitialized
* to any version. It is recommended to use this to lock implementation contracts that are designed to be called
* through proxies.
*/
function _disableInitializers() internal virtual {
require(!_initializing, "Initializable: contract is initializing");
if (_initialized < type(uint8).max) {
_initialized = type(uint8).max;
emit Initialized(type(uint8).max);
}
}
}
IERC721ReceiverUpgradeable.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 IERC721ReceiverUpgradeable {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721Receiver.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
IERC721Upgradeable.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/IERC165Upgradeable.sol";
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721Upgradeable is IERC165Upgradeable {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* 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);
}
IERC165Upgradeable.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 IERC165Upgradeable {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Counters.sol 43 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Counters.sol)
pragma solidity ^0.8.0;
/**
* @title Counters
* @author Matt Condon (@shrugs)
* @dev Provides counters that can only be incremented, decremented or reset. This can be used e.g. to track the number
* of elements in a mapping, issuing ERC721 ids, or counting request ids.
*
* Include with `using Counters for Counters.Counter;`
*/
library Counters {
struct Counter {
// This variable should never be directly accessed by users of the library: interactions must be restricted to
// the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
// this feature: see https://github.com/ethereum/solidity/issues/4637
uint256 _value; // default: 0
}
function current(Counter storage counter) internal view returns (uint256) {
return counter._value;
}
function increment(Counter storage counter) internal {
unchecked {
counter._value += 1;
}
}
function decrement(Counter storage counter) internal {
uint256 value = counter._value;
require(value > 0, "Counter: decrement overflow");
unchecked {
counter._value = value - 1;
}
}
function reset(Counter storage counter) internal {
counter._value = 0;
}
}
Pausable.sol 40 lines
//SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
contract Pausable {
event Paused(address account);
event Unpaused(address account);
bool private _paused;
constructor() {
_paused = false;
}
function paused() public view virtual returns (bool) {
return _paused;
}
modifier whenNotPaused() {
require(!paused(), "SN108: paused");
_;
}
modifier whenPaused() {
require(paused(), "SN109: not paused");
_;
}
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(msg.sender);
}
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(msg.sender);
}
}
NFT-ERC721.sol 105 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
import "./NFT.sol";
import "@openzeppelin/contracts-upgradeable/token/ERC721/extensions/ERC721EnumerableUpgradeable.sol";
import "@openzeppelin/contracts/utils/Counters.sol";
import "@openzeppelin/contracts/utils/Strings.sol";
contract NFTERC721 is NFT, ERC721EnumerableUpgradeable {
using Counters for Counters.Counter;
Counters.Counter private _counterForTokenId;
uint256 public _mintUpperLimitAmount;
event SetUpperLimitOfTokenId(address sender, uint256 indexed maxAmount);
event Freemint(address sender, address indexed to, uint256 indexed tokenId);
function initialize(string memory name_, string memory symbol_, string memory uri_, address config_) public override initializer {
super.initialize(name_, symbol_, uri_, config_);
__ERC721_init(name_, symbol_);
}
function setBaseURI(string memory uri_) external onlyAdmin {
baseUri = uri_;
emit SetBaseURI(msg.sender, uri_);
}
function _baseURI() internal view override returns (string memory) {
return baseUri;
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
return string(abi.encodePacked(_baseURI(), Strings.toString(tokenId)));
}
function setUpperLimitOfTokenId(uint256 maxTokenId) external onlyAdmin {
_mintUpperLimitAmount = maxTokenId;
emit SetUpperLimitOfTokenId(_msgSender(), maxTokenId);
}
function freemint(address to) public allowFreemint returns (uint256 newTokenId) {
_counterForTokenId.increment();
newTokenId = _counterForTokenId.current();
require(newTokenId <= _mintUpperLimitAmount, "ERC721: exceeded upper limit of tokenId minting");
_safeMint(to, newTokenId);
emit Freemint(_msgSender(), to, newTokenId);
}
function mint() public nonReentrant isMinter returns (uint256 newTokenId) {
address to = _getPlatformAssetContract();
_counterForTokenId.increment();
newTokenId = _counterForTokenId.current();
_safeMint(to, newTokenId);
}
function mintNFT(NFTParam[] memory params) public override nonReentrant isMinter returns (bool) {
require(params.length > 0, "SN110: invalid parameters");
address to = _getPlatformAssetContract();
for (uint i = 0; i < params.length; i++) {
uint tokenId = params[i].tokenId;
require(params[i].amount == 1, "SN111: amount must be equal to 1");
super._safeMint(to, tokenId);
}
return super.mintNFT(params);
}
function burnNFT(NFTParam[] memory params) public override nonReentrant isBurner returns (bool) {
require(params.length > 0, "SN110: invalid parameters");
address from = _getPlatformAssetContract();
for (uint i = 0; i < params.length; i++) {
uint tokenId = params[i].tokenId;
require(params[i].amount == 1, "SN111: amount must be equal to 1");
require(_isApprovedOrOwner(_msgSender(), tokenId), "SN112: caller is not token owner nor approved");
require(ownerOf(tokenId) == from, "SN113: tokenId and owner mismatch");
super._burn(tokenId);
}
return super.burnNFT(params);
}
function burn(uint256 tokenId) public selfBurn {
require(ownerOf(tokenId) == msg.sender, "SN116: you do not have it");
_burn(tokenId);
}
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal override whenNotPaused isNotInTheFromBlacklist(from) isNotInTheToBlacklist(to) {
super._beforeTokenTransfer(from, to, tokenId);
}
function transferNFT(TransferParam[] memory params) public override nonReentrant isTransferer returns (bool) {
address from = _msgSender();
for (uint i = 0; i < params.length; i++) {
address to = params[i].to;
uint tokenId = params[i].tokenId;
require(ownerOf(tokenId) == from, "SN113: tokenId and owner mismatch");
super.safeTransferFrom(from, to, tokenId);
}
return super.transferNFT(params);
}
}
Registry.sol 34 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.8.0 <0.9.0;
library Registry {
// keccak256("platform.assets.contract.key");
bytes32 internal constant PLATFORM_ASSETS_CONTRACT_KEY = 0xc33c8716707b901a5897f5b0eb3bfd4928388fae53a418d46ab0875723c1dcd5;
// keccak256("self.burn.key")
bytes32 internal constant SELF_BURN_KEY = 0x75194dd2030e024bec7157fbb11d88254cd93866bea6f28460cb1a3f4ece16a8;
// keccak256("ADMIN_ROLE");
bytes32 internal constant ADMIN_ROLE = 0xa49807205ce4d355092ef5a8a18f56e8913cf4a201fbe287825b095693c21775;
// keccak256("nft.freemint.role")
bytes32 internal constant NFT_FREE_MINT_ROLE = 0x0767cc7d475698a20da8b9c9ab30101036be6749f2bf86a72d06268a5b3f1e5a;
// keccak256("nft.group.minter.role")
bytes32 internal constant NFT_GROUP_MINTER_ROLE = 0xd9d808b7856857a3760215b224352383987bacfc5008c9dca860116bcc2c8f0c;
// keccak256("nft.group.burner.role")
bytes32 internal constant NFT_GROUP_BURNER_ROLE = 0xe83fe28a8b39dca556b6801067344bab81e98ce23ce9aff4628a4103b6b6bb2d;
// keccak256("nft.group.transferer.role")
bytes32 internal constant NFT_GROUP_TRANSFER_ROLE = 0xdc24745d8f4fef6bd3d099210f61e8dbf7dc40d6062869098e8607ba57770b15;
// keccak256("blacklist.restrictions.from.role")
bytes32 internal constant BLACKLIST_RESTRICTIONS_FROM_ROLE = 0xec0348d8f67c17b6a4f0d5fe690f13320db186c52b5d6496aada586aef1fba09;
// keccak256("blacklist.restrictions.to.role")
bytes32 internal constant BLACKLIST_RESTRICTIONS_TO_ROLE = 0xba36acc39ec3d3132500f85961bb78d126e633601d0ab49bb3612560538a7e2a;
}
ContextUpgradeable.sol 37 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
import "../proxy/utils/Initializable.sol";
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract ContextUpgradeable is Initializable {
function __Context_init() internal onlyInitializing {
}
function __Context_init_unchained() internal onlyInitializing {
}
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
/**
* @dev This empty reserved space is put in place to allow future versions to add new
* variables without shifting down storage in the inheritance chain.
* See https://docs.openzeppelin.com/contracts/4.x/upgradeable#storage_gaps
*/
uint256[50] private __gap;
}
Read Contract
ADDRESS_HASH 0xc87d2cd7 → bytes32
UINT256_HASH 0x85668a21 → bytes32
_mintUpperLimitAmount 0xa9f52e7b → uint256
balanceOf 0x70a08231 → uint256
baseUri 0x9abc8320 → string
bytesToAddress 0xf38c363f → address
config 0x79502c55 → address
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
ownerOf 0x6352211e → address
paused 0x5c975abb → bool
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
Write Contract 15 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
burn 0x42966c68
uint256 tokenId
burnNFT 0x1eb24ce8
tuple[] params
returns: bool
freemint 0xf2c05b2e
address to
returns: uint256
initialize 0x5c6d8da1
string name_
string symbol_
string uri_
address config_
mint 0x1249c58b
No parameters
returns: uint256
mintNFT 0x69f9c679
tuple[] params
returns: bool
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string uri_
setPaused 0x16c38b3c
bool isPaused
setUpperLimitOfTokenId 0x36fe0da6
uint256 maxTokenId
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferNFT 0xa30a13f7
tuple[] params
returns: bool
Recent Transactions
No transactions found for this address