Address Contract Verified
Address
0xE6e8941f9B5CfA6f281f64DF76848920BE7911B3
Balance
0 ETH
Nonce
1
Code Size
18815 bytes
Creator
0x96cEba50...506A at tx 0x4a48a01d...ce3682
Indexed Transactions
0
Contract Bytecode
18815 bytes
0x6080604052600436106103e45760003560e01c806381b724ba11610208578063c252d4f911610118578063e0d988a3116100ab578063e985e9c51161007a578063e985e9c514610a7a578063eccfa9fb14610a9a578063f2c4ce1e14610aba578063f2fde38b14610ada578063f51f96dd14610afa576103e4565b8063e0d988a314610a1d578063e14ca35314610a3d578063e183fa6b14610a52578063e637dc8214610a5a576103e4565b8063c87b56dd116100e7578063c87b56dd146109cb578063d5abeb01146109eb578063dbdff2c114610a00578063e086e5ec14610a15576103e4565b8063c252d4f91461096c578063c26ecefa1461098c578063c6682862146109a1578063c6ab67a3146109b6576103e4565b80639ce60b831161019b578063a22cb4651161016a578063a22cb465146108e2578063a3be8a7814610902578063a475b5dd14610922578063adc2112f14610937578063b88d4fde1461094c576103e4565b80639ce60b83146108835780639da3f8fd146108985780639f181b5e146108ad578063a0d41d9f146108c2576103e4565b806394985ddd116101d757806394985ddd14610819578063953f049d1461083957806395d89b411461084e57806398e049b514610863576103e4565b806381b724ba146107c557806386a7a38c146107da5780638738bb11146107ef5780638da5cb5b14610804576103e4565b806342842e0e1161030357806361c4be551161029657806370f185a01161026557806370f185a014610746578063715018a614610766578063722503801461077b578063779ab8a0146107905780637d59946f146107b0576103e4565b806361c4be55146106dc5780636352211e146106f15780636c0360eb1461071157806370a0823114610726576103e4565b806351830227116102d2578063518302271461065957806351c557551461066e57806355f804b31461069c578063580684e2146106bc576103e4565b806342842e0e146105fa5780634b2596c71461061a5780634e6630b01461062f5780634f94319214610644576103e4565b80631a8fd9751161037b57806323e3fff31161034a57806323e3fff31461057a5780632f745c591461059a578063372c12b1146105ba57806339745791146105da576103e4565b80631a8fd975146105055780631f7b81251461051a5780632333f3c41461053a57806323b872dd1461055a576103e4565b8063095ea7b3116103b7578063095ea7b314610483578063096cf171146104a35780631759dcd5146104c357806318160ddd146104e3576103e4565b806301ffc9a7146103e957806306fbe2c11461041f57806306fdde0314610434578063081812fc14610456575b600080fd5b3480156103f557600080fd5b50610409610404366004613b67565b610b0f565b6040516104169190613dfb565b60405180910390f35b61043261042d366004613be5565b610b57565b005b34801561044057600080fd5b50610449610d02565b6040516104169190613e43565b34801561046257600080fd5b50610476610471366004613be5565b610d94565b6040516104169190613d61565b34801561048f57600080fd5b5061043261049e366004613a3c565b610dd7565b3480156104af57600080fd5b506104326104be366004613b0e565b610e6f565b3480156104cf57600080fd5b506104326104de366004613be5565b610eca565b3480156104ef57600080fd5b506104f8610f21565b6040516104169190613e16565b34801561051157600080fd5b506104f8610f27565b34801561052657600080fd5b50610409610535366004613906565b610f2d565b34801561054657600080fd5b506104f8610555366004613906565b610f42565b34801561056657600080fd5b50610432610575366004613952565b610f54565b34801561058657600080fd5b50610432610595366004613a65565b610f8c565b3480156105a657600080fd5b506104f86105b5366004613a3c565b6111ce565b3480156105c657600080fd5b506104096105d5366004613906565b611220565b3480156105e657600080fd5b506104326105f5366004613a65565b611235565b34801561060657600080fd5b50610432610615366004613952565b6113a7565b34801561062657600080fd5b506104f86113c2565b34801561063b57600080fd5b506104f86113c7565b34801561065057600080fd5b506104f861140d565b34801561066557600080fd5b50610409611413565b34801561067a57600080fd5b5061068e610689366004613906565b61141c565b604051610416929190613e06565b3480156106a857600080fd5b506104326106b7366004613b9f565b611448565b3480156106c857600080fd5b5061068e6106d7366004613906565b61149a565b3480156106e857600080fd5b506104096114c6565b3480156106fd57600080fd5b5061047661070c366004613be5565b6114d5565b34801561071d57600080fd5b5061044961150a565b34801561073257600080fd5b506104f8610741366004613906565b611598565b34801561075257600080fd5b50610432610761366004613be5565b6115dc565b34801561077257600080fd5b506104326116c9565b34801561078757600080fd5b50610449611714565b34801561079c57600080fd5b506104096107ab366004613906565b611721565b3480156107bc57600080fd5b50610432611736565b3480156107d157600080fd5b50610409611781565b3480156107e657600080fd5b50610432611791565b3480156107fb57600080fd5b506104f86117e5565b34801561081057600080fd5b506104766117eb565b34801561082557600080fd5b50610432610834366004613b46565b6117fa565b34801561084557600080fd5b506104f861184c565b34801561085a57600080fd5b50610449611852565b34801561086f57600080fd5b5061043261087e366004613aa5565b611861565b34801561088f57600080fd5b506104f8611acb565b3480156108a457600080fd5b50610409611ad1565b3480156108b957600080fd5b506104f8611adf565b3480156108ce57600080fd5b506104326108dd366004613aa5565b611af0565b3480156108ee57600080fd5b506104326108fd366004613a06565b611c8e565b34801561090e57600080fd5b506104f861091d366004613906565b611ca0565b34801561092e57600080fd5b50610432611cb2565b34801561094357600080fd5b50610432611d00565b34801561095857600080fd5b5061043261096736600461398d565b611e7b565b34801561097857600080fd5b506104f8610987366004613906565b611eba565b34801561099857600080fd5b506104f8611ecc565b3480156109ad57600080fd5b50610449611fa9565b3480156109c257600080fd5b50610449611fb6565b3480156109d757600080fd5b506104496109e6366004613be5565b611fc3565b3480156109f757600080fd5b506104f86120e5565b348015610a0c57600080fd5b506104f86120eb565b6104326121f7565b348015610a2957600080fd5b5061068e610a38366004613906565b6122cd565b348015610a4957600080fd5b506104f86122f9565b610432612315565b348015610a6657600080fd5b50610432610a75366004613aa5565b612547565b348015610a8657600080fd5b50610409610a95366004613920565b6127d3565b348015610aa657600080fd5b50610432610ab5366004613b0e565b612801565b348015610ac657600080fd5b50610432610ad5366004613b9f565b61285a565b348015610ae657600080fd5b50610432610af5366004613906565b6128ac565b348015610b0657600080fd5b506104f861291a565b60006001600160e01b031982166380ac58cd60e01b1480610b4057506001600160e01b03198216635b5e139f60e01b145b80610b4f5750610b4f82612926565b90505b919050565b60175462010000900460ff16610b885760405162461bcd60e51b8152600401610b7f9061477e565b60405180910390fd5b6000610b926122f9565b11610baf5760405162461bcd60e51b8152600401610b7f90614138565b336000908152601e6020526040902054610bdb5760405162461bcd60e51b8152600401610b7f90613e56565b336000908152601e6020526040902054811115610c0a5760405162461bcd60e51b8152600401610b7f906141f2565b610d4881600f54610c1b91906147cb565b1115610c395760405162461bcd60e51b8152600401610b7f906146d5565b610c4b81670214e8348c4f00006147f7565b341015610c6a5760405162461bcd60e51b8152600401610b7f9061416f565b336000908152601e602052604081208054839290610c89908490614816565b9091555050600f54610c9b908261293f565b600f5560015b818111610cfe576000610cb261294b565b9050610cbe3382612a92565b604051819033907f8e831c466df7986a7151dcb553c25ec8a1b822864bf871b6aeeb0347a86749df90600090a35080610cf681614894565b915050610ca1565b5050565b606060008054610d1190614859565b80601f0160208091040260200160405190810160405280929190818152602001828054610d3d90614859565b8015610d8a5780601f10610d5f57610100808354040283529160200191610d8a565b820191906000526020600020905b815481529060010190602001808311610d6d57829003601f168201915b5050505050905090565b6000610d9f82612aac565b610dbb5760405162461bcd60e51b8152600401610b7f90614432565b506000908152600460205260409020546001600160a01b031690565b6000610de2826114d5565b9050806001600160a01b0316836001600160a01b03161415610e165760405162461bcd60e51b8152600401610b7f90614588565b806001600160a01b0316610e28612ac9565b6001600160a01b03161480610e445750610e4481610a95612ac9565b610e605760405162461bcd60e51b8152600401610b7f906142e6565b610e6a8383612acd565b505050565b610e77612ac9565b6001600160a01b0316610e886117eb565b6001600160a01b031614610eae5760405162461bcd60e51b8152600401610b7f9061447e565b60178054911515620100000262ff000019909216919091179055565b610ed381612aac565b610eef5760405162461bcd60e51b8152600401610b7f906144b3565b610ef93382612b3b565b610f155760405162461bcd60e51b8152600401610b7f90614244565b610f1e81612bc0565b50565b60085490565b60115481565b60196020526000908152604090205460ff1681565b601e6020526000908152604090205481565b610f65610f5f612ac9565b82612b3b565b610f815760405162461bcd60e51b8152600401610b7f90614616565b610e6a838383612c00565b610f94612ac9565b6001600160a01b0316610fa56117eb565b6001600160a01b031614610fcb5760405162461bcd60e51b8152600401610b7f9061447e565b60005b81811015610e6a576000838383818110610ff857634e487b7160e01b600052603260045260246000fd5b905060200201602081019061100d9190613906565b6001600160a01b031614156110345760405162461bcd60e51b8152600401610b7f90614286565b6017546301000000900460ff1615611103576000601b600085858581811061106c57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906110819190613906565b6001600160a01b0316815260208101919091526040016000908120805460ff191692151592909217909155601c818585858181106110cf57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906110e49190613906565b6001600160a01b031681526020810191909152604001600020556111bc565b60006019600085858581811061112957634e487b7160e01b600052603260045260246000fd5b905060200201602081019061113e9190613906565b6001600160a01b0316815260208101919091526040016000908120805460ff191692151592909217909155601a8185858581811061118c57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906111a19190613906565b6001600160a01b031681526020810191909152604001600020555b806111c681614894565b915050610fce565b60006111d983611598565b82106111f75760405162461bcd60e51b8152600401610b7f90613f14565b506001600160a01b03919091166000908152602160209081526040808320938352929052205490565b601d6020526000908152604090205460ff1681565b61123d612ac9565b6001600160a01b031661124e6117eb565b6001600160a01b0316146112745760405162461bcd60e51b8152600401610b7f9061447e565b60005b81811015610e6a5760008383838181106112a157634e487b7160e01b600052603260045260246000fd5b90506020020160208101906112b69190613906565b6001600160a01b031614156112dd5760405162461bcd60e51b8152600401610b7f90614286565b6000601d600085858581811061130357634e487b7160e01b600052603260045260246000fd5b90506020020160208101906113189190613906565b6001600160a01b0316815260208101919091526040016000908120805460ff191692151592909217909155601e8185858581811061136657634e487b7160e01b600052603260045260246000fd5b905060200201602081019061137b9190613906565b6001600160a01b031681526020810191909152604001600020558061139f81614894565b915050611277565b610e6a83838360405180602001604052806000815250611e7b565b609581565b60006113d1612ac9565b6001600160a01b03166113e26117eb565b6001600160a01b0316146114085760405162461bcd60e51b8152600401610b7f9061447e565b504790565b600f5481565b60175460ff1681565b6001600160a01b03166000908152601b6020908152604080832054601c9092529091205460ff90911691565b611450612ac9565b6001600160a01b03166114616117eb565b6001600160a01b0316146114875760405162461bcd60e51b8152600401610b7f9061447e565b8051610cfe906013906020840190613765565b6001600160a01b0316600090815260196020908152604080832054601a9092529091205460ff90911691565b60175462010000900460ff1681565b6000818152600260205260408120546001600160a01b031680610b4f5760405162461bcd60e51b8152600401610b7f9061438d565b6013805461151790614859565b80601f016020809104026020016040519081016040528092919081815260200182805461154390614859565b80156115905780601f1061156557610100808354040283529160200191611590565b820191906000526020600020905b81548152906001019060200180831161157357829003601f168201915b505050505081565b60006001600160a01b0382166115c05760405162461bcd60e51b8152600401610b7f90614343565b506001600160a01b031660009081526003602052604090205490565b6115e4612ac9565b6001600160a01b03166115f56117eb565b6001600160a01b03161461161b5760405162461bcd60e51b8152600401610b7f9061447e565b60006116256122f9565b116116425760405162461bcd60e51b8152600401610b7f90614138565b8061164b6122f9565b10156116695760405162461bcd60e51b8152600401610b7f906145c9565b60015b818111610cfe57600061167d61294b565b90506116893382612a92565b604051819033907f773305d69372e79e7e5806bb2f1200d4a78648daeb0eeb52ef7a76103c834aa890600090a350806116c181614894565b91505061166c565b6116d1612ac9565b6001600160a01b03166116e26117eb565b6001600160a01b0316146117085760405162461bcd60e51b8152600401610b7f9061447e565b6117126000612d33565b565b6016805461151790614859565b601b6020526000908152604090205460ff1681565b61173e612ac9565b6001600160a01b031661174f6117eb565b6001600160a01b0316146117755760405162461bcd60e51b8152600401610b7f9061447e565b6017805460ff19169055565b6017546301000000900460ff1681565b611799612ac9565b6001600160a01b03166117aa6117eb565b6001600160a01b0316146117d05760405162461bcd60e51b8152600401610b7f9061447e565b6017805463ff00000019166301000000179055565b600e5481565b600c546001600160a01b031690565b336001600160a01b037f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb795216146118425760405162461bcd60e51b8152600401610b7f90614551565b610cfe8282612d85565b610d4881565b606060018054610d1190614859565b611869612ac9565b6001600160a01b031661187a6117eb565b6001600160a01b0316146118a05760405162461bcd60e51b8152600401610b7f9061447e565b60006118aa6122f9565b116118c75760405162461bcd60e51b8152600401610b7f90614138565b6000805b82811015611919578383828181106118f357634e487b7160e01b600052603260045260246000fd5b905060200201358261190591906147cb565b91508061191181614894565b9150506118cb565b50806119236122f9565b10156119415760405162461bcd60e51b8152600401610b7f906145c9565b80600e5460956119519190614816565b101561196f5760405162461bcd60e51b8152600401610b7f9061468f565b60005b84811015611ac3576119b584848381811061199d57634e487b7160e01b600052603260045260246000fd5b90506020020135600e5461293f90919063ffffffff16565b600e5560015b8484838181106119db57634e487b7160e01b600052603260045260246000fd5b905060200201358111611ab05760006119f261294b565b9050611a32888885818110611a1757634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611a2c9190613906565b82612a92565b80888885818110611a5357634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611a689190613906565b6001600160a01b03167f63bb95ed5ced171be914d4a04ef15495493c1476cebec347ac1e2665a14e73d460405160405180910390a35080611aa881614894565b9150506119bb565b5080611abb81614894565b915050611972565b505050505050565b60105481565b601754610100900460ff1681565b6000611aeb6007612dd8565b905090565b611af8612ac9565b6001600160a01b0316611b096117eb565b6001600160a01b031614611b2f5760405162461bcd60e51b8152600401610b7f9061447e565b60005b83811015611c87576000858583818110611b5c57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611b719190613906565b6001600160a01b03161415611b985760405162461bcd60e51b8152600401610b7f90614286565b6001601d6000878785818110611bbe57634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611bd39190613906565b6001600160a01b031681526020810191909152604001600020805460ff1916911515919091179055828282818110611c1b57634e487b7160e01b600052603260045260246000fd5b90506020020135601e6000878785818110611c4657634e487b7160e01b600052603260045260246000fd5b9050602002016020810190611c5b9190613906565b6001600160a01b0316815260208101919091526040016000205580611c7f81614894565b915050611b32565b5050505050565b610cfe611c99612ac9565b8383612ddc565b601c6020526000908152604090205481565b611cba612ac9565b6001600160a01b0316611ccb6117eb565b6001600160a01b031614611cf15760405162461bcd60e51b8152600401610b7f9061447e565b6017805460ff19166001179055565b611d08612ac9565b6001600160a01b0316611d196117eb565b6001600160a01b031614611d3f5760405162461bcd60e51b8152600401610b7f9061447e565b6000611d49611ecc565b11611d665760405162461bcd60e51b8152600401610b7f90614667565b6040516370a0823160e01b81526001600160a01b037f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca169063a9059cbb90339083906370a0823190611dbc903090600401613d61565b60206040518083038186803b158015611dd457600080fd5b505afa158015611de8573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611e0c9190613bfd565b6040518363ffffffff1660e01b8152600401611e29929190613db2565b602060405180830381600087803b158015611e4357600080fd5b505af1158015611e57573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610f1e9190613b2a565b611e8c611e86612ac9565b83612b3b565b611ea85760405162461bcd60e51b8152600401610b7f90614616565b611eb484848484612e7f565b50505050565b601a6020526000908152604090205481565b6000611ed6612ac9565b6001600160a01b0316611ee76117eb565b6001600160a01b031614611f0d5760405162461bcd60e51b8152600401610b7f9061447e565b6040516370a0823160e01b81526001600160a01b037f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca16906370a0823190611f59903090600401613d61565b60206040518083038186803b158015611f7157600080fd5b505afa158015611f85573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611aeb9190613bfd565b6014805461151790614859565b6015805461151790614859565b6060611fce82612aac565b611fea5760405162461bcd60e51b8152600401610b7f90614502565b60175460ff16612086576016805461200190614859565b80601f016020809104026020016040519081016040528092919081815260200182805461202d90614859565b801561207a5780601f1061204f5761010080835404028352916020019161207a565b820191906000526020600020905b81548152906001019060200180831161205d57829003601f168201915b50505050509050610b52565b6000612090612eb2565b905060008151116120b057604051806020016040528060008152506120de565b806120ba84612ec1565b60146040516020016120ce93929190613c8a565b6040516020818303038152906040525b9392505050565b61270f81565b60006120f5612ac9565b6001600160a01b03166121066117eb565b6001600160a01b03161461212c5760405162461bcd60e51b8152600401610b7f9061447e565b600d546040516370a0823160e01b81526001600160a01b037f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca16906370a082319061217b903090600401613d61565b60206040518083038186803b15801561219357600080fd5b505afa1580156121a7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906121cb9190613bfd565b10156121e95760405162461bcd60e51b8152600401610b7f906142bd565b611aeb601854600d54612fdc565b6121ff612ac9565b6001600160a01b03166122106117eb565b6001600160a01b0316146122365760405162461bcd60e51b8152600401610b7f9061447e565b60006122406113c7565b1161225d5760405162461bcd60e51b8152600401610b7f906143d6565b60006122676117eb565b6001600160a01b03164760405161227d90613d5e565b60006040518083038185875af1925050503d80600081146122ba576040519150601f19603f3d011682016040523d82523d6000602084013e6122bf565b606091505b5050905080610f1e57600080fd5b6001600160a01b03166000908152601d6020908152604080832054601e9092529091205460ff90911691565b6000612303611adf565b61230b610f21565b611aeb9190614816565b601754610100900460ff1661233c5760405162461bcd60e51b8152600401610b7f90614722565b60006123466122f9565b116123635760405162461bcd60e51b8152600401610b7f90614138565b60003233146123845760405162461bcd60e51b8152600401610b7f90613fb1565b61238c6117eb565b6001600160a01b0316336001600160a01b031614156123bd5760405162461bcd60e51b8152600401610b7f90614752565b6017546301000000900460ff161561240357336000908152601b602052604090205460ff166123fe5760405162461bcd60e51b8152600401610b7f90613ed0565b612432565b3360009081526019602052604090205460ff166124325760405162461bcd60e51b8152600401610b7f90613e8d565b6017546301000000900460ff161561245a5750336000908152601c602052604090205461246c565b50336000908152601a60205260409020545b61247e81670214e8348c4f00006147f7565b34101561249d5760405162461bcd60e51b8152600401610b7f9061416f565b6017546301000000900460ff16156124cb57336000908152601b60205260409020805460ff191690556124e3565b336000908152601960205260409020805460ff191690555b60005b818160ff161015610cfe5760006124fb61294b565b90506125073382612a92565b604051819033907f8794c15e36411de2af9f04db51395fceb22a64323256ec2fa673f979fcbbdb1990600090a3508061253f816148af565b9150506124e6565b61254f612ac9565b6001600160a01b03166125606117eb565b6001600160a01b0316146125865760405162461bcd60e51b8152600401610b7f9061447e565b60005b83811015611c875760008585838181106125b357634e487b7160e01b600052603260045260246000fd5b90506020020160208101906125c89190613906565b6001600160a01b031614156125ef5760405162461bcd60e51b8152600401610b7f90614286565b6017546301000000900460ff16156126e3576001601b600087878581811061262757634e487b7160e01b600052603260045260246000fd5b905060200201602081019061263c9190613906565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905582828281811061268457634e487b7160e01b600052603260045260246000fd5b90506020020135601c60008787858181106126af57634e487b7160e01b600052603260045260246000fd5b90506020020160208101906126c49190613906565b6001600160a01b031681526020810191909152604001600020556127c1565b60016019600087878581811061270957634e487b7160e01b600052603260045260246000fd5b905060200201602081019061271e9190613906565b6001600160a01b031681526020810191909152604001600020805460ff191691151591909117905582828281811061276657634e487b7160e01b600052603260045260246000fd5b90506020020135601a600087878581811061279157634e487b7160e01b600052603260045260246000fd5b90506020020160208101906127a69190613906565b6001600160a01b031681526020810191909152604001600020555b806127cb81614894565b915050612589565b6001600160a01b03918216600090815260056020908152604080832093909416825291909152205460ff1690565b612809612ac9565b6001600160a01b031661281a6117eb565b6001600160a01b0316146128405760405162461bcd60e51b8152600401610b7f9061447e565b601780549115156101000261ff0019909216919091179055565b612862612ac9565b6001600160a01b03166128736117eb565b6001600160a01b0316146128995760405162461bcd60e51b8152600401610b7f9061447e565b8051610cfe906016906020840190613765565b6128b4612ac9565b6001600160a01b03166128c56117eb565b6001600160a01b0316146128eb5760405162461bcd60e51b8152600401610b7f9061447e565b6001600160a01b0381166129115760405162461bcd60e51b8152600401610b7f90613ffb565b610f1e81612d33565b670214e8348c4f000081565b6001600160e01b031981166301ffc9a760e01b14919050565b60006120de82846147cb565b6000806129566122f9565b116129735760405162461bcd60e51b8152600401610b7f90614138565b600061297d611adf565b612985610f21565b61298f9190614816565b905060008133414445426040516020016129ad959493929190613c41565b6040516020818303038152906040528051906020012060001c6129d091906148cf565b600081815260096020526040812054919250906129ee5750806129ff565b506000818152600960205260409020545b60096000612a0e600186614816565b81526020019081526020016000205460001415612a4457612a30600184614816565b600083815260096020526040902055612a74565b60096000612a53600186614816565b81526020808201929092526040908101600090812054858252600990935220555b612a7c613117565b50600a54612a8a90826147cb565b935050505090565b610cfe828260405180602001604052806000815250613157565b6000908152600260205260409020546001600160a01b0316151590565b3390565b600081815260046020526040902080546001600160a01b0319166001600160a01b0384169081179091558190612b02826114d5565b6001600160a01b03167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b6000612b4682612aac565b612b625760405162461bcd60e51b8152600401610b7f906141a6565b6000612b6d836114d5565b9050806001600160a01b0316846001600160a01b03161480612ba85750836001600160a01b0316612b9d84610d94565b6001600160a01b0316145b80612bb85750612bb881856127d3565b949350505050565b612bc98161318a565b60008181526006602052604090208054612be290614859565b159050610f1e576000818152600660205260408120610f1e916137e9565b826001600160a01b0316612c13826114d5565b6001600160a01b031614612c395760405162461bcd60e51b8152600401610b7f90614041565b6001600160a01b038216612c5f5760405162461bcd60e51b8152600401610b7f906140bd565b612c6a838383613239565b612c75600082612acd565b6001600160a01b0383166000908152600360205260408120805460019290612c9e908490614816565b90915550506001600160a01b0382166000908152600360205260408120805460019290612ccc9084906147cb565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b0386811691821790925591518493918716917fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91a4610e6a838383610e6a565b600c80546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6017546301000000900460ff1615612da1576011819055612da7565b60108190555b604051819083907f258e8aab35e09293c36892d6c2e2ee63509c0ba72c3437d609e4f30109d3f16c90600090a35050565b5490565b816001600160a01b0316836001600160a01b03161415612e0e5760405162461bcd60e51b8152600401610b7f90614101565b6001600160a01b0383811660008181526005602090815260408083209487168084529490915290819020805460ff1916851515179055517f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3190612e72908590613dfb565b60405180910390a3505050565b612e8a848484612c00565b612e96848484846132c2565b611eb45760405162461bcd60e51b8152600401610b7f90613f5f565b606060138054610d1190614859565b606081612ee657506040805180820190915260018152600360fc1b6020820152610b52565b8160005b8115612f105780612efa81614894565b9150612f099050600a836147e3565b9150612eea565b60008167ffffffffffffffff811115612f3957634e487b7160e01b600052604160045260246000fd5b6040519080825280601f01601f191660200182016040528015612f63576020820181803683370190505b5090505b8415612bb857612f78600183614816565b9150612f85600a866148cf565b612f909060306147cb565b60f81b818381518110612fb357634e487b7160e01b600052603260045260246000fd5b60200101906001600160f81b031916908160001a905350612fd5600a866147e3565b9450612f67565b60007f000000000000000000000000514910771af9ca656af840dff83e8264ecf986ca6001600160a01b0316634000aea07f000000000000000000000000f0d54349addcf704f77ae15b96510dea15cb795284866000604051602001613043929190613c7c565b6040516020818303038152906040526040518463ffffffff1660e01b815260040161307093929190613dcb565b602060405180830381600087803b15801561308a57600080fd5b505af115801561309e573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906130c29190613b2a565b506000838152600b60205260408120546130e1908590839030906133dd565b6000858152600b60205260409020549091506130fe9060016147cb565b6000858152600b6020526040902055612bb88482613417565b6000806131226122f9565b1161313f5760405162461bcd60e51b8152600401610b7f90614138565b600061314b6007612dd8565b9050611aeb600761344a565b6131618383613453565b61316e60008484846132c2565b610e6a5760405162461bcd60e51b8152600401610b7f90613f5f565b6000613195826114d5565b90506131a381600084613239565b6131ae600083612acd565b6001600160a01b03811660009081526003602052604081208054600192906131d7908490614816565b909155505060008281526002602052604080822080546001600160a01b0319169055518391906001600160a01b038416907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908390a4610cfe81600084610e6a565b613244838383610e6a565b6001600160a01b0383166132605761325b8161353a565b613283565b816001600160a01b0316836001600160a01b03161461328357613283838261357d565b6001600160a01b03821661329f5761329a8161361a565b610e6a565b826001600160a01b0316826001600160a01b031614610e6a57610e6a82826136f0565b60006132d6846001600160a01b0316613734565b156133d257836001600160a01b031663150b7a026132f2612ac9565b8786866040518563ffffffff1660e01b81526004016133149493929190613d75565b602060405180830381600087803b15801561332e57600080fd5b505af192505050801561335e575060408051601f3d908101601f1916820190925261335b91810190613b83565b60015b6133b8573d80801561338c576040519150601f19603f3d011682016040523d82523d6000602084013e613391565b606091505b5080516133b05760405162461bcd60e51b8152600401610b7f90613f5f565b805181602001fd5b6001600160e01b031916630a85bd0160e11b149050612bb8565b506001949350505050565b6000848484846040516020016133f69493929190613e1f565b60408051601f19818403018152919052805160209091012095945050505050565b6000828260405160200161342c929190613c7c565b60405160208183030381529060405280519060200120905092915050565b80546001019055565b6001600160a01b0382166134795760405162461bcd60e51b8152600401610b7f906143fd565b61348281612aac565b1561349f5760405162461bcd60e51b8152600401610b7f90614086565b6134ab60008383613239565b6001600160a01b03821660009081526003602052604081208054600192906134d49084906147cb565b909155505060008181526002602052604080822080546001600160a01b0319166001600160a01b03861690811790915590518392907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a4610cfe60008383610e6a565b6012805460008381526020805260408120829055600182018355919091527fbb8a6a4669ba250d26cd7a459eca9d215f8307e33aebe50379bc5a3617ec34440155565b6000600161358a84611598565b6135949190614816565b6000838152601f60205260409020549091508082146135e7576001600160a01b03841660009081526021602090815260408083208584528252808320548484528184208190558352601f90915290208190555b506000918252601f602090815260408084208490556001600160a01b039094168352602181528383209183525290812055565b60125460009061362c90600190614816565b60008381526020805260408120546012805493945090928490811061366157634e487b7160e01b600052603260045260246000fd5b90600052602060002001549050806012838154811061369057634e487b7160e01b600052603260045260246000fd5b6000918252602080832090910192909255828152908052604080822084905585825281205560128054806136d457634e487b7160e01b600052603160045260246000fd5b6001900381819060005260206000200160009055905550505050565b60006136fb83611598565b6001600160a01b0390931660009081526021602090815260408083208684528252808320859055938252601f9052919091209190915550565b600080826001600160a01b0316803b806020016040519081016040528181526000908060200190933c511192915050565b82805461377190614859565b90600052602060002090601f01602090048101928261379357600085556137d9565b82601f106137ac57805160ff19168380011785556137d9565b828001600101855582156137d9579182015b828111156137d95782518255916020019190600101906137be565b506137e5929150613821565b5090565b5080546137f590614859565b6000825580601f106138075750610f1e565b601f016020900490600052602060002090810190610f1e91905b5b808211156137e55760008155600101613822565b600067ffffffffffffffff808411156138515761385161490f565b604051601f8501601f1916810160200182811182821017156138755761387561490f565b60405284815291508183850186101561388d57600080fd5b8484602083013760006020868301015250509392505050565b80356001600160a01b0381168114610b5257600080fd5b60008083601f8401126138ce578081fd5b50813567ffffffffffffffff8111156138e5578182fd5b60208301915083602080830285010111156138ff57600080fd5b9250929050565b600060208284031215613917578081fd5b6120de826138a6565b60008060408385031215613932578081fd5b61393b836138a6565b9150613949602084016138a6565b90509250929050565b600080600060608486031215613966578081fd5b61396f846138a6565b925061397d602085016138a6565b9150604084013590509250925092565b600080600080608085870312156139a2578081fd5b6139ab856138a6565b93506139b9602086016138a6565b925060408501359150606085013567ffffffffffffffff8111156139db578182fd5b8501601f810187136139eb578182fd5b6139fa87823560208401613836565b91505092959194509250565b60008060408385031215613a18578182fd5b613a21836138a6565b91506020830135613a3181614925565b809150509250929050565b60008060408385031215613a4e578182fd5b613a57836138a6565b946020939093013593505050565b60008060208385031215613a77578182fd5b823567ffffffffffffffff811115613a8d578283fd5b613a99858286016138bd565b90969095509350505050565b60008060008060408587031215613aba578384fd5b843567ffffffffffffffff80821115613ad1578586fd5b613add888389016138bd565b90965094506020870135915080821115613af5578384fd5b50613b02878288016138bd565b95989497509550505050565b600060208284031215613b1f578081fd5b81356120de81614925565b600060208284031215613b3b578081fd5b81516120de81614925565b60008060408385031215613b58578182fd5b50508035926020909101359150565b600060208284031215613b78578081fd5b81356120de81614933565b600060208284031215613b94578081fd5b81516120de81614933565b600060208284031215613bb0578081fd5b813567ffffffffffffffff811115613bc6578182fd5b8201601f81018413613bd6578182fd5b612bb884823560208401613836565b600060208284031215613bf6578081fd5b5035919050565b600060208284031215613c0e578081fd5b5051919050565b60008151808452613c2d81602086016020860161482d565b601f01601f19169290920160200192915050565b6bffffffffffffffffffffffff19606096871b811682529490951b909316601485015260288401919091526048830152606882015260880190565b918252602082015260400190565b600084516020613c9d8285838a0161482d565b8184019150602f60f81b825260018651613cbc81838601858b0161482d565b865493019284906002810483821680613cd657607f821691505b858210811415613cf457634e487b7160e01b88526022600452602488fd5b808015613d085760018114613d1d57613d4d565b60ff1984168887015282880186019450613d4d565b613d268b6147bf565b895b84811015613d435781548a8201890152908701908801613d28565b5050858389010194505b50929b9a5050505050505050505050565b90565b6001600160a01b0391909116815260200190565b6001600160a01b0385811682528416602082015260408101839052608060608201819052600090613da890830184613c15565b9695505050505050565b6001600160a01b03929092168252602082015260400190565b600060018060a01b038516825283602083015260606040830152613df26060830184613c15565b95945050505050565b901515815260200190565b9115158252602082015260400190565b90815260200190565b93845260208401929092526001600160a01b03166040830152606082015260800190565b6000602082526120de6020830184613c15565b6020808252601c908201527f596f7520617265206e6f74206f6e207468652077686974656c69737400000000604082015260600190565b60208082526023908201527f596f7520617265206e6f74206f6e207468652066697273742077696e6e65726c6040820152621a5cdd60ea1b606082015260800190565b60208082526024908201527f596f7520617265206e6f74206f6e20746865207365636f6e642077696e6e65726040820152631b1a5cdd60e21b606082015260800190565b6020808252602b908201527f455243373231456e756d657261626c653a206f776e657220696e646578206f7560408201526a74206f6620626f756e647360a81b606082015260800190565b60208082526032908201527f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560408201527131b2b4bb32b91034b6b83632b6b2b73a32b960711b606082015260800190565b6020808252602a908201527f596f752063616e2774206d696e74207468726f75676820612065787465726e616040820152691b0818dbdb9d1c9858dd60b21b606082015260800190565b60208082526026908201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160408201526564647265737360d01b606082015260800190565b60208082526025908201527f4552433732313a207472616e736665722066726f6d20696e636f72726563742060408201526437bbb732b960d91b606082015260800190565b6020808252601c908201527f4552433732313a20746f6b656e20616c7265616479206d696e74656400000000604082015260600190565b60208082526024908201527f4552433732313a207472616e7366657220746f20746865207a65726f206164646040820152637265737360e01b606082015260800190565b60208082526019908201527f4552433732313a20617070726f766520746f2063616c6c657200000000000000604082015260600190565b60208082526018908201527f4e6f206d6f726520746f6b656e7320617661696c61626c650000000000000000604082015260600190565b6020808252601c908201527f45544820616d6f756e74206973206e6f742073756666696369656e7400000000604082015260600190565b6020808252602c908201527f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b60208082526032908201527f596f752063616e206e6f74206d696e74206d6f7265207468616e20544f5249586040820152715b77686974654c697374436c61696d65645d60701b606082015260800190565b60208082526022908201527f4f776e6572206f7220417070726f76656420616464726573732063616e206275604082015261393760f11b606082015260800190565b6020808252601e908201527f596f752063616e27742061646420746865206e756c6c20616464726573730000604082015260600190565b6020808252600f908201526e4e6f7420656e6f756768204c494e4b60881b604082015260600190565b60208082526038908201527f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760408201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000606082015260800190565b6020808252602a908201527f4552433732313a2062616c616e636520717565727920666f7220746865207a65604082015269726f206164647265737360b01b606082015260800190565b60208082526029908201527f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460408201526832b73a103a37b5b2b760b91b606082015260800190565b6020808252600d908201526c0dcdee840caf0d2e6e8408aa89609b1b604082015260600190565b6020808252818101527f4552433732313a206d696e7420746f20746865207a65726f2061646472657373604082015260600190565b6020808252602c908201527f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860408201526b34b9ba32b73a103a37b5b2b760a11b606082015260800190565b6020808252818101527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572604082015260600190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba30b73a103a37b5b2b760891b606082015260800190565b6020808252602f908201527f4552433732314d657461646174613a2055524920717565727920666f72206e6f60408201526e3732bc34b9ba32b73a103a37b5b2b760891b606082015260800190565b6020808252601f908201527f4f6e6c7920565246436f6f7264696e61746f722063616e2066756c66696c6c00604082015260600190565b60208082526021908201527f4552433732313a20617070726f76616c20746f2063757272656e74206f776e656040820152603960f91b606082015260800190565b6020808252602d908201527f596f752063616e206e6f74206d696e74206d6f7265207468616e20617661696c60408201526c18589b19535a5b9d10dbdd5b9d609a1b606082015260800190565b60208082526031908201527f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f6040820152701ddb995c881b9bdc88185c1c1c9bdd9959607a1b606082015260800190565b6020808252600e908201526d6e6f74206578697374204c494e4b60901b604082015260600190565b60208082526026908201527f596f752063616e206e6f74206d696e74206d6f7265207468616e207465616d20604082015265737570706c7960d01b606082015260800190565b6020808252602d908201527f596f752063616e206e6f74206d696e74206d6f7265207468616e206d6178576860408201526c6974656c697374537570706c7960981b606082015260800190565b60208082526016908201527536b4b73a30b136329036bab9ba103132903a393ab29760511b604082015260600190565b60208082526012908201527113dddb995c8818d85b881b9bdd081b5a5b9d60721b604082015260600190565b60208082526021908201527f6d696e7457686974656c697374537461747573206d75737420626520747275656040820152601760f91b606082015260800190565b60009081526020902090565b600082198211156147de576147de6148e3565b500190565b6000826147f2576147f26148f9565b500490565b6000816000190483118215151615614811576148116148e3565b500290565b600082821015614828576148286148e3565b500390565b60005b83811015614848578181015183820152602001614830565b83811115611eb45750506000910152565b60028104600182168061486d57607f821691505b6020821081141561488e57634e487b7160e01b600052602260045260246000fd5b50919050565b60006000198214156148a8576148a86148e3565b5060010190565b600060ff821660ff8114156148c6576148c66148e3565b60010192915050565b6000826148de576148de6148f9565b500690565b634e487b7160e01b600052601160045260246000fd5b634e487b7160e01b600052601260045260246000fd5b634e487b7160e01b600052604160045260246000fd5b8015158114610f1e57600080fd5b6001600160e01b031981168114610f1e57600080fdfea2646970667358221220d760b101b08dce473f960e0b0b559b7aede8bcf1235b1ca89a3d56e932228f6564736f6c63430008000033
Verified Source Code Full Match
Compiler: v0.8.0+commit.c7dfd78e
EVM: istanbul
Optimization: Yes (200 runs)
torix.sol 431 lines
//SPDX-License-Identifier: MIT
pragma solidity 0.8.0;
import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/utils/math/SafeMath.sol";
import "@1001-digital/erc721-extensions/contracts/RandomlyAssigned.sol";
import "@chainlink/contracts/src/v0.8/VRFConsumerBase.sol";
contract TORIX is ERC721URIStorage, RandomlyAssigned, VRFConsumerBase, Ownable {
using Strings for uint256;
using SafeMath for uint256;
uint256 internal fee;
uint256 public teamSupplyMinted;
uint256 public whitelistSupplyMinted;
uint256 public constant maxSupply = 9999;
uint256 public constant maxTeamSupply = 149;
uint256 public constant maxWhitelistSupply = 3400;
uint256 public constant salePrice = 0.15 ether;
uint256 public firstWinnerMetadataShuffleRandomResult;
uint256 public secondWinnerMetadataShuffleRandomResult;
uint256[] private _allTokens;
string public baseURI;
string public baseExtension = ".json";
/**
* @dev Each TORIX image is hashed using SHA-256.
* These hashes are then, in order 1 - 9999, concatenated into a string which is then hashed using SHA-256 into provenceHash.
*/
string public provenanceHash = "ea7f691c1a1a95a617805076904035dcbf8e1f0878f47caa53c51ad309d1c062";
string public notRevealedURI;
bool public revealed;
bool public mintStatus;
bool public mintWhitelistStatus;
bool public secondSale;
bytes32 internal keyHash;
mapping(address => bool) public firstWinnerList;
mapping(address => uint256) public firstWinnerListClaimed;
mapping(address => bool) public secondWinnerList;
mapping(address => uint256) public secondWinnerListClaimed;
mapping(address => bool) public whiteList;
mapping(address => uint256) public whiteListClaimed;
mapping(uint256 => uint256) private _ownedTokensIndex;
mapping(uint256 => uint256) private _allTokensIndex;
mapping(address => mapping(uint256 => uint256)) private _ownedTokens;
modifier mintable() {
require(mintStatus, "mintable must be true.");
_;
}
modifier mintableWhitelist() {
require(mintWhitelistStatus, "mintWhitelistStatus must be true.");
_;
}
event RequestRandomnessFulfilled(bytes32 indexed requestId, uint256 indexed randomness);
event RequestAddWinnListEvent(address[] indexed addresses, uint256[] indexed mintcount);
event RequestRemoveWinnerList(address[] indexed addresses);
event RequestOwnerMint(address indexed ownerAddress, uint256 indexed tokenId);
event RequestReserveMint(address indexed ownerAddress, uint256 indexed tokenId);
event RequestWinnerMint(address indexed winnerAddress, uint256 indexed tokenId);
event RequestWhitelistMint(address indexed winnerAddress, uint256 indexed tokenId);
constructor(
string memory _name,
string memory _symbol,
address _VRFCoordinator,
address _LinkToken,
bytes32 _keyhash,
uint256 _fee
)
ERC721(_name, _symbol)
RandomlyAssigned(maxSupply,1)
VRFConsumerBase(_VRFCoordinator, _LinkToken)
{
keyHash = _keyhash;
fee = _fee;
}
/**
* @dev Requests randomness
*/
function getRandomNumber() public onlyOwner returns (bytes32 requestId) {
require(LINK.balanceOf(address(this)) >= fee, "Not enough LINK");
return requestRandomness(keyHash, fee);
}
/**
* @dev Callback function used by VRF Coordinator
*/
function fulfillRandomness(bytes32 requestId, uint256 randomness) internal override {
if(secondSale){
secondWinnerMetadataShuffleRandomResult = randomness;
}else{
firstWinnerMetadataShuffleRandomResult = randomness;
}
emit RequestRandomnessFulfilled(requestId, randomness);
}
/**
* @dev Adds the provided address(mint count) to the whitelist
*/
function addWhiteList(address[] calldata addresses, uint256[] calldata mintcount) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
require(addresses[i] != address(0), "You can't add the null address");
whiteList[addresses[i]] = true;
whiteListClaimed[addresses[i]] = mintcount[i];
}
}
/**
* @dev Removes the provided address to the whitelist
*/
function removeWhiteList(address[] calldata addresses) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
require(addresses[i] != address(0), "You can't add the null address");
whiteList[addresses[i]] = false;
whiteListClaimed[addresses[i]] = 0;
}
}
/**
* @dev Adds the provided address(mint count) to the winnerlist
*/
function addWinnerList(address[] calldata addresses, uint256[] calldata mintcount) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
require(addresses[i] != address(0), "You can't add the null address");
if(secondSale){
secondWinnerList[addresses[i]] = true;
secondWinnerListClaimed[addresses[i]] = mintcount[i];
}else{
firstWinnerList[addresses[i]] = true;
firstWinnerListClaimed[addresses[i]] = mintcount[i];
}
}
}
/**
* @dev Removes the provided address to the winnerlist
*/
function removeWinnerList(address[] calldata addresses) external onlyOwner {
for (uint256 i = 0; i < addresses.length; i++) {
require(addresses[i] != address(0), "You can't add the null address");
if(secondSale){
secondWinnerList[addresses[i]] = false;
secondWinnerListClaimed[addresses[i]] = 0;
}else{
firstWinnerList[addresses[i]] = false;
firstWinnerListClaimed[addresses[i]] = 0;
}
}
}
/**
* @dev Returns check whether the address is whitelisted
*/
function checkWhitelistWinner(address _address) public view returns(bool, uint256) {
return (whiteList[_address], whiteListClaimed[_address]);
}
/**
* @dev Returns check whether the address is first sale winnerlisted
*/
function checkFirstWinner(address _address) public view returns(bool, uint256) {
return (firstWinnerList[_address], firstWinnerListClaimed[_address]);
}
/**
* @dev Returns check whether the address is second sale winnerlisted
*/
function checkSecondWinner(address _address) public view returns(bool, uint256) {
return (secondWinnerList[_address], secondWinnerListClaimed[_address]);
}
/**
* @dev minted by only owner
*/
function mintOwnerTorix(uint256 mintcount)
external
onlyOwner
ensureAvailability
{
require(availableTokenCount() >= mintcount, "You can not mint more than availableMintCount");
for (uint i = 1; i <= mintcount; i++) {
uint256 id = nextToken();
_safeMint(msg.sender, id);
emit RequestOwnerMint(msg.sender, id);
}
}
/**
* @dev minted by the teamlist
*/
function mintTeamTorix(address[] calldata addresses, uint256[] calldata mintcount)
external
onlyOwner
ensureAvailability
{
uint256 totalMintCount;
for(uint256 i = 0; i < mintcount.length; i++){
totalMintCount += mintcount[i];
}
require( availableTokenCount() >= totalMintCount, "You can not mint more than availableMintCount");
require( maxTeamSupply - teamSupplyMinted >= totalMintCount, "You can not mint more than team supply");
for (uint256 i = 0; i < addresses.length; i++) {
teamSupplyMinted = teamSupplyMinted.add(mintcount[i]);
for (uint j = 1; j <= mintcount[i]; j++) {
uint256 id = nextToken();
_safeMint(addresses[i], id);
emit RequestReserveMint(addresses[i], id);
}
}
}
/**
* @dev minted by the whitelist
*/
function mintWhitelistTorix(uint256 mintcount)
public
payable
mintableWhitelist
ensureAvailability
{
require( whiteListClaimed[msg.sender] > 0, "You are not on the whitelist");
require( whiteListClaimed[msg.sender] >= mintcount, "You can not mint more than TORIX[whiteListClaimed]");
require( whitelistSupplyMinted + mintcount <= maxWhitelistSupply, "You can not mint more than maxWhitelistSupply");
require( msg.value >= salePrice * mintcount, "ETH amount is not sufficient");
whiteListClaimed[msg.sender] -= mintcount;
whitelistSupplyMinted = whitelistSupplyMinted.add(mintcount);
for (uint i = 1; i <= mintcount; i++) {
uint256 id = nextToken();
_safeMint(msg.sender, id);
emit RequestWhitelistMint(msg.sender, id);
}
}
/**
* @dev minted by the winner
*/
function mintTorix()
public
payable
mintable
ensureAvailability
{
uint256 availableMintCount;
require( tx.origin == msg.sender, "You can't mint through a external contract");
require( msg.sender != owner(), "Owner can not mint");
if(secondSale){
require( secondWinnerList[msg.sender], "You are not on the second winnerlist");
}else{
require( firstWinnerList[msg.sender], "You are not on the first winnerlist");
}
if(secondSale){
availableMintCount = secondWinnerListClaimed[msg.sender];
}else{
availableMintCount = firstWinnerListClaimed[msg.sender];
}
require( msg.value >= salePrice * availableMintCount, "ETH amount is not sufficient");
if(secondSale){
secondWinnerList[msg.sender] = false;
}else{
firstWinnerList[msg.sender] = false;
}
for(uint8 i=0;i<availableMintCount;i++){
uint256 id = nextToken();
_safeMint(msg.sender, id);
emit RequestWinnerMint(msg.sender, id);
}
}
/**
* @dev Enable the second sale flag
*/
function onSecondSale() public onlyOwner {
secondSale = true;
}
/**
* @dev Enable reveal
*/
function reveal() public onlyOwner {
revealed = true;
}
/**
* @dev Disable not reveal
*/
function notReveal() public onlyOwner {
revealed = false;
}
/**
* @dev Set not reveal URI
*/
function setNotRevealedURI(string memory _notRevealedURI) public onlyOwner {
notRevealedURI = _notRevealedURI;
}
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
function setBaseURI(string memory _newBaseURI) public onlyOwner {
baseURI = _newBaseURI;
}
/**
* @dev Enable or disable the mintable status
*/
function toggleMintable(bool _mintStatus) public onlyOwner {
mintStatus = _mintStatus;
}
/**
* @dev Enable or disable the whitelist mintable status
*/
function toggleWhitelistMintable(bool _mintWhitelistStatus) public onlyOwner {
mintWhitelistStatus = _mintWhitelistStatus;
}
function tokenURI(uint256 tokenId) public view virtual override
returns (string memory){
require(_exists(tokenId),
"ERC721Metadata: URI query for nonexistent token"
);
if(revealed == false) {
return notRevealedURI;
}
string memory currentBaseURI = _baseURI();
return bytes(currentBaseURI).length >0 ? string(abi.encodePacked(currentBaseURI, "/", tokenId.toString(), baseExtension)) : "";
}
/**
* @dev IERC721Enumerable
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256) {
require(index < ERC721.balanceOf(owner), "ERC721Enumerable: owner index out of bounds");
return _ownedTokens[owner][index];
}
function _addTokenToOwnerEnumeration(address to, uint256 tokenId) private {
uint256 length = ERC721.balanceOf(to);
_ownedTokens[to][length] = tokenId;
_ownedTokensIndex[tokenId] = length;
}
function _removeTokenFromOwnerEnumeration(address from, uint256 tokenId) private {
uint256 lastTokenIndex = ERC721.balanceOf(from) - 1;
uint256 tokenIndex = _ownedTokensIndex[tokenId];
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
}
delete _ownedTokensIndex[tokenId];
delete _ownedTokens[from][lastTokenIndex];
}
function _removeTokenFromAllTokensEnumeration(uint256 tokenId) private {
uint256 lastTokenIndex = _allTokens.length - 1;
uint256 tokenIndex = _allTokensIndex[tokenId];
uint256 lastTokenId = _allTokens[lastTokenIndex];
_allTokens[tokenIndex] = lastTokenId;
_allTokensIndex[lastTokenId] = tokenIndex;
delete _allTokensIndex[tokenId];
_allTokens.pop();
}
function _addTokenToAllTokensEnumeration(uint256 tokenId) private {
_allTokensIndex[tokenId] = _allTokens.length;
_allTokens.push(tokenId);
}
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);
}
}
function burnTorix(uint256 tokenId) public {
require(
_exists(tokenId),
"ERC721Metadata: URI query for nonexistant token"
);
require(_isApprovedOrOwner(msg.sender, tokenId),"Owner or Approved address can burn");
super._burn(tokenId);
}
function ethBalance() public view onlyOwner returns (uint256) {
return address(this).balance;
}
function linkBalance() public view onlyOwner returns (uint256) {
return LINK.balanceOf(address(this));
}
function withdrawETH() public payable onlyOwner {
require(ethBalance() > 0, "not exist ETH" );
(bool os, ) = payable(owner()).call{value: address(this).balance}("");
require(os);
}
function withdrawLINK() external onlyOwner {
require(linkBalance() > 0, "not exist LINK" );
LINK.transfer(msg.sender, LINK.balanceOf(address(this)));
}
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (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
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
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);
}
}
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;
}
}
ERC721.sol 447 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./IERC721Receiver.sol";
import "./extensions/IERC721Metadata.sol";
import "../../utils/Address.sol";
import "../../utils/Context.sol";
import "../../utils/Strings.sol";
import "../../utils/introspection/ERC165.sol";
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: 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);
_afterTokenTransfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
_afterTokenTransfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer from incorrect owner");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
_afterTokenTransfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits 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 {}
/**
* @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 {}
}
SafeMath.sol 227 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/math/SafeMath.sol)
pragma solidity ^0.8.0;
// CAUTION
// This version of SafeMath should only be used with Solidity 0.8 or later,
// because it relies on the compiler's built in overflow checks.
/**
* @dev Wrappers over Solidity's arithmetic operations.
*
* NOTE: `SafeMath` is generally not needed starting with Solidity 0.8, since the compiler
* now has built in overflow checking.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b > a) return (false, 0);
return (true, a - b);
}
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a / b);
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
unchecked {
if (b == 0) return (false, 0);
return (true, a % b);
}
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
return a + b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
return a * b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator.
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b <= a, errorMessage);
return a - b;
}
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a / b;
}
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(
uint256 a,
uint256 b,
string memory errorMessage
) internal pure returns (uint256) {
unchecked {
require(b > 0, errorMessage);
return a % b;
}
}
}
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;
}
VRFConsumerBase.sol 216 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./interfaces/LinkTokenInterface.sol";
import "./VRFRequestIDBase.sol";
/** ****************************************************************************
* @notice Interface for contracts using VRF randomness
* *****************************************************************************
* @dev PURPOSE
*
* @dev Reggie the Random Oracle (not his real job) wants to provide randomness
* @dev to Vera the verifier in such a way that Vera can be sure he's not
* @dev making his output up to suit himself. Reggie provides Vera a public key
* @dev to which he knows the secret key. Each time Vera provides a seed to
* @dev Reggie, he gives back a value which is computed completely
* @dev deterministically from the seed and the secret key.
*
* @dev Reggie provides a proof by which Vera can verify that the output was
* @dev correctly computed once Reggie tells it to her, but without that proof,
* @dev the output is indistinguishable to her from a uniform random sample
* @dev from the output space.
*
* @dev The purpose of this contract is to make it easy for unrelated contracts
* @dev to talk to Vera the verifier about the work Reggie is doing, to provide
* @dev simple access to a verifiable source of randomness.
* *****************************************************************************
* @dev USAGE
*
* @dev Calling contracts must inherit from VRFConsumerBase, and can
* @dev initialize VRFConsumerBase's attributes in their constructor as
* @dev shown:
*
* @dev contract VRFConsumer {
* @dev constuctor(<other arguments>, address _vrfCoordinator, address _link)
* @dev VRFConsumerBase(_vrfCoordinator, _link) public {
* @dev <initialization with other arguments goes here>
* @dev }
* @dev }
*
* @dev The oracle will have given you an ID for the VRF keypair they have
* @dev committed to (let's call it keyHash), and have told you the minimum LINK
* @dev price for VRF service. Make sure your contract has sufficient LINK, and
* @dev call requestRandomness(keyHash, fee, seed), where seed is the input you
* @dev want to generate randomness from.
*
* @dev Once the VRFCoordinator has received and validated the oracle's response
* @dev to your request, it will call your contract's fulfillRandomness method.
*
* @dev The randomness argument to fulfillRandomness is the actual random value
* @dev generated from your seed.
*
* @dev The requestId argument is generated from the keyHash and the seed by
* @dev makeRequestId(keyHash, seed). If your contract could have concurrent
* @dev requests open, you can use the requestId to track which seed is
* @dev associated with which randomness. See VRFRequestIDBase.sol for more
* @dev details. (See "SECURITY CONSIDERATIONS" for principles to keep in mind,
* @dev if your contract could have multiple requests in flight simultaneously.)
*
* @dev Colliding `requestId`s are cryptographically impossible as long as seeds
* @dev differ. (Which is critical to making unpredictable randomness! See the
* @dev next section.)
*
* *****************************************************************************
* @dev SECURITY CONSIDERATIONS
*
* @dev A method with the ability to call your fulfillRandomness method directly
* @dev could spoof a VRF response with any random value, so it's critical that
* @dev it cannot be directly called by anything other than this base contract
* @dev (specifically, by the VRFConsumerBase.rawFulfillRandomness method).
*
* @dev For your users to trust that your contract's random behavior is free
* @dev from malicious interference, it's best if you can write it so that all
* @dev behaviors implied by a VRF response are executed *during* your
* @dev fulfillRandomness method. If your contract must store the response (or
* @dev anything derived from it) and use it later, you must ensure that any
* @dev user-significant behavior which depends on that stored value cannot be
* @dev manipulated by a subsequent VRF request.
*
* @dev Similarly, both miners and the VRF oracle itself have some influence
* @dev over the order in which VRF responses appear on the blockchain, so if
* @dev your contract could have multiple VRF requests in flight simultaneously,
* @dev you must ensure that the order in which the VRF responses arrive cannot
* @dev be used to manipulate your contract's user-significant behavior.
*
* @dev Since the ultimate input to the VRF is mixed with the block hash of the
* @dev block in which the request is made, user-provided seeds have no impact
* @dev on its economic security properties. They are only included for API
* @dev compatability with previous versions of this contract.
*
* @dev Since the block hash of the block which contains the requestRandomness
* @dev call is mixed into the input to the VRF *last*, a sufficiently powerful
* @dev miner could, in principle, fork the blockchain to evict the block
* @dev containing the request, forcing the request to be included in a
* @dev different block with a different hash, and therefore a different input
* @dev to the VRF. However, such an attack would incur a substantial economic
* @dev cost. This cost scales with the number of blocks the VRF oracle waits
* @dev until it calls responds to a request.
*/
abstract contract VRFConsumerBase is VRFRequestIDBase {
/**
* @notice fulfillRandomness handles the VRF response. Your contract must
* @notice implement it. See "SECURITY CONSIDERATIONS" above for important
* @notice principles to keep in mind when implementing your fulfillRandomness
* @notice method.
*
* @dev VRFConsumerBase expects its subcontracts to have a method with this
* @dev signature, and will call it once it has verified the proof
* @dev associated with the randomness. (It is triggered via a call to
* @dev rawFulfillRandomness, below.)
*
* @param requestId The Id initially returned by requestRandomness
* @param randomness the VRF output
*/
function fulfillRandomness(
bytes32 requestId,
uint256 randomness
)
internal
virtual;
/**
* @dev In order to keep backwards compatibility we have kept the user
* seed field around. We remove the use of it because given that the blockhash
* enters later, it overrides whatever randomness the used seed provides.
* Given that it adds no security, and can easily lead to misunderstandings,
* we have removed it from usage and can now provide a simpler API.
*/
uint256 constant private USER_SEED_PLACEHOLDER = 0;
/**
* @notice requestRandomness initiates a request for VRF output given _seed
*
* @dev The fulfillRandomness method receives the output, once it's provided
* @dev by the Oracle, and verified by the vrfCoordinator.
*
* @dev The _keyHash must already be registered with the VRFCoordinator, and
* @dev the _fee must exceed the fee specified during registration of the
* @dev _keyHash.
*
* @dev The _seed parameter is vestigial, and is kept only for API
* @dev compatibility with older versions. It can't *hurt* to mix in some of
* @dev your own randomness, here, but it's not necessary because the VRF
* @dev oracle will mix the hash of the block containing your request into the
* @dev VRF seed it ultimately uses.
*
* @param _keyHash ID of public key against which randomness is generated
* @param _fee The amount of LINK to send with the request
*
* @return requestId unique ID for this request
*
* @dev The returned requestId can be used to distinguish responses to
* @dev concurrent requests. It is passed as the first argument to
* @dev fulfillRandomness.
*/
function requestRandomness(
bytes32 _keyHash,
uint256 _fee
)
internal
returns (
bytes32 requestId
)
{
LINK.transferAndCall(vrfCoordinator, _fee, abi.encode(_keyHash, USER_SEED_PLACEHOLDER));
// This is the seed passed to VRFCoordinator. The oracle will mix this with
// the hash of the block containing this request to obtain the seed/input
// which is finally passed to the VRF cryptographic machinery.
uint256 vRFSeed = makeVRFInputSeed(_keyHash, USER_SEED_PLACEHOLDER, address(this), nonces[_keyHash]);
// nonces[_keyHash] must stay in sync with
// VRFCoordinator.nonces[_keyHash][this], which was incremented by the above
// successful LINK.transferAndCall (in VRFCoordinator.randomnessRequest).
// This provides protection against the user repeating their input seed,
// which would result in a predictable/duplicate output, if multiple such
// requests appeared in the same block.
nonces[_keyHash] = nonces[_keyHash] + 1;
return makeRequestId(_keyHash, vRFSeed);
}
LinkTokenInterface immutable internal LINK;
address immutable private vrfCoordinator;
// Nonces for each VRF key from which randomness has been requested.
//
// Must stay in sync with VRFCoordinator[_keyHash][this]
mapping(bytes32 /* keyHash */ => uint256 /* nonce */) private nonces;
/**
* @param _vrfCoordinator address of VRFCoordinator contract
* @param _link address of LINK token contract
*
* @dev https://docs.chain.link/docs/link-token-contracts
*/
constructor(
address _vrfCoordinator,
address _link
) {
vrfCoordinator = _vrfCoordinator;
LINK = LinkTokenInterface(_link);
}
// rawFulfillRandomness is called by VRFCoordinator when it receives a valid VRF
// proof. rawFulfillRandomness then calls fulfillRandomness, after validating
// the origin of the call
function rawFulfillRandomness(
bytes32 requestId,
uint256 randomness
)
external
{
require(msg.sender == vrfCoordinator, "Only VRFCoordinator can fulfill");
fulfillRandomness(requestId, randomness);
}
}
VRFRequestIDBase.sol 56 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract VRFRequestIDBase {
/**
* @notice returns the seed which is actually input to the VRF coordinator
*
* @dev To prevent repetition of VRF output due to repetition of the
* @dev user-supplied seed, that seed is combined in a hash with the
* @dev user-specific nonce, and the address of the consuming contract. The
* @dev risk of repetition is mostly mitigated by inclusion of a blockhash in
* @dev the final seed, but the nonce does protect against repetition in
* @dev requests which are included in a single block.
*
* @param _userSeed VRF seed input provided by user
* @param _requester Address of the requesting contract
* @param _nonce User-specific nonce at the time of the request
*/
function makeVRFInputSeed(
bytes32 _keyHash,
uint256 _userSeed,
address _requester,
uint256 _nonce
)
internal
pure
returns (
uint256
)
{
return uint256(keccak256(abi.encode(_keyHash, _userSeed, _requester, _nonce)));
}
/**
* @notice Returns the id for this request
* @param _keyHash The serviceAgreement ID to be used for this request
* @param _vRFInputSeed The seed to be passed directly to the VRF
* @return The id for this request
*
* @dev Note that _vRFInputSeed is not the seed passed by the consuming
* @dev contract, but the one generated by makeVRFInputSeed
*/
function makeRequestId(
bytes32 _keyHash,
uint256 _vRFInputSeed
)
internal
pure
returns (
bytes32
)
{
return keccak256(abi.encodePacked(_keyHash, _vRFInputSeed));
}
}
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);
}
RandomlyAssigned.sol 62 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./WithLimitedSupply.sol";
/// @author 1001.digital
/// @title Randomly assign tokenIDs from a given set of tokens.
abstract contract RandomlyAssigned is WithLimitedSupply {
// Used for random index assignment
mapping(uint256 => uint256) private tokenMatrix;
// The initial token ID
uint256 private startFrom;
/// Instanciate the contract
/// @param _totalSupply how many tokens this collection should hold
/// @param _startFrom the tokenID with which to start counting
constructor (uint256 _totalSupply, uint256 _startFrom)
WithLimitedSupply(_totalSupply)
{
startFrom = _startFrom;
}
/// Get the next token ID
/// @dev Randomly gets a new token ID and keeps track of the ones that are still available.
/// @return the next token ID
function nextToken() internal override ensureAvailability returns (uint256) {
uint256 maxIndex = totalSupply() - tokenCount();
uint256 random = uint256(keccak256(
abi.encodePacked(
msg.sender,
block.coinbase,
block.difficulty,
block.gaslimit,
block.timestamp
)
)) % maxIndex;
uint256 value = 0;
if (tokenMatrix[random] == 0) {
// If this matrix position is empty, set the value to the generated random number.
value = random;
} else {
// Otherwise, use the previously stored number from the matrix.
value = tokenMatrix[random];
}
// If the last available tokenID is still unused...
if (tokenMatrix[maxIndex - 1] == 0) {
// ...store that ID in the current matrix position.
tokenMatrix[random] = maxIndex - 1;
} else {
// ...otherwise copy over the stored number to the current matrix position.
tokenMatrix[random] = tokenMatrix[maxIndex - 1];
}
// Increment counts
super.nextToken();
return value + startFrom;
}
}
WithLimitedSupply.sol 63 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/utils/Counters.sol";
/// @author 1001.digital
/// @title A token tracker that limits the token supply and increments token IDs on each new mint.
abstract contract WithLimitedSupply {
using Counters for Counters.Counter;
// Keeps track of how many we have minted
Counters.Counter private _tokenCount;
/// @dev The maximum count of tokens this token tracker will hold.
uint256 private _totalSupply;
/// Instanciate the contract
/// @param totalSupply_ how many tokens this collection should hold
constructor (uint256 totalSupply_) {
_totalSupply = totalSupply_;
}
/// @dev Get the max Supply
/// @return the maximum token count
function totalSupply() public view returns (uint256) {
return _totalSupply;
}
/// @dev Get the current token count
/// @return the created token count
function tokenCount() public view returns (uint256) {
return _tokenCount.current();
}
/// @dev Check whether tokens are still available
/// @return the available token count
function availableTokenCount() public view returns (uint256) {
return totalSupply() - tokenCount();
}
/// @dev Increment the token count and fetch the latest count
/// @return the next token id
function nextToken() internal virtual ensureAvailability returns (uint256) {
uint256 token = _tokenCount.current();
_tokenCount.increment();
return token;
}
/// @dev Check whether another token is still available
modifier ensureAvailability() {
require(availableTokenCount() > 0, "No more tokens available");
_;
}
/// @param amount Check whether number of tokens are still available
/// @dev Check whether tokens are still available
modifier ensureAvailabilityFor(uint256 amount) {
require(availableTokenCount() >= amount, "Requested number of tokens not available");
_;
}
}
LinkTokenInterface.sol 105 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
interface LinkTokenInterface {
function allowance(
address owner,
address spender
)
external
view
returns (
uint256 remaining
);
function approve(
address spender,
uint256 value
)
external
returns (
bool success
);
function balanceOf(
address owner
)
external
view
returns (
uint256 balance
);
function decimals()
external
view
returns (
uint8 decimalPlaces
);
function decreaseApproval(
address spender,
uint256 addedValue
)
external
returns (
bool success
);
function increaseApproval(
address spender,
uint256 subtractedValue
) external;
function name()
external
view
returns (
string memory tokenName
);
function symbol()
external
view
returns (
string memory tokenSymbol
);
function totalSupply()
external
view
returns (
uint256 totalTokensIssued
);
function transfer(
address to,
uint256 value
)
external
returns (
bool success
);
function transferAndCall(
address to,
uint256 value,
bytes calldata data
)
external
returns (
bool success
);
function transferFrom(
address from,
address to,
uint256 value
)
external
returns (
bool success
);
}
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);
}
ERC721URIStorage.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/ERC721URIStorage.sol)
pragma solidity ^0.8.0;
import "../ERC721.sol";
/**
* @dev ERC721 token with storage based token URI management.
*/
abstract contract ERC721URIStorage is ERC721 {
using Strings for uint256;
// Optional mapping for token URIs
mapping(uint256 => string) private _tokenURIs;
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721URIStorage: URI query for nonexistent token");
string memory _tokenURI = _tokenURIs[tokenId];
string memory base = _baseURI();
// If there is no base URI, return the token URI.
if (bytes(base).length == 0) {
return _tokenURI;
}
// If both are set, concatenate the baseURI and tokenURI (via abi.encodePacked).
if (bytes(_tokenURI).length > 0) {
return string(abi.encodePacked(base, _tokenURI));
}
return super.tokenURI(tokenId);
}
/**
* @dev Sets `_tokenURI` as the tokenURI of `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal virtual {
require(_exists(tokenId), "ERC721URIStorage: URI set of nonexistent token");
_tokenURIs[tokenId] = _tokenURI;
}
/**
* @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 override {
super._burn(tokenId);
if (bytes(_tokenURIs[tokenId]).length != 0) {
delete _tokenURIs[tokenId];
}
}
}
Read Contract
availableTokenCount 0xe14ca353 → uint256
balanceOf 0x70a08231 → uint256
baseExtension 0xc6682862 → string
baseURI 0x6c0360eb → string
checkFirstWinner 0x580684e2 → bool, uint256
checkSecondWinner 0x51c55755 → bool, uint256
checkWhitelistWinner 0xe0d988a3 → bool, uint256
ethBalance 0x4e6630b0 → uint256
firstWinnerList 0x1f7b8125 → bool
firstWinnerListClaimed 0xc252d4f9 → uint256
firstWinnerMetadataShuffleRandomResult 0x9ce60b83 → uint256
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
linkBalance 0xc26ecefa → uint256
maxSupply 0xd5abeb01 → uint256
maxTeamSupply 0x4b2596c7 → uint256
maxWhitelistSupply 0x953f049d → uint256
mintStatus 0x9da3f8fd → bool
mintWhitelistStatus 0x61c4be55 → bool
name 0x06fdde03 → string
notRevealedURI 0x72250380 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
provenanceHash 0xc6ab67a3 → string
revealed 0x51830227 → bool
salePrice 0xf51f96dd → uint256
secondSale 0x81b724ba → bool
secondWinnerList 0x779ab8a0 → bool
secondWinnerListClaimed 0xa3be8a78 → uint256
secondWinnerMetadataShuffleRandomResult 0x1a8fd975 → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
teamSupplyMinted 0x8738bb11 → uint256
tokenCount 0x9f181b5e → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
whiteList 0x372c12b1 → bool
whiteListClaimed 0x2333f3c4 → uint256
whitelistSupplyMinted 0x4f943192 → uint256
Write Contract 27 functions
These functions modify contract state and require a wallet transaction to execute.
addWhiteList 0xa0d41d9f
address[] addresses
uint256[] mintcount
addWinnerList 0xe637dc82
address[] addresses
uint256[] mintcount
approve 0x095ea7b3
address to
uint256 tokenId
burnTorix 0x1759dcd5
uint256 tokenId
getRandomNumber 0xdbdff2c1
No parameters
returns: bytes32
mintOwnerTorix 0x70f185a0
uint256 mintcount
mintTeamTorix 0x98e049b5
address[] addresses
uint256[] mintcount
mintTorix 0xe183fa6b
No parameters
mintWhitelistTorix 0x06fbe2c1
uint256 mintcount
notReveal 0x7d59946f
No parameters
onSecondSale 0x86a7a38c
No parameters
rawFulfillRandomness 0x94985ddd
bytes32 requestId
uint256 randomness
removeWhiteList 0x39745791
address[] addresses
removeWinnerList 0x23e3fff3
address[] addresses
renounceOwnership 0x715018a6
No parameters
reveal 0xa475b5dd
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
setBaseURI 0x55f804b3
string _newBaseURI
setNotRevealedURI 0xf2c4ce1e
string _notRevealedURI
toggleMintable 0xeccfa9fb
bool _mintStatus
toggleWhitelistMintable 0x096cf171
bool _mintWhitelistStatus
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
withdrawETH 0xe086e5ec
No parameters
withdrawLINK 0xadc2112f
No parameters
Recent Transactions
No transactions found for this address