Address Contract Verified
Address
0xa5A1E6972aCE6f4Ae388FBAFcb7ec12013b64f53
Balance
0.744000 ETH ($1468.06)
Nonce
1
Code Size
14004 bytes
Creator
0xeF1c6778...792B at tx 0x1878f165...eb56cb
Indexed Transactions
0
Contract Bytecode
14004 bytes
0x60806040526004361061030c5760003560e01c80636c0360eb1161019a578063a22cb465116100e1578063d5abeb011161008a578063e33b7de311610064578063e33b7de314610890578063e985e9c5146108a5578063f2fde38b146108ee57600080fd5b8063d5abeb0114610846578063e228c6fe1461085b578063e27c429c1461087057600080fd5b8063c87b56dd116100bb578063c87b56dd146107d0578063ce7c2ac2146107f0578063cfb00c6d1461082657600080fd5b8063a22cb46514610770578063b88d4fde14610790578063c865815b146107b057600080fd5b806388c025ec1161014357806395d89b411161011d57806395d89b41146107055780639852595c1461071a5780639a48eb511461075057600080fd5b806388c025ec146106b45780638b83209b146106c75780638da5cb5b146106e757600080fd5b8063715018a611610174578063715018a614610673578063722d185314610688578063815c5fd41461069e57600080fd5b80636c0360eb1461061e578063709b00ae1461063357806370a082311461065357600080fd5b80633732ad1c1161025e5780634f777803116102075780636352211e116101e15780636352211e146105c957806366e590e4146105e95780636ac437b01461060957600080fd5b80634f7778031461057457806355f804b31461059457806360d938dc146105b457600080fd5b806342842e0e1161023857806342842e0e146105215780634f459936146105415780634f6ccce71461055457600080fd5b80633732ad1c146104e457806338d1787f146104f95780633a98ef391461050c57600080fd5b80630cbb5df5116102c057806323b872dd1161029a57806323b872dd1461048e5780632f745c59146104ae57806336daaea4146104ce57600080fd5b80630cbb5df51461043957806318160ddd14610459578063191655871461046e57600080fd5b8063070c9a8a116102f1578063070c9a8a146103b1578063081812fc146103df578063095ea7b31461041757600080fd5b806301ffc9a71461035a57806306fdde031461038f57600080fd5b36610355577f6ef95f06320e7a25a04a175ca677b7052bdd97131872c2192525a629f51be77033604080516001600160a01b0390921682523460208301520160405180910390a1005b600080fd5b34801561036657600080fd5b5061037a610375366004612f38565b61090e565b60405190151581526020015b60405180910390f35b34801561039b57600080fd5b506103a46109df565b6040516103869190612fad565b3480156103bd57600080fd5b506103d16103cc366004612fd5565b610a71565b604051908152602001610386565b3480156103eb57600080fd5b506103ff6103fa366004612ff2565b610a8f565b6040516001600160a01b039091168152602001610386565b34801561042357600080fd5b5061043761043236600461300b565b610b2f565b005b34801561044557600080fd5b506103d1610454366004612fd5565b610c62565b34801561046557600080fd5b506002546103d1565b34801561047a57600080fd5b50610437610489366004612fd5565b610c6d565b34801561049a57600080fd5b506104376104a9366004613037565b610cd3565b3480156104ba57600080fd5b506103d16104c936600461300b565b610cde565b3480156104da57600080fd5b506103d160125481565b3480156104f057600080fd5b5061037a610e70565b6104376105073660046130c4565b610e86565b34801561051857600080fd5b506009546103d1565b34801561052d57600080fd5b5061043761053c366004613037565b610fe8565b61043761054f366004612ff2565b611003565b34801561056057600080fd5b506103d161056f366004612ff2565b6111af565b34801561058057600080fd5b5061043761058f366004613157565b611232565b3480156105a057600080fd5b506104376105af366004613267565b61131a565b3480156105c057600080fd5b5061037a61138b565b3480156105d557600080fd5b506103ff6105e4366004612ff2565b61139c565b3480156105f557600080fd5b506104376106043660046132c5565b6113ae565b34801561061557600080fd5b5061037a611466565b34801561062a57600080fd5b506103a4611477565b34801561063f57600080fd5b5061037a61064e366004613324565b611505565b34801561065f57600080fd5b506103d161066e366004612fd5565b611577565b34801561067f57600080fd5b50610437611623565b34801561069457600080fd5b506103d160115481565b3480156106aa57600080fd5b506103d160105481565b6104376106c23660046130c4565b611689565b3480156106d357600080fd5b506103ff6106e2366004612ff2565b6117e1565b3480156106f357600080fd5b50600e546001600160a01b03166103ff565b34801561071157600080fd5b506103a4611811565b34801561072657600080fd5b506103d1610735366004612fd5565b6001600160a01b03166000908152600c602052604090205490565b34801561075c57600080fd5b5061043761076b366004613381565b611820565b34801561077c57600080fd5b5061043761078b3660046133a3565b61189a565b34801561079c57600080fd5b506104376107ab3660046133d8565b61195f565b3480156107bc57600080fd5b5061037a6107cb366004613458565b6119ee565b3480156107dc57600080fd5b506103a46107eb366004612ff2565b611a4c565b3480156107fc57600080fd5b506103d161080b366004612fd5565b6001600160a01b03166000908152600b602052604090205490565b34801561083257600080fd5b506103d161084136600461300b565b611b34565b34801561085257600080fd5b506127106103d1565b34801561086757600080fd5b50610437611b86565b34801561087c57600080fd5b506103d161088b366004612fd5565b611b8f565b34801561089c57600080fd5b50600a546103d1565b3480156108b157600080fd5b5061037a6108c03660046134af565b6001600160a01b03918216600090815260086020908152604080832093909416825291909152205460ff1690565b3480156108fa57600080fd5b50610437610909366004612fd5565b611bcf565b60006001600160e01b031982167f80ac58cd00000000000000000000000000000000000000000000000000000000148061097157506001600160e01b031982167f5b5e139f00000000000000000000000000000000000000000000000000000000145b806109a557506001600160e01b031982167f780e9d6300000000000000000000000000000000000000000000000000000000145b806109d957507f01ffc9a7000000000000000000000000000000000000000000000000000000006001600160e01b03198316145b92915050565b6060600380546109ee906134e8565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1a906134e8565b8015610a675780601f10610a3c57610100808354040283529160200191610a67565b820191906000526020600020905b815481529060010190602001808311610a4a57829003601f168201915b5050505050905090565b6001600160a01b0381166000908152601760205260408120546109d9565b6000610a9c826002541190565b610b135760405162461bcd60e51b815260206004820152602d60248201527f455243373231413a20617070726f76656420717565727920666f72206e6f6e6560448201527f78697374656e7420746f6b656e0000000000000000000000000000000000000060648201526084015b60405180910390fd5b506000908152600760205260409020546001600160a01b031690565b6000610b3a8261139c565b9050806001600160a01b0316836001600160a01b03161415610bc45760405162461bcd60e51b815260206004820152602260248201527f455243373231413a20617070726f76616c20746f2063757272656e74206f776e60448201527f65720000000000000000000000000000000000000000000000000000000000006064820152608401610b0a565b336001600160a01b0382161480610be05750610be081336108c0565b610c525760405162461bcd60e51b815260206004820152603960248201527f455243373231413a20617070726f76652063616c6c6572206973206e6f74206f60448201527f776e6572206e6f7220617070726f76656420666f7220616c6c000000000000006064820152608401610b0a565b610c5d838383611cae565b505050565b60006109d982611d17565b600e546001600160a01b03163314610cc75760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b0a565b610cd081611dd7565b50565b610c5d838383611fb1565b6000610ce983611577565b8210610d5d5760405162461bcd60e51b815260206004820152602260248201527f455243373231413a206f776e657220696e646578206f7574206f6620626f756e60448201527f64730000000000000000000000000000000000000000000000000000000000006064820152608401610b0a565b6000610d6860025490565b905060008060005b83811015610e01576000818152600560209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff169183019190915215610dc357805192505b876001600160a01b0316836001600160a01b03161415610df85786841415610df1575093506109d992505050565b6001909301925b50600101610d70565b5060405162461bcd60e51b815260206004820152602e60248201527f455243373231413a20756e61626c6520746f2067657420746f6b656e206f662060448201527f6f776e657220627920696e6465780000000000000000000000000000000000006064820152608401610b0a565b601454600090610e819060016122e2565b905090565b6002600f541415610ed95760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b0a565b6002600f55601454610eec9060016122e2565b610f385760405162461bcd60e51b815260206004820152601060248201527f436c61696d696e672073746f70706564000000000000000000000000000000006044820152606401610b0a565b806000108015610f49575060328111155b610f855760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a590818dbdd5b9d609a1b6044820152606401610b0a565b80601054610f939190613539565b341015610fd25760405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420707269636560981b6044820152606401610b0a565b610fde33848484612303565b50506001600f5550565b610c5d8383836040518060200160405280600081525061195f565b6002600f5414156110565760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b0a565b6002600f553233146110aa5760405162461bcd60e51b815260206004820152600c60248201527f4d757374206265207573657200000000000000000000000000000000000000006044820152606401610b0a565b6014546110b89060036122e2565b6111045760405162461bcd60e51b815260206004820152600f60248201527f4d696e74696e672073746f7070656400000000000000000000000000000000006044820152606401610b0a565b806000108015611115575060148111155b6111515760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a590818dbdd5b9d609a1b6044820152606401610b0a565b34816012546111609190613539565b1461119d5760405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420707269636560981b6044820152606401610b0a565b6111a733826123cf565b506001600f55565b60006111ba60025490565b821061122e5760405162461bcd60e51b815260206004820152602360248201527f455243373231413a20676c6f62616c20696e646578206f7574206f6620626f7560448201527f6e647300000000000000000000000000000000000000000000000000000000006064820152608401610b0a565b5090565b600e546001600160a01b0316331461128c5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b0a565b80600010801561129d575060328111155b6112d95760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a590818dbdd5b9d609a1b6044820152606401610b0a565b60005b8251811015610c5d576113088382815181106112fa576112fa613558565b6020026020010151836123cf565b806113128161356e565b9150506112dc565b600e546001600160a01b031633146113745760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b0a565b8051611387906013906020840190612e92565b5050565b601454600090610e819060026122e2565b60006113a78261243e565b5192915050565b600e546001600160a01b031633146114085760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b0a565b600061141681600189612528565b905061142481600288612528565b905061143281600387612528565b6014819055905083156114455760108490555b82156114515760118390555b811561145d5760128290555b50505050505050565b601454600090610e819060036122e2565b60138054611484906134e8565b80601f01602080910402602001604051908101604052809291908181526020018280546114b0906134e8565b80156114fd5780601f106114d2576101008083540402835291602001916114fd565b820191906000526020600020905b8154815290600101906020018083116114e057829003601f168201915b505050505081565b600061156c858561156286866040516bffffffffffffffffffffffff19606084901b166020820152605f60f81b60348201526035810182905260009060550160405160208183030381529060405280519060200120905092915050565b6015929190612551565b90505b949350505050565b60006001600160a01b0382166115f55760405162461bcd60e51b815260206004820152602b60248201527f455243373231413a2062616c616e636520717565727920666f7220746865207a60448201527f65726f20616464726573730000000000000000000000000000000000000000006064820152608401610b0a565b506001600160a01b03166000908152600660205260409020546fffffffffffffffffffffffffffffffff1690565b600e546001600160a01b0316331461167d5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b0a565b6116876000612562565b565b6002600f5414156116dc5760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610b0a565b6002600f8190556014546116ef916122e2565b61173b5760405162461bcd60e51b815260206004820152600f60248201527f50726573616c652073746f7070656400000000000000000000000000000000006044820152606401610b0a565b80600010801561174c575060028111155b6117885760405162461bcd60e51b815260206004820152600d60248201526c125b9d985b1a590818dbdd5b9d609a1b6044820152606401610b0a565b806011546117969190613539565b3410156117d55760405162461bcd60e51b815260206004820152600d60248201526c496e76616c696420707269636560981b6044820152606401610b0a565b610fde338484846125c1565b6000600d82815481106117f6576117f6613558565b6000918252602090912001546001600160a01b031692915050565b6060600480546109ee906134e8565b600e546001600160a01b0316331461187a5760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b0a565b811561188a5761188a6015839055565b8115611387576113876016829055565b6001600160a01b0382163314156118f35760405162461bcd60e51b815260206004820152601a60248201527f455243373231413a20617070726f766520746f2063616c6c65720000000000006044820152606401610b0a565b3360008181526008602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b61196a848484611fb1565b611976848484846126d6565b6119e85760405162461bcd60e51b815260206004820152603360248201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260448201527f6563656976657220696d706c656d656e746572000000000000000000000000006064820152608401610b0a565b50505050565b6000611a428484611a38856040516bffffffffffffffffffffffff19606083901b166020820152600090603401604051602081830303815290604052805190602001209050919050565b6016929190612551565b90505b9392505050565b6060611a59826002541190565b611aa55760405162461bcd60e51b815260206004820152600860248201527f4e6f20746f6b656e0000000000000000000000000000000000000000000000006044820152606401610b0a565b6000611aaf612827565b90506000815111611b025760405162461bcd60e51b815260206004820152600a60248201527f4261736520756e736574000000000000000000000000000000000000000000006044820152606401610b0a565b80611b0c84612836565b604051602001611b1d929190613589565b604051602081830303815290604052915050919050565b60408051606084901b6bffffffffffffffffffffffff1916602080830191909152605f60f81b603483015260358083018590528351808403909101815260559092019092528051910120600090611a45565b61168733611dd7565b60408051606083901b6bffffffffffffffffffffffff191660208083019190915282516014818403018152603490920190925280519101206000906109d9565b600e546001600160a01b03163314611c295760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610b0a565b6001600160a01b038116611ca55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201527f64647265737300000000000000000000000000000000000000000000000000006064820152608401610b0a565b610cd081612562565b600082815260076020526040808220805473ffffffffffffffffffffffffffffffffffffffff19166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b60006001600160a01b038216611d955760405162461bcd60e51b815260206004820152603160248201527f455243373231413a206e756d626572206d696e74656420717565727920666f7260448201527f20746865207a65726f20616464726573730000000000000000000000000000006064820152608401610b0a565b506001600160a01b031660009081526006602052604090205470010000000000000000000000000000000090046fffffffffffffffffffffffffffffffff1690565b6001600160a01b0381166000908152600b6020526040902054611e625760405162461bcd60e51b815260206004820152602660248201527f5061796d656e7453706c69747465723a206163636f756e7420686173206e6f2060448201527f73686172657300000000000000000000000000000000000000000000000000006064820152608401610b0a565b6000611e6d600a5490565b611e7790476135b8565b90506000611ea48383611e9f866001600160a01b03166000908152600c602052604090205490565b612841565b905080611f195760405162461bcd60e51b815260206004820152602b60248201527f5061796d656e7453706c69747465723a206163636f756e74206973206e6f742060448201527f647565207061796d656e740000000000000000000000000000000000000000006064820152608401610b0a565b6001600160a01b0383166000908152600c602052604081208054839290611f419084906135b8565b9250508190555080600a6000828254611f5a91906135b8565b90915550611f6a9050838261287f565b604080516001600160a01b0385168152602081018390527fdf20fd1e76bc69d672e4814fafb2c449bba3a5369d8359adf9e05e6fde87b056910160405180910390a1505050565b6000611fbc8261243e565b80519091506000906001600160a01b0316336001600160a01b03161480611ff3575033611fe884610a8f565b6001600160a01b0316145b806120055750815161200590336108c0565b90508061207a5760405162461bcd60e51b815260206004820152603260248201527f455243373231413a207472616e736665722063616c6c6572206973206e6f742060448201527f6f776e6572206e6f7220617070726f76656400000000000000000000000000006064820152608401610b0a565b846001600160a01b031682600001516001600160a01b0316146121055760405162461bcd60e51b815260206004820152602660248201527f455243373231413a207472616e736665722066726f6d20696e636f727265637460448201527f206f776e657200000000000000000000000000000000000000000000000000006064820152608401610b0a565b6001600160a01b0384166121815760405162461bcd60e51b815260206004820152602560248201527f455243373231413a207472616e7366657220746f20746865207a65726f20616460448201527f64726573730000000000000000000000000000000000000000000000000000006064820152608401610b0a565b6121916000848460000151611cae565b6001600160a01b03858116600090815260066020908152604080832080546fffffffffffffffffffffffffffffffff198082166fffffffffffffffffffffffffffffffff928316600019018316179092558986168086528386208054938416938316600190810190931693909317909255888552600590935281842080546001600160e01b031916909117600160a01b4267ffffffffffffffff16021790559086018083529120549091166122985761224b816002541190565b15612298578251600082815260056020908152604090912080549186015167ffffffffffffffff16600160a01b026001600160e01b03199092166001600160a01b03909316929092171790555b5082846001600160a01b0316866001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b5050505050565b6000600183831c81169081146122f957600061156f565b6001949350505050565b61237d8383611562876001866123188b611d17565b61232291906135b8565b61232c91906135d0565b6040516bffffffffffffffffffffffff19606084901b166020820152605f60f81b60348201526035810182905260009060550160405160208183030381529060405280519060200120905092915050565b6123c95760405162461bcd60e51b815260206004820152601760248201527f50726f6f6620696e76616c696420666f7220636c61696d0000000000000000006044820152606401610b0a565b6119e884825b612710816123dc60025490565b6123e691906135b8565b11156124345760405162461bcd60e51b815260206004820152600e60248201527f4c696d69742065786365656465640000000000000000000000000000000000006044820152606401610b0a565b6113878282612998565b604080518082019091526000808252602082015261245d826002541190565b6124cf5760405162461bcd60e51b815260206004820152602a60248201527f455243373231413a206f776e657220717565727920666f72206e6f6e6578697360448201527f74656e7420746f6b656e000000000000000000000000000000000000000000006064820152608401610b0a565b815b6000818152600560209081526040918290208251808401909352546001600160a01b038116808452600160a01b90910467ffffffffffffffff16918301919091521561251e579392505050565b50600019016124d1565b6000811561254057506001821b929092179182611a45565b506001821b19929092169182611a45565b835460009061156c908585856129b2565b600e80546001600160a01b0383811673ffffffffffffffffffffffffffffffffffffffff19831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b6126098383611a38876040516bffffffffffffffffffffffff19606083901b166020820152600090603401604051602081830303815290604052805190602001209050919050565b6126555760405162461bcd60e51b815260206004820152601960248201527f50726f6f6620696e76616c696420666f722070726573616c65000000000000006044820152606401610b0a565b6001600160a01b03841660009081526017602052604090205460029061267c9083906135b8565b11156126ca5760405162461bcd60e51b815260206004820152601e60248201527f52657175657374696e6720746f6f206d616e7920696e2070726573616c6500006044820152606401610b0a565b6123c9601785836129f6565b60006001600160a01b0384163b1561281f57604051630a85bd0160e11b81526001600160a01b0385169063150b7a029061271a9033908990889088906004016135e7565b6020604051808303816000875af1925050508015612755575060408051601f3d908101601f1916820190925261275291810190613623565b60015b612805573d808015612783576040519150601f19603f3d011682016040523d82523d6000602084013e612788565b606091505b5080516127fd5760405162461bcd60e51b815260206004820152603360248201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260448201527f6563656976657220696d706c656d656e746572000000000000000000000000006064820152608401610b0a565b805181602001fd5b6001600160e01b031916630a85bd0160e11b14905061156f565b50600161156f565b6060601380546109ee906134e8565b60606109d982612a28565b6009546001600160a01b0384166000908152600b60205260408120549091839161286b9086613539565b6128759190613656565b611a4291906135d0565b804710156128cf5760405162461bcd60e51b815260206004820152601d60248201527f416464726573733a20696e73756666696369656e742062616c616e63650000006044820152606401610b0a565b6000826001600160a01b03168260405160006040518083038185875af1925050503d806000811461291c576040519150601f19603f3d011682016040523d82523d6000602084013e612921565b606091505b5050905080610c5d5760405162461bcd60e51b815260206004820152603a60248201527f416464726573733a20756e61626c6520746f2073656e642076616c75652c207260448201527f6563697069656e74206d617920686176652072657665727465640000000000006064820152608401610b0a565b611387828260405180602001604052806000815250612b5a565b600061156c8583868680806020026020016040519081016040528093929190818152602001838360200280828437600092019190915250929493925050612b679050565b6001600160a01b03821660009081526020849052604081208054839290612a1e9084906135b8565b9091555050505050565b606081612a6857505060408051808201909152600181527f3000000000000000000000000000000000000000000000000000000000000000602082015290565b8160005b8115612a925780612a7c8161356e565b9150612a8b9050600a83613656565b9150612a6c565b60008167ffffffffffffffff811115612aad57612aad613110565b6040519080825280601f01601f191660200182016040528015612ad7576020820181803683370190505b5090505b841561156f57612aec6001836135d0565b9150612af9600a8661366a565b612b049060306135b8565b60f81b818381518110612b1957612b19613558565b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350612b53600a86613656565b9450612adb565b610c5d8383836001612b7d565b600082612b748584612de6565b14949350505050565b6002546001600160a01b038516612bfc5760405162461bcd60e51b815260206004820152602160248201527f455243373231413a206d696e7420746f20746865207a65726f2061646472657360448201527f73000000000000000000000000000000000000000000000000000000000000006064820152608401610b0a565b83612c6f5760405162461bcd60e51b815260206004820152602860248201527f455243373231413a207175616e74697479206d7573742062652067726561746560448201527f72207468616e20300000000000000000000000000000000000000000000000006064820152608401610b0a565b6001600160a01b038516600081815260066020908152604080832080547001000000000000000000000000000000006fffffffffffffffffffffffffffffffff1982166fffffffffffffffffffffffffffffffff9283168c01831690811782900483168c01909216021790558483526005909152812080546001600160e01b031916909217600160a01b4267ffffffffffffffff16021790915581905b85811015612ddd5760405182906001600160a01b038916906000907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef908290a48315612dd157612d5f60008884886126d6565b612dd15760405162461bcd60e51b815260206004820152603360248201527f455243373231413a207472616e7366657220746f206e6f6e204552433732315260448201527f6563656976657220696d706c656d656e746572000000000000000000000000006064820152608401610b0a565b60019182019101612d0c565b506002556122db565b600081815b8451811015612e8a576000858281518110612e0857612e08613558565b60200260200101519050808311612e4a576040805160208101859052908101829052606001604051602081830303815290604052805190602001209250612e77565b60408051602081018390529081018490526060016040516020818303038152906040528051906020012092505b5080612e828161356e565b915050612deb565b509392505050565b828054612e9e906134e8565b90600052602060002090601f016020900481019282612ec05760008555612f06565b82601f10612ed957805160ff1916838001178555612f06565b82800160010185558215612f06579182015b82811115612f06578251825591602001919060010190612eeb565b5061122e9291505b8082111561122e5760008155600101612f0e565b6001600160e01b031981168114610cd057600080fd5b600060208284031215612f4a57600080fd5b8135611a4581612f22565b60005b83811015612f70578181015183820152602001612f58565b838111156119e85750506000910152565b60008151808452612f99816020860160208601612f55565b601f01601f19169290920160200192915050565b602081526000611a456020830184612f81565b6001600160a01b0381168114610cd057600080fd5b600060208284031215612fe757600080fd5b8135611a4581612fc0565b60006020828403121561300457600080fd5b5035919050565b6000806040838503121561301e57600080fd5b823561302981612fc0565b946020939093013593505050565b60008060006060848603121561304c57600080fd5b833561305781612fc0565b9250602084013561306781612fc0565b929592945050506040919091013590565b60008083601f84011261308a57600080fd5b50813567ffffffffffffffff8111156130a257600080fd5b6020830191508360208260051b85010111156130bd57600080fd5b9250929050565b6000806000604084860312156130d957600080fd5b833567ffffffffffffffff8111156130f057600080fd5b6130fc86828701613078565b909790965060209590950135949350505050565b634e487b7160e01b600052604160045260246000fd5b604051601f8201601f1916810167ffffffffffffffff8111828210171561314f5761314f613110565b604052919050565b6000806040838503121561316a57600080fd5b823567ffffffffffffffff8082111561318257600080fd5b818501915085601f83011261319657600080fd5b81356020828211156131aa576131aa613110565b8160051b92506131bb818401613126565b82815292840181019281810190898511156131d557600080fd5b948201945b848610156131ff57853593506131ef84612fc0565b83825294820194908201906131da565b9997909101359750505050505050565b600067ffffffffffffffff83111561322957613229613110565b61323c601f8401601f1916602001613126565b905082815283838301111561325057600080fd5b828260208301376000602084830101529392505050565b60006020828403121561327957600080fd5b813567ffffffffffffffff81111561329057600080fd5b8201601f810184136132a157600080fd5b61156f8482356020840161320f565b803580151581146132c057600080fd5b919050565b60008060008060008060c087890312156132de57600080fd5b6132e7876132b0565b95506132f5602088016132b0565b9450613303604088016132b0565b9350606087013592506080870135915060a087013590509295509295509295565b6000806000806060858703121561333a57600080fd5b843567ffffffffffffffff81111561335157600080fd5b61335d87828801613078565b909550935050602085013561337181612fc0565b9396929550929360400135925050565b6000806040838503121561339457600080fd5b50508035926020909101359150565b600080604083850312156133b657600080fd5b82356133c181612fc0565b91506133cf602084016132b0565b90509250929050565b600080600080608085870312156133ee57600080fd5b84356133f981612fc0565b9350602085013561340981612fc0565b925060408501359150606085013567ffffffffffffffff81111561342c57600080fd5b8501601f8101871361343d57600080fd5b61344c8782356020840161320f565b91505092959194509250565b60008060006040848603121561346d57600080fd5b833567ffffffffffffffff81111561348457600080fd5b61349086828701613078565b90945092505060208401356134a481612fc0565b809150509250925092565b600080604083850312156134c257600080fd5b82356134cd81612fc0565b915060208301356134dd81612fc0565b809150509250929050565b600181811c908216806134fc57607f821691505b6020821081141561351d57634e487b7160e01b600052602260045260246000fd5b50919050565b634e487b7160e01b600052601160045260246000fd5b600081600019048311821515161561355357613553613523565b500290565b634e487b7160e01b600052603260045260246000fd5b600060001982141561358257613582613523565b5060010190565b6000835161359b818460208801612f55565b8351908301906135af818360208801612f55565b01949350505050565b600082198211156135cb576135cb613523565b500190565b6000828210156135e2576135e2613523565b500390565b60006001600160a01b038087168352808616602084015250836040830152608060608301526136196080830184612f81565b9695505050505050565b60006020828403121561363557600080fd5b8151611a4581612f22565b634e487b7160e01b600052601260045260246000fd5b60008261366557613665613640565b500490565b60008261367957613679613640565b50069056fea2646970667358221220ee6e09e397b61f68e2220dcf267f663cba4799f6f3b3870786528d6a4880f61464736f6c634300080b0033
Verified Source Code Full Match
Compiler: v0.8.11+commit.d7f03943
EVM: london
Optimization: Yes (1000 runs)
NoobPunks.sol 32 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import './NoobPunksBase.sol';
import './NoobPunksSplits.sol';
/**
* @title NOOBPUNKS wrapper contract
* __________
* _ _ / ___ ___\ ____ _____ _ _ _ _ _ __ _____
* | \ | |/ __ \ / __ \| _ \| __ \| | | | \ | | |/ // ____|
* | \| | | *| | | *| | |_) | |__) | | | | \| | ' /| (___
* | . ` | |__| | |__| | _ <| ___/| | | | . ` | < \___ \
* | |\ | | | |_) | | | |__| | |\ | . \ ____) |
* |_| \_|\____/ \____/|____/|_| \____/|_| \_|_|\_\_____/
* \__________/
*
* Credit to https://patorjk.com/ for text generator.
*/
contract NoobPunks is NoobPunksSplits, NoobPunksBase {
constructor()
NoobPunksBase(
'NOOBPUNKS',
'NBPKS',
'https://gateway.pinata.cloud/ipfs/Qmc9Ut3DUNhybDFWrGhrSfPttVH15HNCKErzhew8BkKL8V/', //pre-reveal v2
addresses,
splits
)
{
// Implementation version: 1
}
}
NoobPunksBase.sol 283 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
// NFTC Open Source Contracts See: https://github.com/NFTCulture/nftc-open-contracts
import '@nftculture/nftc-open-contracts/contracts/security/GuardedAgainstContracts.sol';
import '@nftculture/nftc-open-contracts/contracts/financial/LockedPaymentSplitter.sol';
// NFTC Prerelease Contracts
import '@nftculture/nftc-contract-library/contracts/whitelisting/MerkleLeaves.sol';
// NFTC Open Source Libraries See: https://github.com/NFTCulture/nftc-open-contracts
import {BooleanPacking} from '@nftculture/nftc-open-contracts/contracts/utility/BooleanPacking.sol';
// NFTC Prerelease Libraries
import {MerkleClaimList} from '@nftculture/nftc-contract-library/contracts/whitelisting/MerkleClaimList.sol';
import {WalletIndex} from '@nftculture/nftc-contract-library/contracts/whitelisting/WalletIndex.sol';
// ERC721A from Chiru Labs
import 'erc721a/contracts/ERC721A.sol';
// OZ Libraries
import '@openzeppelin/contracts/security/ReentrancyGuard.sol';
import '@openzeppelin/contracts/access/Ownable.sol';
import '@openzeppelin/contracts/finance/PaymentSplitter.sol';
/**
* @title NoobPunksBase
* @author @NiftyMike, NFT Culture
* @dev Standard ERC721A implementation
*
* NoobPunksBase is a straightforward ERC721A NFT contract, with both a claiming
* phase (free tokens) and a presale phase (paid tokens).
*
* In addition to using ERC721A, gas is optimized via Merkle Trees, boolean packing
* and use of constants where possible.
*
* Reusable functionality is packaged in included contracts:
* - GuardedAgainstContracts - an attempt to limit access to functions to user transactions
* - LockedPaymentSplitter - an reduced sized version of PaymentSplitter, with better access
* controls
* - MerkleLeaves - helper functionality for MerkleTrees
*
* And libraries:
* - BooleanPacking - for boolean packing, obviously :)
* - MerkleClaimList - a self contained basic MerkleTree implementation, that makes it easier
* to support multiple merkle trees in the same contract.
* - WalletIndex - a helper library for tracking indexes by wallet
*
* Visit the NFTC Labs open source repo on github:
* https://github.com/NFTCulture/nftc-open-contracts
*
* Pieces not available in the github are pre-release and will be added as time allows.
*/
abstract contract NoobPunksBase is
ERC721A,
Ownable,
GuardedAgainstContracts,
ReentrancyGuard,
LockedPaymentSplitter,
MerkleLeaves
{
using Strings for uint256;
using BooleanPacking for uint256;
using MerkleClaimList for MerkleClaimList.Root;
using WalletIndex for WalletIndex.Index;
uint256 private constant MAX_NFTS_FOR_SALE = 10000;
uint256 private constant MAX_CLAIM_BATCH_SIZE = 50;
uint256 private constant MAX_MINT_BATCH_SIZE = 20;
uint256 private constant PRESALE_QUANTITY = 2;
uint256 private constant CLAIMING_PHASE = 1;
uint256 private constant PRESALE_PHASE = 2;
uint256 private constant MINTING_PHASE = 3;
uint256 public claimPricePerNft;
uint256 public presalePricePerNft;
uint256 public mintPricePerNft;
string public baseURI;
// BooleanPacking used on mintControlFlags
uint256 private mintControlFlags;
MerkleClaimList.Root private _claimRoot;
MerkleClaimList.Root private _presaleRoot;
WalletIndex.Index private _presaleWalletIndexes;
constructor(
string memory __name,
string memory __symbol,
string memory __baseURI,
address[] memory __addresses,
uint256[] memory __splits
) ERC721A(__name, __symbol) SlimPaymentSplitter(__addresses, __splits) {
baseURI = __baseURI;
presalePricePerNft = 0.04 ether;
mintPricePerNft = 0.04 ether;
}
function setMintingState(
bool __claimingActive,
bool __presaleActive,
bool __mintingActive,
uint256 __claimPricePerNft,
uint256 __presalePricePerNft,
uint256 __mintPricePerNft
) external onlyOwner {
uint256 tempControlFlags;
tempControlFlags = tempControlFlags.setBoolean(CLAIMING_PHASE, __claimingActive);
tempControlFlags = tempControlFlags.setBoolean(PRESALE_PHASE, __presaleActive);
tempControlFlags = tempControlFlags.setBoolean(MINTING_PHASE, __mintingActive);
mintControlFlags = tempControlFlags;
if (__claimPricePerNft > 0) {
claimPricePerNft = __claimPricePerNft;
}
if (__presalePricePerNft > 0) {
presalePricePerNft = __presalePricePerNft;
}
if (__mintPricePerNft > 0) {
mintPricePerNft = __mintPricePerNft;
}
}
function isClaimingActive() external view returns (bool) {
return mintControlFlags.getBoolean(CLAIMING_PHASE);
}
function isPresaleActive() external view returns (bool) {
return mintControlFlags.getBoolean(PRESALE_PHASE);
}
function isMintingActive() external view returns (bool) {
return mintControlFlags.getBoolean(MINTING_PHASE);
}
function maxSupply() external pure returns (uint256) {
return MAX_NFTS_FOR_SALE;
}
function setBaseURI(string memory __baseUri) external onlyOwner {
baseURI = __baseUri;
}
function setMerkleRoots(bytes32 __claimRoot, bytes32 __presaleRoot) external onlyOwner {
if (__claimRoot != 0) {
_claimRoot._setRoot(__claimRoot);
}
if (__claimRoot != 0) {
_presaleRoot._setRoot(__presaleRoot);
}
}
function checkClaim(
bytes32[] calldata proof,
address wallet,
uint256 index
) external view returns (bool) {
return _claimRoot._checkLeaf(proof, _generateIndexedLeaf(wallet, index));
}
function getNextClaimIndex(address wallet) external view returns (uint256) {
return _numberMinted(wallet);
}
function checkPresale(bytes32[] calldata proof, address wallet) external view returns (bool) {
return _presaleRoot._checkLeaf(proof, _generateLeaf(wallet));
}
function getNextPresaleIndex(address wallet) external view returns (uint256) {
return _presaleWalletIndexes._getNextIndex(wallet);
}
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), 'No token');
string memory base = _baseURI();
require(bytes(base).length > 0, 'Base unset');
return string(abi.encodePacked(base, _tokenFilename(tokenId)));
}
/**
* @notice Owner: reserve NoobPunks for team.
*
* @param friends addresses to send NoobPunks to.
* @param count the number of NoobPunks to mint.
*/
function reservePunks(address[] memory friends, uint256 count) external onlyOwner {
require(0 < count && count <= MAX_CLAIM_BATCH_SIZE, 'Invalid count');
uint256 idx;
for (idx = 0; idx < friends.length; idx++) {
_internalMintTokens(friends[idx], count);
}
}
function claimPunks(bytes32[] calldata proof, uint256 count) external payable nonReentrant {
require(mintControlFlags.getBoolean(CLAIMING_PHASE), 'Claiming stopped');
require(0 < count && count <= MAX_CLAIM_BATCH_SIZE, 'Invalid count');
require(msg.value >= claimPricePerNft * count, 'Invalid price');
_claimPunks(_msgSender(), proof, count);
}
function presalePunks(bytes32[] calldata proof, uint256 count) external payable nonReentrant {
require(mintControlFlags.getBoolean(PRESALE_PHASE), 'Presale stopped');
require(0 < count && count <= PRESALE_QUANTITY, 'Invalid count');
require(msg.value >= presalePricePerNft * count, 'Invalid price');
_presalePunks(_msgSender(), proof, count);
}
/**
* @notice Mint NoobPunks - purchase bound by terms & conditions of project.
*
* @param count the number of NoobPunks to mint.
*/
function mintPunks(uint256 count) external payable nonReentrant onlyUsers {
require(mintControlFlags.getBoolean(MINTING_PHASE), 'Minting stopped');
require(0 < count && count <= MAX_MINT_BATCH_SIZE, 'Invalid count');
require(mintPricePerNft * count == msg.value, 'Invalid price');
_internalMintTokens(_msgSender(), count);
}
function _baseURI() internal view virtual override returns (string memory) {
return baseURI;
}
function _tokenFilename(uint256 tokenId) internal view virtual returns (string memory) {
return tokenId.toString();
}
function _claimPunks(
address minter,
bytes32[] calldata proof,
uint256 count
) internal {
// Verify proof matches expected target total number of claims.
require(
_claimRoot._checkLeaf(
proof,
_generateIndexedLeaf(minter, (_numberMinted(minter) + count) - 1) //Zero-based index.
),
'Proof invalid for claim'
);
_internalMintTokens(minter, count);
}
function _presalePunks(
address minter,
bytes32[] calldata proof,
uint256 count
) internal {
// Verify address is eligible for presale mints.
require(_presaleRoot._checkLeaf(proof, _generateLeaf(minter)), 'Proof invalid for presale');
// Has to be tracked indepedently for presale, since caller might have previously used claims.
require(
_presaleWalletIndexes._getNextIndex(minter) + count <= PRESALE_QUANTITY,
'Requesting too many in presale'
);
_presaleWalletIndexes._incrementIndex(minter, count);
_internalMintTokens(minter, count);
}
function _internalMintTokens(address minter, uint256 count) internal {
require(totalSupply() + count <= MAX_NFTS_FOR_SALE, 'Limit exceeded');
_safeMint(minter, count);
}
}
NoobPunksSplits.sol 14 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
contract NoobPunksSplits {
address[] internal addresses = [
0x063a48F3b73957b6d0640352525Eae313D4426c3,
0x5DA3e70F8Ce9C85b6Ccbdfe1430D452E68A7BCcc,
0x48b23c92Cd6E32DaeD6589428bD41804A5399884,
0xDbcB5606947783cc1dEac81Dee1F332E8767B767,
0x4474efe96982D38997B5BbF231EABB587201124E
];
uint256[] internal splits = [20, 20, 5, 40, 15];
}
ERC721A.sol 497 lines
// SPDX-License-Identifier: MIT
// Creator: Chiru Labs
pragma solidity ^0.8.0;
import '@openzeppelin/contracts/token/ERC721/IERC721.sol';
import '@openzeppelin/contracts/token/ERC721/IERC721Receiver.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol';
import '@openzeppelin/contracts/token/ERC721/extensions/IERC721Enumerable.sol';
import '@openzeppelin/contracts/utils/Address.sol';
import '@openzeppelin/contracts/utils/Context.sol';
import '@openzeppelin/contracts/utils/Strings.sol';
import '@openzeppelin/contracts/utils/introspection/ERC165.sol';
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata and Enumerable extension. Built to optimize for lower gas during batch mints.
*
* Assumes serials are sequentially minted starting at 0 (e.g. 0, 1, 2, 3..).
*
* Does not support burning tokens to address(0).
*
* Assumes that an owner cannot have more than the 2**128 - 1 (max value of uint128) of supply
*/
contract ERC721A is Context, ERC165, IERC721, IERC721Metadata, IERC721Enumerable {
using Address for address;
using Strings for uint256;
struct TokenOwnership {
address addr;
uint64 startTimestamp;
}
struct AddressData {
uint128 balance;
uint128 numberMinted;
}
uint256 internal currentIndex;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to ownership details
// An empty struct value does not necessarily mean the token is unowned. See ownershipOf implementation for details.
mapping(uint256 => TokenOwnership) internal _ownerships;
// Mapping owner address to address data
mapping(address => AddressData) private _addressData;
// 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;
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC721Enumerable-totalSupply}.
*/
function totalSupply() public view override returns (uint256) {
return currentIndex;
}
/**
* @dev See {IERC721Enumerable-tokenByIndex}.
*/
function tokenByIndex(uint256 index) public view override returns (uint256) {
require(index < totalSupply(), 'ERC721A: global index out of bounds');
return index;
}
/**
* @dev See {IERC721Enumerable-tokenOfOwnerByIndex}.
* This read function is O(totalSupply). If calling from a separate contract, be sure to test gas first.
* It may also degrade with extremely large collection sizes (e.g >> 10000), test for your use case.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) public view override returns (uint256) {
require(index < balanceOf(owner), 'ERC721A: owner index out of bounds');
uint256 numMintedSoFar = totalSupply();
uint256 tokenIdsIdx;
address currOwnershipAddr;
// Counter overflow is impossible as the loop breaks when uint256 i is equal to another uint256 numMintedSoFar.
unchecked {
for (uint256 i; i < numMintedSoFar; i++) {
TokenOwnership memory ownership = _ownerships[i];
if (ownership.addr != address(0)) {
currOwnershipAddr = ownership.addr;
}
if (currOwnershipAddr == owner) {
if (tokenIdsIdx == index) {
return i;
}
tokenIdsIdx++;
}
}
}
revert('ERC721A: unable to get token of owner by index');
}
/**
* @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 ||
interfaceId == type(IERC721Enumerable).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view override returns (uint256) {
require(owner != address(0), 'ERC721A: balance query for the zero address');
return uint256(_addressData[owner].balance);
}
function _numberMinted(address owner) internal view returns (uint256) {
require(owner != address(0), 'ERC721A: number minted query for the zero address');
return uint256(_addressData[owner].numberMinted);
}
/**
* Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around in the collection over time.
*/
function ownershipOf(uint256 tokenId) internal view returns (TokenOwnership memory) {
require(_exists(tokenId), 'ERC721A: owner query for nonexistent token');
unchecked {
for (uint256 curr = tokenId; curr >= 0; curr--) {
TokenOwnership memory ownership = _ownerships[curr];
if (ownership.addr != address(0)) {
return ownership;
}
}
}
revert('ERC721A: unable to determine the owner of token');
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view override returns (address) {
return ownershipOf(tokenId).addr;
}
/**
* @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 override {
address owner = ERC721A.ownerOf(tokenId);
require(to != owner, 'ERC721A: approval to current owner');
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
'ERC721A: approve caller is not owner nor approved for all'
);
_approve(to, tokenId, owner);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view override returns (address) {
require(_exists(tokenId), 'ERC721A: approved query for nonexistent token');
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public override {
require(operator != _msgSender(), 'ERC721A: approve to caller');
_operatorApprovals[_msgSender()][operator] = approved;
emit ApprovalForAll(_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 override {
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public override {
_transfer(from, to, tokenId);
require(
_checkOnERC721Received(from, to, tokenId, _data),
'ERC721A: 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`),
*/
function _exists(uint256 tokenId) internal view returns (bool) {
return tokenId < currentIndex;
}
function _safeMint(address to, uint256 quantity) internal {
_safeMint(to, quantity, '');
}
/**
* @dev Safely mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called for each safe transfer.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal {
_mint(to, quantity, _data, true);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {Transfer} event.
*/
function _mint(
address to,
uint256 quantity,
bytes memory _data,
bool safe
) internal {
uint256 startTokenId = currentIndex;
require(to != address(0), 'ERC721A: mint to the zero address');
require(quantity != 0, 'ERC721A: quantity must be greater than 0');
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// balance or numberMinted overflow if current value of either + quantity > 3.4e38 (2**128) - 1
// updatedIndex overflows if currentIndex + quantity > 1.56e77 (2**256) - 1
unchecked {
_addressData[to].balance += uint128(quantity);
_addressData[to].numberMinted += uint128(quantity);
_ownerships[startTokenId].addr = to;
_ownerships[startTokenId].startTimestamp = uint64(block.timestamp);
uint256 updatedIndex = startTokenId;
for (uint256 i; i < quantity; i++) {
emit Transfer(address(0), to, updatedIndex);
if (safe) {
require(
_checkOnERC721Received(address(0), to, updatedIndex, _data),
'ERC721A: transfer to non ERC721Receiver implementer'
);
}
updatedIndex++;
}
currentIndex = updatedIndex;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* 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
) private {
TokenOwnership memory prevOwnership = ownershipOf(tokenId);
bool isApprovedOrOwner = (_msgSender() == prevOwnership.addr ||
getApproved(tokenId) == _msgSender() ||
isApprovedForAll(prevOwnership.addr, _msgSender()));
require(isApprovedOrOwner, 'ERC721A: transfer caller is not owner nor approved');
require(prevOwnership.addr == from, 'ERC721A: transfer from incorrect owner');
require(to != address(0), 'ERC721A: transfer to the zero address');
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner
_approve(address(0), tokenId, prevOwnership.addr);
// Underflow of the sender's balance is impossible because we check for
// ownership above and the recipient's balance can't realistically overflow.
// Counter overflow is incredibly unrealistic as tokenId would have to be 2**256.
unchecked {
_addressData[from].balance -= 1;
_addressData[to].balance += 1;
_ownerships[tokenId].addr = to;
_ownerships[tokenId].startTimestamp = uint64(block.timestamp);
// If the ownership slot of tokenId+1 is not explicitly set, that means the transfer initiator owns it.
// Set the slot of tokenId+1 explicitly in storage to maintain correctness for ownerOf(tokenId+1) calls.
uint256 nextTokenId = tokenId + 1;
if (_ownerships[nextTokenId].addr == address(0)) {
if (_exists(nextTokenId)) {
_ownerships[nextTokenId].addr = prevOwnership.addr;
_ownerships[nextTokenId].startTimestamp = prevOwnership.startTimestamp;
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(
address to,
uint256 tokenId,
address owner
) private {
_tokenApprovals[tokenId] = to;
emit Approval(owner, to, tokenId);
}
/**
* @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(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert('ERC721A: transfer to non ERC721Receiver implementer');
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before a set of serially-ordered token ids are about to be transferred. This includes minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* 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`.
*/
function _beforeTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Hook that is called after a set of serially-ordered token ids have been transferred. This includes
* minting.
*
* startTokenId - the first token id to be transferred
* quantity - the amount to be transferred
*
* Calling conditions:
*
* - when `from` and `to` are both non-zero.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
}
Address.sol 217 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
Ownable.sol 76 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
interface IERC20 {
/**
* @dev Returns the amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `recipient`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address recipient, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `sender` to `recipient` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address sender,
address recipient,
uint256 amount
) external returns (bool);
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
}
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;
}
PaymentSplitter.sol 189 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (finance/PaymentSplitter.sol)
pragma solidity ^0.8.0;
import "../token/ERC20/utils/SafeERC20.sol";
import "../utils/Address.sol";
import "../utils/Context.sol";
/**
* @title PaymentSplitter
* @dev This contract allows to split Ether payments among a group of accounts. The sender does not need to be aware
* that the Ether will be split in this way, since it is handled transparently by the contract.
*
* The split can be in equal parts or in any other arbitrary proportion. The way this is specified is by assigning each
* account to a number of shares. Of all the Ether that this contract receives, each account will then be able to claim
* an amount proportional to the percentage of total shares they were assigned.
*
* `PaymentSplitter` follows a _pull payment_ model. This means that payments are not automatically forwarded to the
* accounts but kept in this contract, and the actual transfer is triggered as a separate step by calling the {release}
* function.
*
* NOTE: This contract assumes that ERC20 tokens will behave similarly to native tokens (Ether). Rebasing tokens, and
* tokens that apply fees during transfers, are likely to not be supported as expected. If in doubt, we encourage you
* to run tests before sending real value to this contract.
*/
contract PaymentSplitter is Context {
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event ERC20PaymentReleased(IERC20 indexed token, address to, uint256 amount);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
mapping(IERC20 => uint256) private _erc20TotalReleased;
mapping(IERC20 => mapping(address => uint256)) private _erc20Released;
/**
* @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
* the matching position in the `shares` array.
*
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`.
*/
constructor(address[] memory payees, uint256[] memory shares_) payable {
require(payees.length == shares_.length, "PaymentSplitter: payees and shares length mismatch");
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
/**
* @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
* reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
* reliability of the events, and not the actual splitting of Ether.
*
* To learn more about this see the Solidity documentation for
* https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback
* functions].
*/
receive() external payable virtual {
emit PaymentReceived(_msgSender(), msg.value);
}
/**
* @dev Getter for the total shares held by payees.
*/
function totalShares() public view returns (uint256) {
return _totalShares;
}
/**
* @dev Getter for the total amount of Ether already released.
*/
function totalReleased() public view returns (uint256) {
return _totalReleased;
}
/**
* @dev Getter for the total amount of `token` already released. `token` should be the address of an IERC20
* contract.
*/
function totalReleased(IERC20 token) public view returns (uint256) {
return _erc20TotalReleased[token];
}
/**
* @dev Getter for the amount of shares held by an account.
*/
function shares(address account) public view returns (uint256) {
return _shares[account];
}
/**
* @dev Getter for the amount of Ether already released to a payee.
*/
function released(address account) public view returns (uint256) {
return _released[account];
}
/**
* @dev Getter for the amount of `token` tokens already released to a payee. `token` should be the address of an
* IERC20 contract.
*/
function released(IERC20 token, address account) public view returns (uint256) {
return _erc20Released[token][account];
}
/**
* @dev Getter for the address of the payee number `index`.
*/
function payee(uint256 index) public view returns (address) {
return _payees[index];
}
/**
* @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the
* total shares and their previous withdrawals.
*/
function release(address payable account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = address(this).balance + totalReleased();
uint256 payment = _pendingPayment(account, totalReceived, released(account));
require(payment != 0, "PaymentSplitter: account is not due payment");
_released[account] += payment;
_totalReleased += payment;
Address.sendValue(account, payment);
emit PaymentReleased(account, payment);
}
/**
* @dev Triggers a transfer to `account` of the amount of `token` tokens they are owed, according to their
* percentage of the total shares and their previous withdrawals. `token` must be the address of an IERC20
* contract.
*/
function release(IERC20 token, address account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = token.balanceOf(address(this)) + totalReleased(token);
uint256 payment = _pendingPayment(account, totalReceived, released(token, account));
require(payment != 0, "PaymentSplitter: account is not due payment");
_erc20Released[token][account] += payment;
_erc20TotalReleased[token] += payment;
SafeERC20.safeTransfer(token, account, payment);
emit ERC20PaymentReleased(token, account, payment);
}
/**
* @dev internal logic for computing the pending payment of an `account` given the token historical balances and
* already released amounts.
*/
function _pendingPayment(
address account,
uint256 totalReceived,
uint256 alreadyReleased
) private view returns (uint256) {
return (totalReceived * _shares[account]) / _totalShares - alreadyReleased;
}
/**
* @dev Add a new payee to the contract.
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address account, uint256 shares_) private {
require(account != address(0), "PaymentSplitter: account is the zero address");
require(shares_ > 0, "PaymentSplitter: shares are 0");
require(_shares[account] == 0, "PaymentSplitter: account already has shares");
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_);
}
}
ReentrancyGuard.sol 63 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module that helps prevent reentrant calls to a function.
*
* Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
* available, which can be applied to functions to make sure there are no nested
* (reentrant) calls to them.
*
* Note that because there is a single `nonReentrant` guard, functions marked as
* `nonReentrant` may not call one another. This can be worked around by making
* those functions `private`, and then adding `external` `nonReentrant` entry
* points to them.
*
* TIP: If you would like to learn more about reentrancy and alternative ways
* to protect against it, check out our blog post
* https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
*/
abstract contract ReentrancyGuard {
// Booleans are more expensive than uint256 or any type that takes up a full
// word because each write operation emits an extra SLOAD to first read the
// slot's contents, replace the bits taken up by the boolean, and then write
// back. This is the compiler's defense against contract upgrades and
// pointer aliasing, and it cannot be disabled.
// The values being non-zero value makes deployment a bit more expensive,
// but in exchange the refund on every call to nonReentrant will be lower in
// amount. Since refunds are capped to a percentage of the total
// transaction's gas, it is best to keep them low in cases like this one, to
// increase the likelihood of the full refund coming into effect.
uint256 private constant _NOT_ENTERED = 1;
uint256 private constant _ENTERED = 2;
uint256 private _status;
constructor() {
_status = _NOT_ENTERED;
}
/**
* @dev Prevents a contract from calling itself, directly or indirectly.
* Calling a `nonReentrant` function from another `nonReentrant`
* function is not supported. It is possible to prevent this from happening
* by making the `nonReentrant` function external, and making it call a
* `private` function that does the actual work.
*/
modifier nonReentrant() {
// On the first call to nonReentrant, _notEntered will be true
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
_;
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
}
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;
}
}
SafeERC20.sol 99 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
IERC721Receiver.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
MerkleProof.sol 52 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/cryptography/MerkleProof.sol)
pragma solidity ^0.8.0;
/**
* @dev These functions deal with verification of Merkle Trees proofs.
*
* The proofs can be generated using the JavaScript library
* https://github.com/miguelmota/merkletreejs[merkletreejs].
* Note: the hashing algorithm should be keccak256 and pair sorting should be enabled.
*
* See `test/utils/cryptography/MerkleProof.test.js` for some examples.
*/
library MerkleProof {
/**
* @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
* defined by `root`. For this, a `proof` must be provided, containing
* sibling hashes on the branch from the leaf to the root of the tree. Each
* pair of leaves and each pair of pre-images are assumed to be sorted.
*/
function verify(
bytes32[] memory proof,
bytes32 root,
bytes32 leaf
) internal pure returns (bool) {
return processProof(proof, leaf) == root;
}
/**
* @dev Returns the rebuilt hash obtained by traversing a Merklee tree up
* from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt
* hash matches the root of the tree. When processing the proof, the pairs
* of leafs & pre-images are assumed to be sorted.
*
* _Available since v4.4._
*/
function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {
bytes32 computedHash = leaf;
for (uint256 i = 0; i < proof.length; i++) {
bytes32 proofElement = proof[i];
if (computedHash <= proofElement) {
// Hash(current computed hash + current element of the proof)
computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
} else {
// Hash(current element of the proof + current computed hash)
computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
}
}
return computedHash;
}
}
IERC721Metadata.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
BooleanPacking.sol 33 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
/**
* @title BooleanPacking
* @author @NiftyMike, NFT Culture
* @dev Credit to Zimri Leijen
* See https://ethereum.stackexchange.com/a/92235
*/
library BooleanPacking {
function getBoolean(uint256 _packedBools, uint256 _columnNumber)
internal
pure
returns (bool)
{
uint256 flag = (_packedBools >> _columnNumber) & uint256(1);
return (flag == 1 ? true : false);
}
function setBoolean(
uint256 _packedBools,
uint256 _columnNumber,
bool _value
) internal pure returns (uint256) {
if (_value) {
_packedBools = _packedBools | (uint256(1) << _columnNumber);
return _packedBools;
} else {
_packedBools = _packedBools & ~(uint256(1) << _columnNumber);
return _packedBools;
}
}
}
IERC721Enumerable.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Enumerable.sol)
pragma solidity ^0.8.0;
import "../IERC721.sol";
/**
* @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Enumerable is IERC721 {
/**
* @dev Returns the total amount of tokens stored by the contract.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns a token ID owned by `owner` at a given `index` of its token list.
* Use along with {balanceOf} to enumerate all of ``owner``'s tokens.
*/
function tokenOfOwnerByIndex(address owner, uint256 index) external view returns (uint256 tokenId);
/**
* @dev Returns a token ID at a given `index` of all the tokens stored by the contract.
* Use along with {totalSupply} to enumerate all tokens.
*/
function tokenByIndex(uint256 index) external view returns (uint256);
}
MerkleRoot.sol 26 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import {MerkleProof} from '@openzeppelin/contracts/utils/cryptography/MerkleProof.sol';
/**
* @title MerkleRoot
* @author @NiftyMike, NFT Culture
* @dev Companion library to OpenZeppelin's MerkleProof.
* Allows you to abstract away merkle functionality a bit further, you now just need to
* worry about dealing with your merkle root.
*
* Using this library allows you to treat bytes32 member variables as Merkle Roots, with a
* slightly easier to use api then the OZ library.
*/
library MerkleRoot {
using MerkleProof for bytes32[];
function check(
bytes32 root,
bytes32[] calldata proof,
bytes32 leaf
) internal pure returns (bool) {
return proof.verify(root, leaf);
}
}
WalletIndex.sol 28 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
/**
* @title WalletIndex
* @author @NiftyMike, NFT Culture
* @dev Library that tracks an index against a wallet.
*
* Small helper library, in case you need to track a count by wallet.
*/
library WalletIndex {
struct Index {
// This variable should never be directly accessed by users of the library. See OZ comments in other libraries for more info.
mapping(address => uint256) _index;
}
function _getNextIndex(Index storage index, address wallet) internal view returns (uint256) {
return index._index[wallet];
}
function _incrementIndex(
Index storage index,
address wallet,
uint256 count
) internal {
index._index[wallet] += count;
}
}
MerkleLeaves.sol 61 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
/**
* @title MerkleLeaves
* @author @NiftyMike, NFT Culture
* @dev Merkle Leaves for Merkle Trees - This is a companion contract to NFTC Labs' MerkleClaimList.sol library.
* It provides leaf generation functions for both indexed and non-indexed merkle trees.
* It also provides wrapper methods to expose the leaf generation functions to off-chain callers.
*
* Off-chain access is useful, because both the contract and the caller need to be able to generate the
* leaves in a perfectly identical manner, so the generators are exposed to make it easier.
*/
abstract contract MerkleLeaves {
/**
* @notice External: generate a leaf for a wallet.
*
* @param wallet Address to hash.
*/
function getLeafFor(address wallet) external pure returns (bytes32) {
return _generateLeaf(wallet);
}
/**
* @notice External: generate a leaf for a wallet and an embedded index value.
*
* @param wallet Address to hash.
* @param index integer index to assign the leaf.
*/
function getIndexedLeafFor(address wallet, uint256 index)
external
pure
returns (bytes32)
{
return _generateIndexedLeaf(wallet, index);
}
/**
* @dev Generate a merkle leaf based only on a wallet address. This is useful when all users
* represented in the tree are eligible for the exact same thing, such as one free mint.
*
* A tiered system can be supported by this approach, by making seperate merkle trees and
* mint functions per tier, but that approach will become ungainly if you have to support more
* than a few tiers.
*/
function _generateLeaf(address wallet) internal pure returns (bytes32) {
return keccak256(abi.encodePacked(wallet));
}
/**
* @dev Generate a merkle leaf based on a wallet address and an index. This is useful when all
* users represented in the tree are eligible for different amounts of something.
*/
function _generateIndexedLeaf(address wallet, uint256 index)
internal
pure
returns (bytes32)
{
return keccak256(abi.encodePacked(wallet, "_", index));
}
}
SlimPaymentSplitter.sol 152 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "@openzeppelin/contracts/utils/Address.sol";
import "@openzeppelin/contracts/utils/Context.sol";
/**
* @title SlimPaymentSplitter
* @author @NiftyMike, NFT Culture
* @dev A drop-in slim replacement version of OZ's Payment Splitter. All ERC-20 token functionality removed.
*
* Based on OpenZeppelin Contracts v4.4.1 (finance/PaymentSplitter.sol)
*/
contract SlimPaymentSplitter is Context {
event PayeeAdded(address account, uint256 shares);
event PaymentReleased(address to, uint256 amount);
event PaymentReceived(address from, uint256 amount);
uint256 private _totalShares;
uint256 private _totalReleased;
mapping(address => uint256) private _shares;
mapping(address => uint256) private _released;
address[] private _payees;
/**
* @dev Creates an instance of `PaymentSplitter` where each account in `payees` is assigned the number of shares at
* the matching position in the `shares` array.
*
* All addresses in `payees` must be non-zero. Both arrays must have the same non-zero length, and there must be no
* duplicates in `payees`.
*/
constructor(address[] memory payees, uint256[] memory shares_) payable {
require(
payees.length == shares_.length,
"PaymentSplitter: payees and shares length mismatch"
);
require(payees.length > 0, "PaymentSplitter: no payees");
for (uint256 i = 0; i < payees.length; i++) {
_addPayee(payees[i], shares_[i]);
}
}
/**
* @dev The Ether received will be logged with {PaymentReceived} events. Note that these events are not fully
* reliable: it's possible for a contract to receive Ether without triggering this function. This only affects the
* reliability of the events, and not the actual splitting of Ether.
*
* To learn more about this see the Solidity documentation for
* https://solidity.readthedocs.io/en/latest/contracts.html#fallback-function[fallback
* functions].
*/
receive() external payable virtual {
emit PaymentReceived(_msgSender(), msg.value);
}
/**
* @dev Getter for the total shares held by payees.
*/
function totalShares() public view returns (uint256) {
return _totalShares;
}
/**
* @dev Getter for the total amount of Ether already released.
*/
function totalReleased() public view returns (uint256) {
return _totalReleased;
}
/**
* @dev Getter for the amount of shares held by an account.
*/
function shares(address account) public view returns (uint256) {
return _shares[account];
}
/**
* @dev Getter for the amount of Ether already released to a payee.
*/
function released(address account) public view returns (uint256) {
return _released[account];
}
/**
* @dev Getter for the address of the payee number `index`.
*/
function payee(uint256 index) public view returns (address) {
return _payees[index];
}
/**
* @dev Triggers a transfer to `account` of the amount of Ether they are owed, according to their percentage of the
* total shares and their previous withdrawals.
*/
function release(address payable account) public virtual {
require(_shares[account] > 0, "PaymentSplitter: account has no shares");
uint256 totalReceived = address(this).balance + totalReleased();
uint256 payment = _pendingPayment(
account,
totalReceived,
released(account)
);
require(payment != 0, "PaymentSplitter: account is not due payment");
_released[account] += payment;
_totalReleased += payment;
Address.sendValue(account, payment);
emit PaymentReleased(account, payment);
}
/**
* @dev internal logic for computing the pending payment of an `account` given the token historical balances and
* already released amounts.
*/
function _pendingPayment(
address account,
uint256 totalReceived,
uint256 alreadyReleased
) private view returns (uint256) {
return
(totalReceived * _shares[account]) / _totalShares - alreadyReleased;
}
/**
* @dev Add a new payee to the contract.
* @param account The address of the payee to add.
* @param shares_ The number of shares owned by the payee.
*/
function _addPayee(address account, uint256 shares_) private {
require(
account != address(0),
"PaymentSplitter: account is the zero address"
);
require(shares_ > 0, "PaymentSplitter: shares are 0");
require(
_shares[account] == 0,
"PaymentSplitter: account already has shares"
);
_payees.push(account);
_shares[account] = shares_;
_totalShares = _totalShares + shares_;
emit PayeeAdded(account, shares_);
}
}
MerkleClaimList.sol 49 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import {MerkleRoot} from './MerkleRoot.sol';
/**
* @title MerkleClaimList
* @author @NiftyMike, NFT Culture
* @dev Basic functionality for a MerkleTree that will be used as a "Claimlist"
*
* "Claimlist" - an approach for validating callers that is backed by a Merkle Tree.
* Cheap to set the master claim, not that expensive to check the claim. Requires
* off-chain generation of the Merkle Tree.
*
* This library allows you to declare a member variable like:
* MerkleClaimList.Root private _claimRoot;
*
* The benefit of packaging this as a library, is that if you need multiple merkle trees in your
* contract, you can declare multiple member variables using this library, and use them in similar fashion.
*
* see also: NFTC Labs' MerkleLeaves.sol, which is a companion abstract contract which contains helper
* methods for generating leaves for the Merkle Tree.
*/
library MerkleClaimList {
using MerkleRoot for bytes32;
struct Root {
// This variable should never be directly accessed by users of the library. See OZ comments in other libraries for more info.
bytes32 _root;
}
/**
* @dev Validate that a leaf is part of this merkle tree.
*/
function _checkLeaf(
Root storage root,
bytes32[] calldata proof,
bytes32 leaf
) internal view returns (bool) {
return root._root.check(proof, leaf);
}
/**
* @dev Set the root of this merkle tree.
*/
function _setRoot(Root storage root, bytes32 __root) internal {
root._root = __root;
}
}
LockedPaymentSplitter.sol 34 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
import "./SlimPaymentSplitter.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
/**
* @title LockedPaymentSplitter
* @author @NiftyMike, NFT Culture
* @dev A wrapper around SlimPaymentSplitter which adds on security elements.
*
* Based on OpenZeppelin Contracts v4.4.1 (finance/PaymentSplitter.sol)
*/
abstract contract LockedPaymentSplitter is SlimPaymentSplitter, Ownable {
/**
* @dev Overrides release() method, so that it can only be called by owner.
* @notice Owner: Release funds to a specific address.
*
* @param account Payable address that will receive funds.
*/
function release(address payable account) public override onlyOwner {
super.release(account);
}
/**
* @dev Triggers a transfer to caller's address of the amount of Ether they are owed, according to their percentage of the
* total shares and their previous withdrawals.
* @notice Sender: request payment.
*/
function releaseToSelf() public {
super.release(payable(msg.sender));
}
}
GuardedAgainstContracts.sol 15 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.11;
/**
* @title GuardedAgainstContracts
* @author @NiftyMike, NFT Culture
* @dev Helper contract to help protect against contract based mint spamming attacks.
*/
abstract contract GuardedAgainstContracts {
modifier onlyUsers() {
require(tx.origin == msg.sender, 'Must be user');
_;
}
}
Read Contract
balanceOf 0x70a08231 → uint256
baseURI 0x6c0360eb → string
checkClaim 0x709b00ae → bool
checkPresale 0xc865815b → bool
claimPricePerNft 0x815c5fd4 → uint256
getApproved 0x081812fc → address
getIndexedLeafFor 0xcfb00c6d → bytes32
getLeafFor 0xe27c429c → bytes32
getNextClaimIndex 0x0cbb5df5 → uint256
getNextPresaleIndex 0x070c9a8a → uint256
isApprovedForAll 0xe985e9c5 → bool
isClaimingActive 0x3732ad1c → bool
isMintingActive 0x6ac437b0 → bool
isPresaleActive 0x60d938dc → bool
maxSupply 0xd5abeb01 → uint256
mintPricePerNft 0x36daaea4 → uint256
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
payee 0x8b83209b → address
presalePricePerNft 0x722d1853 → uint256
released 0x9852595c → uint256
shares 0xce7c2ac2 → uint256
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenByIndex 0x4f6ccce7 → uint256
tokenOfOwnerByIndex 0x2f745c59 → uint256
tokenURI 0xc87b56dd → string
totalReleased 0xe33b7de3 → uint256
totalShares 0x3a98ef39 → uint256
totalSupply 0x18160ddd → uint256
Write Contract 16 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
claimPunks 0x38d1787f
bytes32[] proof
uint256 count
mintPunks 0x4f459936
uint256 count
presalePunks 0x88c025ec
bytes32[] proof
uint256 count
release 0x19165587
address account
releaseToSelf 0xe228c6fe
No parameters
renounceOwnership 0x715018a6
No parameters
reservePunks 0x4f777803
address[] friends
uint256 count
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 __baseUri
setMerkleRoots 0x9a48eb51
bytes32 __claimRoot
bytes32 __presaleRoot
setMintingState 0x66e590e4
bool __claimingActive
bool __presaleActive
bool __mintingActive
uint256 __claimPricePerNft
uint256 __presalePricePerNft
uint256 __mintPricePerNft
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
Recent Transactions
No transactions found for this address