Address Contract Verified
Address
0x113F1546D380CbB2F9A4757dB9d4D2E83e5e4037
Balance
0.883200 ETH
Nonce
1
Code Size
14532 bytes
Creator
0xA5D5a111...2BDC at tx 0x67a76e8b...52579c
Indexed Transactions
0
Contract Bytecode
14532 bytes
0x6080604052600436106103b75760003560e01c80636352211e116101f257806396c5085b1161010d578063c87b56dd116100a0578063f03d60af1161006f578063f03d60af14610b16578063f2fde38b14610b46578063f59527f514610b66578063fc3dcb4414610b8657600080fd5b8063c87b56dd14610a6d578063d2a8fb5114610a8d578063e985e9c514610aad578063ed6f74a714610af657600080fd5b8063aa4be35f116100dc578063aa4be35f146109e0578063b69c962514610a00578063b88d4fde14610a2d578063c161d6f014610a4057600080fd5b806396c5085b1461095b57806398a3402a1461098b5780639ce4b680146109ab578063a22cb465146109c057600080fd5b8063715018a6116101855780638da5cb5b116101545780638da5cb5b146108d857806390ecdd9d146108f6578063919e07631461091657806395d89b411461094657600080fd5b8063715018a61461086e57806375bc2d711461088357806385e62a0e146108985780638af35c90146108b857600080fd5b80636767af98116101c15780636767af98146107f95780636c222b1714610819578063706f69771461083957806370a082311461084e57600080fd5b80636352211e14610784578063638681dc146107a4578063656225cb146107c457806366aac399146107e457600080fd5b806323b872dd116102e257806342842e0e1161027557806352c9188f1161024457806352c9188f1461071957806353455f4e1461072e5780635af2eff2146107445780635c0f4cd71461076457600080fd5b806342842e0e146106a657806343dc27a2146106b95780634819564b146106d95780634eea60de146106f957600080fd5b80632e60ea97116102b15780632e60ea9714610632578063331bd0e7146106525780634062988414610672578063406c1f6b1461068c57600080fd5b806323b872dd146105bf578063277eebd0146105d257806329d625b1146105f25780632cd5027d1461061257600080fd5b80630b113f651161035a57806314449fa71161032957806314449fa71461054157806314705d2f1461056157806318160ddd146105815780631e5cb0f71461059f57600080fd5b80630b113f65146104ce57806312a52bf5146104ee5780631321d8321461050e578063137c6dee1461052157600080fd5b806306fdde031161039657806306fdde0314610441578063081812fc14610463578063095ea7b31461049b5780630ab46fcf146104ae57600080fd5b8062728e46146103bc57806301a10b4d146103de57806301ffc9a714610411575b600080fd5b3480156103c857600080fd5b506103dc6103d7366004612ab8565b610b9c565b005b3480156103ea57600080fd5b506103fe6103f9366004612ab8565b610ba9565b6040519081526020015b60405180910390f35b34801561041d57600080fd5b5061043161042c366004612ae7565b610bc0565b6040519015158152602001610408565b34801561044d57600080fd5b50610456610c12565b6040516104089190612b54565b34801561046f57600080fd5b5061048361047e366004612ab8565b610ca4565b6040516001600160a01b039091168152602001610408565b6103dc6104a9366004612b8c565b610ce8565b3480156104ba57600080fd5b506103dc6104c9366004612ccd565b610d88565b3480156104da57600080fd5b506104566104e9366004612ab8565b610db5565b3480156104fa57600080fd5b506103dc610509366004612ab8565b610e55565b6103dc61051c366004612ab8565b610eb0565b34801561052d57600080fd5b5061045661053c366004612ab8565b610edb565b34801561054d57600080fd5b506103fe61055c366004612d13565b610eeb565b34801561056d57600080fd5b506103dc61057c366004612d35565b610f77565b34801561058d57600080fd5b506001546000540361272419016103fe565b3480156105ab57600080fd5b506103dc6105ba366004612d65565b610fbe565b6103dc6105cd366004612d99565b610fd6565b3480156105de57600080fd5b506104566105ed366004612e6c565b61116f565b3480156105fe57600080fd5b506103fe61060d366004612ea0565b6111ed565b34801561061e57600080fd5b506103dc61062d366004612d65565b61125b565b34801561063e57600080fd5b506103dc61064d366004612ab8565b61126f565b34801561065e57600080fd5b506103dc61066d366004612d65565b611297565b34801561067e57600080fd5b50600a546104319060ff1681565b34801561069857600080fd5b506034546104319060ff1681565b6103dc6106b4366004612d99565b6112ab565b3480156106c557600080fd5b506103dc6106d4366004612d65565b6112c6565b3480156106e557600080fd5b506104836106f4366004612d13565b6112da565b34801561070557600080fd5b506103dc610714366004612f2c565b611312565b34801561072557600080fd5b506103dc61147b565b34801561073a57600080fd5b506103fe60315481565b34801561075057600080fd5b5061045661075f366004612ab8565b6114ef565b34801561077057600080fd5b506103dc61077f366004612ab8565b6114ff565b34801561079057600080fd5b5061048361079f366004612ab8565b61150c565b3480156107b057600080fd5b506103dc6107bf366004612f51565b611517565b3480156107d057600080fd5b506104316107df366004612ab8565b611541565b3480156107f057600080fd5b506104566115ea565b34801561080557600080fd5b506103dc610814366004612ccd565b6115f7565b34801561082557600080fd5b506103dc610834366004612f51565b611613565b34801561084557600080fd5b506103dc61163d565b34801561085a57600080fd5b506103fe610869366004612f51565b611659565b34801561087a57600080fd5b506103dc6116a7565b34801561088f57600080fd5b506104566116bb565b3480156108a457600080fd5b506103dc6108b3366004612ccd565b6116c8565b3480156108c457600080fd5b506103dc6108d3366004612ab8565b6116e4565b3480156108e457600080fd5b506008546001600160a01b0316610483565b34801561090257600080fd5b506103dc610911366004612ab8565b611703565b34801561092257600080fd5b50610431610931366004612ab8565b60116020526000908152604090205460ff1681565b34801561095257600080fd5b50610456611783565b34801561096757600080fd5b50610431610976366004612ab8565b600f6020526000908152604090205460ff1681565b34801561099757600080fd5b506103dc6109a6366004612d13565b611792565b3480156109b757600080fd5b506103dc611817565b3480156109cc57600080fd5b506103dc6109db366004612f6e565b611833565b3480156109ec57600080fd5b506103dc6109fb366004612d13565b61189f565b348015610a0c57600080fd5b506103fe610a1b366004612ab8565b600c6020526000908152604090205481565b6103dc610a3b366004612f9c565b6118c1565b348015610a4c57600080fd5b506103fe610a5b366004612f51565b600e6020526000908152604090205481565b348015610a7957600080fd5b50610456610a88366004612ab8565b61190b565b348015610a9957600080fd5b506103dc610aa8366004612f51565b6119ff565b348015610ab957600080fd5b50610431610ac836600461301b565b6001600160a01b03918216600090815260076020908152604080832093909416825291909152205460ff1690565b348015610b0257600080fd5b506103dc610b11366004612b8c565b611a2f565b348015610b2257600080fd5b50610431610b31366004612ab8565b600d6020526000908152604090205460ff1681565b348015610b5257600080fd5b506103dc610b61366004612f51565b611a68565b348015610b7257600080fd5b50610456610b81366004613049565b611ade565b348015610b9257600080fd5b506103fe600b5481565b610ba4611b4b565b600b55565b602181600e8110610bb957600080fd5b0154905081565b60006301ffc9a760e01b6001600160e01b031983161480610bf157506380ac58cd60e01b6001600160e01b03198316145b80610c0c5750635b5e139f60e01b6001600160e01b03198316145b92915050565b606060028054610c2190613112565b80601f0160208091040260200160405190810160405280929190818152602001828054610c4d90613112565b8015610c9a5780601f10610c6f57610100808354040283529160200191610c9a565b820191906000526020600020905b815481529060010190602001808311610c7d57829003601f168201915b5050505050905090565b6000610caf82611ba5565b610ccc576040516333d1c03960e21b815260040160405180910390fd5b506000908152600660205260409020546001600160a01b031690565b6000610cf38261150c565b9050336001600160a01b03821614610d2c57610d0f8133610ac8565b610d2c576040516367d9dca160e11b815260040160405180910390fd5b60008281526006602052604080822080546001600160a01b0319166001600160a01b0387811691821790925591518593918516917f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92591a4505050565b610d90611b4b565b8060198360088110610da457610da4613146565b0190610db090826131a2565b505050565b60128160078110610dc557600080fd5b018054909150610dd490613112565b80601f0160208091040260200160405190810160405280929190818152602001828054610e0090613112565b8015610e4d5780601f10610e2257610100808354040283529160200191610e4d565b820191906000526020600020905b815481529060010190602001808311610e3057829003601f168201915b505050505081565b336000908152600e60205260408120549003610e8457604051636672b76360e11b815260040160405180910390fd5b336000908152600e60205260408120805491610e9f83613277565b9190505550610ead81611bdb565b50565b600b543414610ed25760405163579e3e8360e11b815260040160405180910390fd5b610ead81611bdb565b60328160028110610dc557600080fd5b6000600e821115610f3a5760405162461bcd60e51b81526020600482015260146024820152730e8e4c2d2e840d2dcc8caf040e8dede40d0d2ced60631b60448201526064015b60405180910390fd5b6000610f4783600e61328e565b90506000610f568260086132a1565b60ff901b90506000610f698360086132a1565b91909516901c949350505050565b610f7f611b4b565b600091825260106020908152604083208054600181018255908452922090910180546001600160a01b0319166001600160a01b03909216919091179055565b610fc6611b4b565b6030610fd282826131a2565b5050565b6000610fe182611d3b565b9050836001600160a01b0316816001600160a01b0316146110145760405162a1148160e81b815260040160405180910390fd5b60008281526006602052604090208054338082146001600160a01b03881690911417611061576110448633610ac8565b61106157604051632ce44b5f60e11b815260040160405180910390fd5b6001600160a01b03851661108857604051633a954ecd60e21b815260040160405180910390fd5b801561109357600082555b6001600160a01b038681166000908152600560205260408082208054600019019055918716808252919020805460010190554260a01b17600160e11b17600085815260046020526040812091909155600160e11b84169003611125576001840160008181526004602052604081205490036111235760005481146111235760008181526004602052604090208490555b505b83856001600160a01b0316876001600160a01b03167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45b505050505050565b6060815160000361118e57505060408051602081019091526000815290565b600060605b806111b68584815181106111a9576111a9613146565b6020026020010151611dab565b6040516020016111c79291906132b8565b604051602081830303815290604052905081600101915083518210611193579392505050565b600080805b600f8110156112545760008482600f811061120f5761120f613146565b6020020151905060ff8111156112385760405163dc8aca5360e01b815260040160405180910390fd5b60089290921b909117908061124c816132e7565b9150506111f2565b5092915050565b611263611b4b565b6037610fd282826131a2565b611277611b4b565b6000908152600f60205260409020805460ff19811660ff90911615179055565b61129f611b4b565b602f610fd282826131a2565b610db0838383604051806020016040528060008152506118c1565b6112ce611b4b565b6036610fd282826131a2565b601060205281600052604060002081815481106112f657600080fd5b6000918252602090912001546001600160a01b03169150829050565b61131a611b4b565b8061144157603554604051630609b37760e11b8152600481018490526001600160a01b0390911690630c1366ee90602401602060405180830381865afa158015611368573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061138c9190613300565b156113aa57604051631a910b5f60e31b815260040160405180910390fd5b6000828152600d602052604090205460ff16156113da57604051631a910b5f60e31b815260040160405180910390fd5b6113e382611541565b6114005760405163ce93090b60e01b815260040160405180910390fd5b81600c600061140e60005490565b81526020808201929092526040908101600090812093909355848352600d9091529020805460ff19166001179055611470565b6001600f600061145060005490565b81526020810191909152604001600020805460ff19169115159190911790555b610fd2336001611dbb565b6038546040516000916001600160a01b03169047908381818185875af1925050503d80600081146114c8576040519150601f19603f3d011682016040523d82523d6000602084013e6114cd565b606091505b5050905080610ead5760405163c79988b360e01b815260040160405180910390fd5b60198160088110610dc557600080fd5b611507611b4b565b603155565b6000610c0c82611d3b565b61151f611b4b565b603580546001600160a01b0319166001600160a01b0392909216919091179055565b60006effffffffffffffffffffffffffffff82111561156257506000919050565b8160000361157257506000919050565b600061157f83600e610eeb565b905080156115905750600092915050565b60005b600e8110156115e0576115a68482610eeb565b9150602181600e81106115bb576115bb613146565b01548211156115ce575060009392505050565b806115d8816132e7565b915050611593565b5060019392505050565b602f8054610dd490613112565b6115ff611b4b565b8060328360028110610da457610da4613146565b61161b611b4b565b603880546001600160a01b0319166001600160a01b0392909216919091179055565b611645611b4b565b600a805460ff19811660ff90911615179055565b60006001600160a01b038216611682576040516323d3ad8160e21b815260040160405180910390fd5b506001600160a01b03166000908152600560205260409020546001600160401b031690565b6116af611b4b565b6116b96000611eb9565b565b60308054610dd490613112565b6116d0611b4b565b8060128360078110610da457610da4613146565b6116ec611b4b565b6000818152601060205260408120610ead91612a3b565b61170c81611ba5565b61172957604051635dea23df60e11b815260040160405180910390fd5b6117328161150c565b6001600160a01b0316336001600160a01b03161461176357604051637bf8404d60e11b815260040160405180910390fd5b6000908152601160205260409020805460ff19811660ff90911615179055565b606060038054610c2190613112565b61179a611b4b565b6117a381611541565b6117c05760405163ce93090b60e01b815260040160405180910390fd5b6000828152600c602052604090205480156117ec576000818152600d60205260409020805460ff191690555b506000918252600c60209081526040808420839055918352600d90529020805460ff19166001179055565b61181f611b4b565b6034805460ff19811660ff90911615179055565b3360008181526007602090815260408083206001600160a01b03871680855290835292819020805460ff191686151590811790915590519081529192917f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31910160405180910390a35050565b6118a7611b4b565b80602183600e81106118bb576118bb613146565b01555050565b6118cc848484610fd6565b6001600160a01b0383163b15611905576118e884848484611f0b565b611905576040516368d2bf6b60e11b815260040160405180910390fd5b50505050565b606061191682611ba5565b61193357604051635dea23df60e11b815260040160405180910390fd5b6000828152600f602052604090205460ff16156119b5576000828152601060209081526040918290208054835181840281018401909452808452610c0c93928301828280156119ab57602002820191906000526020600020905b81546001600160a01b0316815260019091019060200180831161198d575b505050505061116f565b60345460009060ff1680156119d8575060008381526011602052604090205460ff165b905080156119f0576119e983611ff7565b9392505050565b6119e9836124fa565b50919050565b611a07611b4b565b603480546001600160a01b0390921661010002610100600160a81b0319909216919091179055565b611a37611b4b565b6001600160a01b0382166000908152600e602052604081208054839290611a5f90849061331d565b90915550505050565b611a70611b4b565b6001600160a01b038116611ad55760405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608401610f31565b610ead81611eb9565b60808101518151606091601391601490611af7906127b3565b6012600301611b0987602001516127b3565b6012600401611b1b8960c0015161116f565b604051611b359897969594939291906017906020016133a3565b6040516020818303038152906040529050919050565b6008546001600160a01b031633146116b95760405162461bcd60e51b815260206004820181905260248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152606401610f31565b60008161272511158015611bba575060005482105b8015610c0c575050600090815260046020526040902054600160e01b161590565b611be36127f7565b600a5460ff16611c06576040516367b8f35760e01b815260040160405180910390fd5b611c0f81611541565b611c2c5760405163ce93090b60e01b815260040160405180910390fd5b603554604051630609b37760e11b8152600481018390526001600160a01b0390911690630c1366ee90602401602060405180830381865afa158015611c75573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190611c999190613300565b15611cb757604051631a910b5f60e31b815260040160405180910390fd5b6000818152600d602052604090205460ff1615611ce757604051631a910b5f60e31b815260040160405180910390fd5b80600c6000611cf560005490565b81526020808201929092526040908101600090812093909355838352600d9091529020805460ff19166001908117909155611d31903390611dbb565b610ead6001600955565b6000818061272511611d9257600054811015611d925760008181526004602052604081205490600160e01b82169003611d90575b806000036119e9575060001901600081815260046020526040902054611d6f565b505b604051636f96cda160e11b815260040160405180910390fd5b6060610c0c826001600019612850565b6000805490829003611de05760405163b562e8dd60e01b815260040160405180910390fd5b6001600160a01b03831660008181526005602090815260408083208054680100000000000000018802019055848352600490915281206001851460e11b4260a01b178317905582840190839083907fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef8180a4600183015b818114611e8f57808360007fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef600080a4600101611e57565b5081600003611eb057604051622e076360e81b815260040160405180910390fd5b60005550505050565b600880546001600160a01b038381166001600160a01b0319831681179093556040519116919082907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a35050565b604051630a85bd0160e11b81526000906001600160a01b0385169063150b7a0290611f40903390899088908890600401613439565b6020604051808303816000875af1925050508015611f7b575060408051601f3d908101601f19168201909252611f7891810190613476565b60015b611fd9573d808015611fa9576040519150601f19603f3d011682016040523d82523d6000602084013e611fae565b606091505b508051600003611fd1576040516368d2bf6b60e11b815260040160405180910390fd5b805181602001fd5b6001600160e01b031916630a85bd0160e11b1490505b949350505050565b6000818152600c602090815260409182902054825180840190935260608084529183018290529091612027612a59565b600080806019612036896127b3565b60405161204a929190601a90602001613493565b60408051601f198184030181529190529050600060128101805461206d90613112565b80601f016020809104026020016040519081016040528092919081815260200182805461209990613112565b80156120e65780601f106120bb576101008083540402835291602001916120e6565b820191906000526020600020905b8154815290600101906020018083116120c957829003601f168201915b5050505050905060005b600f811015612343576031548103612128576040516121169083906032906020016134c6565b60405160208183030381529060405291505b6121328882610eeb565b94508460000361216f578060010361216a578160306040516020016121589291906134c6565b60405160208183030381529060405291505b612331565b60345460405163acb586df60e01b8152600481018390526101009091046001600160a01b03169063acb586df90602401600060405180830381865afa1580156121bc573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526121e49190810190613648565b96506121f160018661328e565b94508660200151858151811061220957612209613146565b602002602001015195508161221d87611ade565b60405160200161222e9291906132b8565b6040516020818303038152906040529150806002036122bd5784600603612284578161225a6000612905565b603660405160200161226e9392919061374a565b60405160208183030381529060405291506122bd565b846002036122bd57816122976001612905565b60366040516020016122ab9392919061374a565b60405160208183030381529060405291505b60315481036122ec576040516122da9083906033906020016134c6565b60405160208183030381529060405291505b82846122f957601c6122fc565b601b5b8851608089015160405161231b94939291601d91601e90602001613770565b6040516020818303038152906040529250600193505b8061233b816132e7565b9150506120f0565b50806127288a1161236357604051806020016040528060008152506123ef565b602f805461237090613112565b80601f016020809104026020016040519081016040528092919081815260200182805461239c90613112565b80156123e95780601f106123be576101008083540402835291602001916123e9565b820191906000526020600020905b8154815290600101906020018083116123cc57829003601f168201915b50505050505b6123fa896001610eeb565b1561241457604051806020016040528060008152506124a0565b6030805461242190613112565b80601f016020809104026020016040519081016040528092919081815260200182805461244d90613112565b801561249a5780601f1061246f5761010080835404028352916020019161249a565b820191906000526020600020905b81548152906001019060200180831161247d57829003601f168201915b50505050505b6040516124b5939291906018906020016137d9565b60408051808303601f190181529082905291506124dd908390601f908490602090810161382a565b60408051601f198184030181529190529998505050505050505050565b6000818152600c60209081526040918290205482518084019093526060808452918301829052909161252a612a59565b600080806019612539896127b3565b60405161254d929190601a90602001613493565b60408051601f198184030181529190529050600060128101805461257090613112565b80601f016020809104026020016040519081016040528092919081815260200182805461259c90613112565b80156125e95780601f106125be576101008083540402835291602001916125e9565b820191906000526020600020905b8154815290600101906020018083116125cc57829003601f168201915b5050505050905060005b600f811015612343576126068882610eeb565b945084156127a15760345460405163acb586df60e01b8152600481018390526101009091046001600160a01b03169063acb586df90602401600060405180830381865afa15801561265b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526126839190810190613648565b965061269060018661328e565b9450866020015185815181106126a8576126a8613146565b60200260200101519550816126bc87611ade565b6040516020016126cd9291906132b8565b60405160208183030381529060405291508060020361275c578460060361272357816126f96000612905565b603660405160200161270d9392919061374a565b604051602081830303815290604052915061275c565b8460020361275c57816127366001612905565b603660405160200161274a9392919061374a565b60405160208183030381529060405291505b828461276957601c61276c565b601b5b8851608089015160405161278b94939291601d91601e90602001613770565b6040516020818303038152906040529250600193505b806127ab816132e7565b9150506125f3565b606060a06040510180604052602081039150506000815280825b600183039250600a81066030018353600a9004806127cd5750819003601f19909101908152919050565b6002600954036128495760405162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c006044820152606401610f31565b6002600955565b6060833b60008190036128735750506040805160208101909152600081526119e9565b808411156128915750506040805160208101909152600081526119e9565b838310156128c35760405163162544fd60e11b8152600481018290526024810185905260448101849052606401610f31565b83830384820360008282106128d857826128da565b815b60408051603f8301601f19168101909152818152955090508087602087018a3c505050509392505050565b606061290f612a59565b826000036129ff5760345460405163a3f62f3960e01b815260026004820181905260248201526101009091046001600160a01b03169063a3f62f39906044015b600060405180830381865afa15801561296c573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052612994919081019061385a565b608081015181519192506013916014906129ad906127b3565b60126003016129bf86602001516127b3565b60376129ce8860c0015161116f565b6040516129e89897969594939291906017906020016133a3565b604051602081830303815290604052915050919050565b60345460405163a3f62f3960e01b815260026004820152600660248201526101009091046001600160a01b03169063a3f62f399060440161294f565b5080546000825590600052602060002090810190610ead9190612a9f565b6040518060e00160405280600081526020016000815260200160008152602001600081526020016060815260200160006001600160a01b03168152602001606081525090565b5b80821115612ab45760008155600101612aa0565b5090565b600060208284031215612aca57600080fd5b5035919050565b6001600160e01b031981168114610ead57600080fd5b600060208284031215612af957600080fd5b81356119e981612ad1565b60005b83811015612b1f578181015183820152602001612b07565b50506000910152565b60008151808452612b40816020860160208601612b04565b601f01601f19169290920160200192915050565b6020815260006119e96020830184612b28565b6001600160a01b0381168114610ead57600080fd5b8035612b8781612b67565b919050565b60008060408385031215612b9f57600080fd5b8235612baa81612b67565b946020939093013593505050565b634e487b7160e01b600052604160045260246000fd5b60405160e081016001600160401b0381118282101715612bf057612bf0612bb8565b60405290565b604080519081016001600160401b0381118282101715612bf057612bf0612bb8565b604051601f8201601f191681016001600160401b0381118282101715612c4057612c40612bb8565b604052919050565b60006001600160401b03821115612c6157612c61612bb8565b50601f01601f191660200190565b6000612c82612c7d84612c48565b612c18565b9050828152838383011115612c9657600080fd5b828260208301376000602084830101529392505050565b600082601f830112612cbe57600080fd5b6119e983833560208501612c6f565b60008060408385031215612ce057600080fd5b8235915060208301356001600160401b03811115612cfd57600080fd5b612d0985828601612cad565b9150509250929050565b60008060408385031215612d2657600080fd5b50508035926020909101359150565b60008060408385031215612d4857600080fd5b823591506020830135612d5a81612b67565b809150509250929050565b600060208284031215612d7757600080fd5b81356001600160401b03811115612d8d57600080fd5b611fef84828501612cad565b600080600060608486031215612dae57600080fd5b8335612db981612b67565b92506020840135612dc981612b67565b929592945050506040919091013590565b60006001600160401b03821115612df357612df3612bb8565b5060051b60200190565b600082601f830112612e0e57600080fd5b81356020612e1e612c7d83612dda565b82815260059290921b84018101918181019086841115612e3d57600080fd5b8286015b84811015612e61578035612e5481612b67565b8352918301918301612e41565b509695505050505050565b600060208284031215612e7e57600080fd5b81356001600160401b03811115612e9457600080fd5b611fef84828501612dfd565b60006101e0808385031215612eb457600080fd5b83601f840112612ec357600080fd5b6040518181018181106001600160401b0382111715612ee457612ee4612bb8565b604052908301908085831115612ef957600080fd5b845b83811015612f13578035825260209182019101612efb565b509095945050505050565b8015158114610ead57600080fd5b60008060408385031215612f3f57600080fd5b823591506020830135612d5a81612f1e565b600060208284031215612f6357600080fd5b81356119e981612b67565b60008060408385031215612f8157600080fd5b8235612f8c81612b67565b91506020830135612d5a81612f1e565b60008060008060808587031215612fb257600080fd5b8435612fbd81612b67565b93506020850135612fcd81612b67565b92506040850135915060608501356001600160401b03811115612fef57600080fd5b8501601f8101871361300057600080fd5b61300f87823560208401612c6f565b91505092959194509250565b6000806040838503121561302e57600080fd5b823561303981612b67565b91506020830135612d5a81612b67565b60006020828403121561305b57600080fd5b81356001600160401b038082111561307257600080fd5b9083019060e0828603121561308657600080fd5b61308e612bce565b823581526020830135602082015260408301356040820152606083013560608201526080830135828111156130c257600080fd5b6130ce87828601612cad565b6080830152506130e060a08401612b7c565b60a082015260c0830135828111156130f757600080fd5b61310387828601612dfd565b60c08301525095945050505050565b600181811c9082168061312657607f821691505b6020821081036119f957634e487b7160e01b600052602260045260246000fd5b634e487b7160e01b600052603260045260246000fd5b601f821115610db057600081815260208120601f850160051c810160208610156131835750805b601f850160051c820191505b818110156111675782815560010161318f565b81516001600160401b038111156131bb576131bb612bb8565b6131cf816131c98454613112565b8461315c565b602080601f83116001811461320457600084156131ec5750858301515b600019600386901b1c1916600185901b178555611167565b600085815260208120601f198616915b8281101561323357888601518255948401946001909101908401613214565b50858210156132515787850151600019600388901b60f8161c191681555b5050505050600190811b01905550565b634e487b7160e01b600052601160045260246000fd5b60008161328657613286613261565b506000190190565b81810381811115610c0c57610c0c613261565b8082028115828204841417610c0c57610c0c613261565b600083516132ca818460208801612b04565b8351908301906132de818360208801612b04565b01949350505050565b6000600182016132f9576132f9613261565b5060010190565b60006020828403121561331257600080fd5b81516119e981612f1e565b80820180821115610c0c57610c0c613261565b6000815461333d81613112565b60018281168015613355576001811461336a57613399565b60ff1984168752821515830287019450613399565b8560005260208060002060005b858110156133905781548a820152908401908201613377565b50505082870194505b5050505092915050565b60006133af828c613330565b8a516133bf818360208f01612b04565b6133cb8183018c613330565b91505088516133de818360208d01612b04565b6133ea8183018a613330565b91505086516133fd818360208b01612b04565b61340981830188613330565b915050845161341c818360208901612b04565b61342881830186613330565b9d9c50505050505050505050505050565b6001600160a01b038581168252841660208201526040810183905260806060820181905260009061346c90830184612b28565b9695505050505050565b60006020828403121561348857600080fd5b81516119e981612ad1565b600061349f8286613330565b84516134af818360208901612b04565b6134bb81830186613330565b979650505050505050565b600083516134d8818460208801612b04565b6134e481840185613330565b95945050505050565b600082601f8301126134fe57600080fd5b815161350c612c7d82612c48565b81815284602083860101111561352157600080fd5b611fef826020830160208701612b04565b8051612b8781612b67565b600082601f83011261354e57600080fd5b8151602061355e612c7d83612dda565b82815260059290921b8401810191818101908684111561357d57600080fd5b8286015b84811015612e6157805161359481612b67565b8352918301918301613581565b600060e082840312156135b357600080fd5b6135bb612bce565b90508151815260208201516020820152604082015160408201526060820151606082015260808201516001600160401b03808211156135f957600080fd5b613605858386016134ed565b608084015261361660a08501613532565b60a084015260c084015191508082111561362f57600080fd5b5061363c8482850161353d565b60c08301525092915050565b6000602080838503121561365b57600080fd5b82516001600160401b038082111561367257600080fd5b908401906040828703121561368657600080fd5b61368e612bf6565b82518281111561369d57600080fd5b6136a9888286016134ed565b82525083830151828111156136bd57600080fd5b80840193505086601f8401126136d257600080fd5b82516136e0612c7d82612dda565b81815260059190911b840185019085810190898311156136ff57600080fd5b8686015b838110156137375780518681111561371b5760008081fd5b6137298c8a838b01016135a1565b845250918701918701613703565b5095830195909552509695505050505050565b6000845161375c818460208901612b04565b8451908301906134af818360208901612b04565b60008751613782818460208c01612b04565b61378e81840189613330565b905086516137a0818360208b01612b04565b6137ac81830188613330565b91505084516137bf818360208901612b04565b6137cb81830186613330565b9a9950505050505050505050565b600085516137eb818460208a01612b04565b8551908301906137ff818360208a01612b04565b8551910190613812818360208901612b04565b61381e81830186613330565b98975050505050505050565b6000855161383c818460208a01612b04565b61384881840187613330565b90508451613812818360208901612b04565b60006020828403121561386c57600080fd5b81516001600160401b0381111561388257600080fd5b611fef848285016135a156fea26469706673582212208ba767e46b1286f9a7b6debc89465092755e708c22dcf72d334a2c1b0a17abfe64736f6c63430008130033
Verified Source Code Full Match
Compiler: v0.8.19+commit.7dd6d404
EVM: paris
Optimization: Yes (200 runs)
SSTORE2.sol 70 lines
// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./Bytecode.sol"; /** @title A key-value storage with auto-generated keys for storing chunks of data with a lower write & read cost. @author Agustin Aguilar <[email protected]> Readme: https://github.com/0xsequence/sstore2#readme */ library SSTORE2 { error WriteError(); /** @notice Stores `_data` and returns `pointer` as key for later retrieval @dev The pointer is a contract address with `_data` as code @param _data to be written @return pointer Pointer to the written `_data` */ function write(bytes memory _data) internal returns (address pointer) { // Append 00 to _data so contract can't be called // Build init code bytes memory code = Bytecode.creationCodeFor( abi.encodePacked( hex'00', _data ) ); // Deploy contract using create assembly { pointer := create(0, add(code, 32), mload(code)) } // Address MUST be non-zero if (pointer == address(0)) revert WriteError(); } /** @notice Reads the contents of the `_pointer` code as data, skips the first byte @dev The function is intended for reading pointers generated by `write` @param _pointer to be read @return data read from `_pointer` contract */ function read(address _pointer) internal view returns (bytes memory) { return Bytecode.codeAt(_pointer, 1, type(uint256).max); } /** @notice Reads the contents of the `_pointer` code as data, skips the first byte @dev The function is intended for reading pointers generated by `write` @param _pointer to be read @param _start number of bytes to skip @return data read from `_pointer` contract */ function read(address _pointer, uint256 _start) internal view returns (bytes memory) { return Bytecode.codeAt(_pointer, _start + 1, type(uint256).max); } /** @notice Reads the contents of the `_pointer` code as data, skips the first byte @dev The function is intended for reading pointers generated by `write` @param _pointer to be read @param _start number of bytes to skip @param _end index before which to end extraction @return data read from `_pointer` contract */ function read(address _pointer, uint256 _start, uint256 _end) internal view returns (bytes memory) { return Bytecode.codeAt(_pointer, _start + 1, _end + 1); } }
Bytecode.sol 78 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
library Bytecode {
error InvalidCodeAtRange(uint256 _size, uint256 _start, uint256 _end);
/**
@notice Generate a creation code that results on a contract with `_code` as bytecode
@param _code The returning value of the resulting `creationCode`
@return creationCode (constructor) for new contract
*/
function creationCodeFor(bytes memory _code) internal pure returns (bytes memory) {
/*
0x00 0x63 0x63XXXXXX PUSH4 _code.length size
0x01 0x80 0x80 DUP1 size size
0x02 0x60 0x600e PUSH1 14 14 size size
0x03 0x60 0x6000 PUSH1 00 0 14 size size
0x04 0x39 0x39 CODECOPY size
0x05 0x60 0x6000 PUSH1 00 0 size
0x06 0xf3 0xf3 RETURN
<CODE>
*/
return abi.encodePacked(
hex"63",
uint32(_code.length),
hex"80_60_0E_60_00_39_60_00_F3",
_code
);
}
/**
@notice Returns the size of the code on a given address
@param _addr Address that may or may not contain code
@return size of the code on the given `_addr`
*/
function codeSize(address _addr) internal view returns (uint256 size) {
assembly { size := extcodesize(_addr) }
}
/**
@notice Returns the code of a given address
@dev It will fail if `_end < _start`
@param _addr Address that may or may not contain code
@param _start number of bytes of code to skip on read
@param _end index before which to end extraction
@return oCode read from `_addr` deployed bytecode
Forked from: https://gist.github.com/KardanovIR/fe98661df9338c842b4a30306d507fbd
*/
function codeAt(address _addr, uint256 _start, uint256 _end) internal view returns (bytes memory oCode) {
uint256 csize = codeSize(_addr);
if (csize == 0) return bytes("");
if (_start > csize) return bytes("");
if (_end < _start) revert InvalidCodeAtRange(csize, _start, _end);
unchecked {
uint256 reqSize = _end - _start;
uint256 maxSize = csize - _start;
uint256 size = maxSize < reqSize ? maxSize : reqSize;
assembly {
// allocate output byte array - this could also be done without assembly
// by using o_code = new bytes(size)
oCode := mload(0x40)
// new "memory end" including padding
mstore(0x40, add(oCode, and(add(add(size, 0x20), 0x1f), not(0x1f))))
// store length in memory
mstore(oCode, size)
// actually retrieve the code, this needs assembly
extcodecopy(_addr, add(oCode, 0x20), _start, size)
}
}
}
}
ERC721A.sol 1091 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs
pragma solidity ^0.8.4;
import './IERC721A.sol';
/**
* @dev Interface of ERC721 token receiver.
*/
interface ERC721A__IERC721Receiver {
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
/**
* @title ERC721A
*
* @dev Implementation of the [ERC721](https://eips.ethereum.org/EIPS/eip-721)
* Non-Fungible Token Standard, including the Metadata extension.
* Optimized for lower gas during batch mints.
*
* Token IDs are minted in sequential order (e.g. 0, 1, 2, 3, ...)
* starting from `_startTokenId()`.
*
* Assumptions:
*
* - An owner cannot have more than 2**64 - 1 (max value of uint64) of supply.
* - The maximum token ID cannot exceed 2**256 - 1 (max value of uint256).
*/
contract ERC721A is IERC721A {
// Bypass for a `--via-ir` bug (https://github.com/chiru-labs/ERC721A/pull/364).
struct TokenApprovalRef {
address value;
}
// =============================================================
// CONSTANTS
// =============================================================
// Mask of an entry in packed address data.
uint256 private constant _BITMASK_ADDRESS_DATA_ENTRY = (1 << 64) - 1;
// The bit position of `numberMinted` in packed address data.
uint256 private constant _BITPOS_NUMBER_MINTED = 64;
// The bit position of `numberBurned` in packed address data.
uint256 private constant _BITPOS_NUMBER_BURNED = 128;
// The bit position of `aux` in packed address data.
uint256 private constant _BITPOS_AUX = 192;
// Mask of all 256 bits in packed address data except the 64 bits for `aux`.
uint256 private constant _BITMASK_AUX_COMPLEMENT = (1 << 192) - 1;
// The bit position of `startTimestamp` in packed ownership.
uint256 private constant _BITPOS_START_TIMESTAMP = 160;
// The bit mask of the `burned` bit in packed ownership.
uint256 private constant _BITMASK_BURNED = 1 << 224;
// The bit position of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITPOS_NEXT_INITIALIZED = 225;
// The bit mask of the `nextInitialized` bit in packed ownership.
uint256 private constant _BITMASK_NEXT_INITIALIZED = 1 << 225;
// The bit position of `extraData` in packed ownership.
uint256 private constant _BITPOS_EXTRA_DATA = 232;
// Mask of all 256 bits in a packed ownership except the 24 bits for `extraData`.
uint256 private constant _BITMASK_EXTRA_DATA_COMPLEMENT = (1 << 232) - 1;
// The mask of the lower 160 bits for addresses.
uint256 private constant _BITMASK_ADDRESS = (1 << 160) - 1;
// The maximum `quantity` that can be minted with {_mintERC2309}.
// This limit is to prevent overflows on the address data entries.
// For a limit of 5000, a total of 3.689e15 calls to {_mintERC2309}
// is required to cause an overflow, which is unrealistic.
uint256 private constant _MAX_MINT_ERC2309_QUANTITY_LIMIT = 5000;
// The `Transfer` event signature is given by:
// `keccak256(bytes("Transfer(address,address,uint256)"))`.
bytes32 private constant _TRANSFER_EVENT_SIGNATURE =
0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef;
// =============================================================
// STORAGE
// =============================================================
// The next token ID to be minted.
uint256 private _currentIndex;
// The number of tokens burned.
uint256 private _burnCounter;
// 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 {_packedOwnershipOf} implementation for details.
//
// Bits Layout:
// - [0..159] `addr`
// - [160..223] `startTimestamp`
// - [224] `burned`
// - [225] `nextInitialized`
// - [232..255] `extraData`
mapping(uint256 => uint256) private _packedOwnerships;
// Mapping owner address to address data.
//
// Bits Layout:
// - [0..63] `balance`
// - [64..127] `numberMinted`
// - [128..191] `numberBurned`
// - [192..255] `aux`
mapping(address => uint256) private _packedAddressData;
// Mapping from token ID to approved address.
mapping(uint256 => TokenApprovalRef) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
// =============================================================
// CONSTRUCTOR
// =============================================================
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
_currentIndex = _startTokenId();
}
// =============================================================
// TOKEN COUNTING OPERATIONS
// =============================================================
/**
* @dev Returns the starting token ID.
* To change the starting token ID, please override this function.
*/
function _startTokenId() internal view virtual returns (uint256) {
return 0;
}
/**
* @dev Returns the next token ID to be minted.
*/
function _nextTokenId() internal view virtual returns (uint256) {
return _currentIndex;
}
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() public view virtual override returns (uint256) {
// Counter underflow is impossible as _burnCounter cannot be incremented
// more than `_currentIndex - _startTokenId()` times.
unchecked {
return _currentIndex - _burnCounter - _startTokenId();
}
}
/**
* @dev Returns the total amount of tokens minted in the contract.
*/
function _totalMinted() internal view virtual returns (uint256) {
// Counter underflow is impossible as `_currentIndex` does not decrement,
// and it is initialized to `_startTokenId()`.
unchecked {
return _currentIndex - _startTokenId();
}
}
/**
* @dev Returns the total number of tokens burned.
*/
function _totalBurned() internal view virtual returns (uint256) {
return _burnCounter;
}
// =============================================================
// ADDRESS DATA OPERATIONS
// =============================================================
/**
* @dev Returns the number of tokens in `owner`'s account.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
if (owner == address(0)) revert BalanceQueryForZeroAddress();
return _packedAddressData[owner] & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the number of tokens minted by `owner`.
*/
function _numberMinted(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_MINTED) & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the number of tokens burned by or on behalf of `owner`.
*/
function _numberBurned(address owner) internal view returns (uint256) {
return (_packedAddressData[owner] >> _BITPOS_NUMBER_BURNED) & _BITMASK_ADDRESS_DATA_ENTRY;
}
/**
* Returns the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
*/
function _getAux(address owner) internal view returns (uint64) {
return uint64(_packedAddressData[owner] >> _BITPOS_AUX);
}
/**
* Sets the auxiliary data for `owner`. (e.g. number of whitelist mint slots used).
* If there are multiple variables, please pack them into a uint64.
*/
function _setAux(address owner, uint64 aux) internal virtual {
uint256 packed = _packedAddressData[owner];
uint256 auxCasted;
// Cast `aux` with assembly to avoid redundant masking.
assembly {
auxCasted := aux
}
packed = (packed & _BITMASK_AUX_COMPLEMENT) | (auxCasted << _BITPOS_AUX);
_packedAddressData[owner] = packed;
}
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
// The interface IDs are constants representing the first 4 bytes
// of the XOR of all function selectors in the interface.
// See: [ERC165](https://eips.ethereum.org/EIPS/eip-165)
// (e.g. `bytes4(i.functionA.selector ^ i.functionB.selector ^ ...)`)
return
interfaceId == 0x01ffc9a7 || // ERC165 interface ID for ERC165.
interfaceId == 0x80ac58cd || // ERC165 interface ID for ERC721.
interfaceId == 0x5b5e139f; // ERC165 interface ID for ERC721Metadata.
}
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @dev Returns the token collection name.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev Returns the token collection symbol.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
if (!_exists(tokenId)) revert URIQueryForNonexistentToken();
string memory baseURI = _baseURI();
return bytes(baseURI).length != 0 ? string(abi.encodePacked(baseURI, _toString(tokenId))) : '';
}
/**
* @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, it can be overridden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return '';
}
// =============================================================
// OWNERSHIPS OPERATIONS
// =============================================================
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
return address(uint160(_packedOwnershipOf(tokenId)));
}
/**
* @dev Gas spent here starts off proportional to the maximum mint batch size.
* It gradually moves to O(1) as tokens get transferred around over time.
*/
function _ownershipOf(uint256 tokenId) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnershipOf(tokenId));
}
/**
* @dev Returns the unpacked `TokenOwnership` struct at `index`.
*/
function _ownershipAt(uint256 index) internal view virtual returns (TokenOwnership memory) {
return _unpackedOwnership(_packedOwnerships[index]);
}
/**
* @dev Initializes the ownership slot minted at `index` for efficiency purposes.
*/
function _initializeOwnershipAt(uint256 index) internal virtual {
if (_packedOwnerships[index] == 0) {
_packedOwnerships[index] = _packedOwnershipOf(index);
}
}
/**
* Returns the packed ownership data of `tokenId`.
*/
function _packedOwnershipOf(uint256 tokenId) private view returns (uint256) {
uint256 curr = tokenId;
unchecked {
if (_startTokenId() <= curr)
if (curr < _currentIndex) {
uint256 packed = _packedOwnerships[curr];
// If not burned.
if (packed & _BITMASK_BURNED == 0) {
// Invariant:
// There will always be an initialized ownership slot
// (i.e. `ownership.addr != address(0) && ownership.burned == false`)
// before an unintialized ownership slot
// (i.e. `ownership.addr == address(0) && ownership.burned == false`)
// Hence, `curr` will not underflow.
//
// We can directly compare the packed value.
// If the address is zero, packed will be zero.
while (packed == 0) {
packed = _packedOwnerships[--curr];
}
return packed;
}
}
}
revert OwnerQueryForNonexistentToken();
}
/**
* @dev Returns the unpacked `TokenOwnership` struct from `packed`.
*/
function _unpackedOwnership(uint256 packed) private pure returns (TokenOwnership memory ownership) {
ownership.addr = address(uint160(packed));
ownership.startTimestamp = uint64(packed >> _BITPOS_START_TIMESTAMP);
ownership.burned = packed & _BITMASK_BURNED != 0;
ownership.extraData = uint24(packed >> _BITPOS_EXTRA_DATA);
}
/**
* @dev Packs ownership data into a single uint256.
*/
function _packOwnershipData(address owner, uint256 flags) private view returns (uint256 result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// `owner | (block.timestamp << _BITPOS_START_TIMESTAMP) | flags`.
result := or(owner, or(shl(_BITPOS_START_TIMESTAMP, timestamp()), flags))
}
}
/**
* @dev Returns the `nextInitialized` flag set if `quantity` equals 1.
*/
function _nextInitializedFlag(uint256 quantity) private pure returns (uint256 result) {
// For branchless setting of the `nextInitialized` flag.
assembly {
// `(quantity == 1) << _BITPOS_NEXT_INITIALIZED`.
result := shl(_BITPOS_NEXT_INITIALIZED, eq(quantity, 1))
}
}
// =============================================================
// APPROVAL OPERATIONS
// =============================================================
/**
* @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) public payable virtual override {
address owner = ownerOf(tokenId);
if (_msgSenderERC721A() != owner)
if (!isApprovedForAll(owner, _msgSenderERC721A())) {
revert ApprovalCallerNotOwnerNorApproved();
}
_tokenApprovals[tokenId].value = to;
emit Approval(owner, to, tokenId);
}
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
if (!_exists(tokenId)) revert ApprovalQueryForNonexistentToken();
return _tokenApprovals[tokenId].value;
}
/**
* @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) public virtual override {
_operatorApprovals[_msgSenderERC721A()][operator] = approved;
emit ApprovalForAll(_msgSenderERC721A(), operator, approved);
}
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @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. See {_mint}.
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return
_startTokenId() <= tokenId &&
tokenId < _currentIndex && // If within bounds,
_packedOwnerships[tokenId] & _BITMASK_BURNED == 0; // and not burned.
}
/**
* @dev Returns whether `msgSender` is equal to `approvedAddress` or `owner`.
*/
function _isSenderApprovedOrOwner(
address approvedAddress,
address owner,
address msgSender
) private pure returns (bool result) {
assembly {
// Mask `owner` to the lower 160 bits, in case the upper bits somehow aren't clean.
owner := and(owner, _BITMASK_ADDRESS)
// Mask `msgSender` to the lower 160 bits, in case the upper bits somehow aren't clean.
msgSender := and(msgSender, _BITMASK_ADDRESS)
// `msgSender == owner || msgSender == approvedAddress`.
result := or(eq(msgSender, owner), eq(msgSender, approvedAddress))
}
}
/**
* @dev Returns the storage slot and value for the approved address of `tokenId`.
*/
function _getApprovedSlotAndAddress(uint256 tokenId)
private
view
returns (uint256 approvedAddressSlot, address approvedAddress)
{
TokenApprovalRef storage tokenApproval = _tokenApprovals[tokenId];
// The following is equivalent to `approvedAddress = _tokenApprovals[tokenId].value`.
assembly {
approvedAddressSlot := tokenApproval.slot
approvedAddress := sload(approvedAddressSlot)
}
}
// =============================================================
// TRANSFER OPERATIONS
// =============================================================
/**
* @dev Transfers `tokenId` from `from` to `to`.
*
* 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
) public payable virtual override {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
if (address(uint160(prevOwnershipPacked)) != from) revert TransferFromIncorrectOwner();
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
if (to == address(0)) revert TransferToZeroAddress();
_beforeTokenTransfers(from, to, tokenId, 1);
// Clear approvals from the previous owner.
assembly {
if approvedAddress {
// This is equivalent to `delete _tokenApprovals[tokenId]`.
sstore(approvedAddressSlot, 0)
}
}
// 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 {
// We can directly increment and decrement the balances.
--_packedAddressData[from]; // Updates: `balance -= 1`.
++_packedAddressData[to]; // Updates: `balance += 1`.
// Updates:
// - `address` to the next owner.
// - `startTimestamp` to the timestamp of transfering.
// - `burned` to `false`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
to,
_BITMASK_NEXT_INITIALIZED | _nextExtraData(from, to, prevOwnershipPacked)
);
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
// If the next slot's address is zero and not burned (i.e. packed value is zero).
if (_packedOwnerships[nextTokenId] == 0) {
// If the next slot is within bounds.
if (nextTokenId != _currentIndex) {
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
emit Transfer(from, to, tokenId);
_afterTokenTransfers(from, to, tokenId, 1);
}
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public payable virtual override {
safeTransferFrom(from, to, tokenId, '');
}
/**
* @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 memory _data
) public payable virtual override {
transferFrom(from, to, tokenId);
if (to.code.length != 0)
if (!_checkContractOnERC721Received(from, to, tokenId, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
}
/**
* @dev Hook that is called before a set of serially-ordered token IDs
* are about to be transferred. This includes minting.
* And also called before burning one token.
*
* `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`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
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.
* And also called after one token has been burned.
*
* `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` has been
* transferred to `to`.
* - When `from` is zero, `tokenId` has been minted for `to`.
* - When `to` is zero, `tokenId` has been burned by `from`.
* - `from` and `to` are never both zero.
*/
function _afterTokenTransfers(
address from,
address to,
uint256 startTokenId,
uint256 quantity
) internal virtual {}
/**
* @dev Private function to invoke {IERC721Receiver-onERC721Received} on a target contract.
*
* `from` - Previous owner of the given token ID.
* `to` - Target address that will receive the token.
* `tokenId` - Token ID to be transferred.
* `_data` - Optional data to send along with the call.
*
* Returns whether the call correctly returned the expected magic value.
*/
function _checkContractOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
try ERC721A__IERC721Receiver(to).onERC721Received(_msgSenderERC721A(), from, tokenId, _data) returns (
bytes4 retval
) {
return retval == ERC721A__IERC721Receiver(to).onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert TransferToNonERC721ReceiverImplementer();
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
}
// =============================================================
// MINT OPERATIONS
// =============================================================
/**
* @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 for each mint.
*/
function _mint(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (quantity == 0) revert MintZeroQuantity();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are incredibly unrealistic.
// `balance` and `numberMinted` have a maximum limit of 2**64.
// `tokenId` has a maximum limit of 2**256.
unchecked {
// Updates:
// - `balance += quantity`.
// - `numberMinted += quantity`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `quantity == 1`.
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
uint256 toMasked;
uint256 end = startTokenId + quantity;
// Use assembly to loop and emit the `Transfer` event for gas savings.
// The duplicated `log4` removes an extra check and reduces stack juggling.
// The assembly, together with the surrounding Solidity code, have been
// delicately arranged to nudge the compiler into producing optimized opcodes.
assembly {
// Mask `to` to the lower 160 bits, in case the upper bits somehow aren't clean.
toMasked := and(to, _BITMASK_ADDRESS)
// Emit the `Transfer` event.
log4(
0, // Start of data (0, since no data).
0, // End of data (0, since no data).
_TRANSFER_EVENT_SIGNATURE, // Signature.
0, // `address(0)`.
toMasked, // `to`.
startTokenId // `tokenId`.
)
// The `iszero(eq(,))` check ensures that large values of `quantity`
// that overflows uint256 will make the loop run out of gas.
// The compiler will optimize the `iszero` away for performance.
for {
let tokenId := add(startTokenId, 1)
} iszero(eq(tokenId, end)) {
tokenId := add(tokenId, 1)
} {
// Emit the `Transfer` event. Similar to above.
log4(0, 0, _TRANSFER_EVENT_SIGNATURE, 0, toMasked, tokenId)
}
}
if (toMasked == 0) revert MintToZeroAddress();
_currentIndex = end;
}
_afterTokenTransfers(address(0), to, startTokenId, quantity);
}
/**
* @dev Mints `quantity` tokens and transfers them to `to`.
*
* This function is intended for efficient minting only during contract creation.
*
* It emits only one {ConsecutiveTransfer} as defined in
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309),
* instead of a sequence of {Transfer} event(s).
*
* Calling this function outside of contract creation WILL make your contract
* non-compliant with the ERC721 standard.
* For full ERC721 compliance, substituting ERC721 {Transfer} event(s) with the ERC2309
* {ConsecutiveTransfer} event is only permissible during contract creation.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `quantity` must be greater than 0.
*
* Emits a {ConsecutiveTransfer} event.
*/
function _mintERC2309(address to, uint256 quantity) internal virtual {
uint256 startTokenId = _currentIndex;
if (to == address(0)) revert MintToZeroAddress();
if (quantity == 0) revert MintZeroQuantity();
if (quantity > _MAX_MINT_ERC2309_QUANTITY_LIMIT) revert MintERC2309QuantityExceedsLimit();
_beforeTokenTransfers(address(0), to, startTokenId, quantity);
// Overflows are unrealistic due to the above check for `quantity` to be below the limit.
unchecked {
// Updates:
// - `balance += quantity`.
// - `numberMinted += quantity`.
//
// We can directly add to the `balance` and `numberMinted`.
_packedAddressData[to] += quantity * ((1 << _BITPOS_NUMBER_MINTED) | 1);
// Updates:
// - `address` to the owner.
// - `startTimestamp` to the timestamp of minting.
// - `burned` to `false`.
// - `nextInitialized` to `quantity == 1`.
_packedOwnerships[startTokenId] = _packOwnershipData(
to,
_nextInitializedFlag(quantity) | _nextExtraData(address(0), to, 0)
);
emit ConsecutiveTransfer(startTokenId, startTokenId + quantity - 1, address(0), to);
_currentIndex = startTokenId + quantity;
}
_afterTokenTransfers(address(0), to, startTokenId, 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.
*
* See {_mint}.
*
* Emits a {Transfer} event for each mint.
*/
function _safeMint(
address to,
uint256 quantity,
bytes memory _data
) internal virtual {
_mint(to, quantity);
unchecked {
if (to.code.length != 0) {
uint256 end = _currentIndex;
uint256 index = end - quantity;
do {
if (!_checkContractOnERC721Received(address(0), to, index++, _data)) {
revert TransferToNonERC721ReceiverImplementer();
}
} while (index < end);
// Reentrancy protection.
if (_currentIndex != end) revert();
}
}
}
/**
* @dev Equivalent to `_safeMint(to, quantity, '')`.
*/
function _safeMint(address to, uint256 quantity) internal virtual {
_safeMint(to, quantity, '');
}
// =============================================================
// BURN OPERATIONS
// =============================================================
/**
* @dev Equivalent to `_burn(tokenId, false)`.
*/
function _burn(uint256 tokenId) internal virtual {
_burn(tokenId, false);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId, bool approvalCheck) internal virtual {
uint256 prevOwnershipPacked = _packedOwnershipOf(tokenId);
address from = address(uint160(prevOwnershipPacked));
(uint256 approvedAddressSlot, address approvedAddress) = _getApprovedSlotAndAddress(tokenId);
if (approvalCheck) {
// The nested ifs save around 20+ gas over a compound boolean condition.
if (!_isSenderApprovedOrOwner(approvedAddress, from, _msgSenderERC721A()))
if (!isApprovedForAll(from, _msgSenderERC721A())) revert TransferCallerNotOwnerNorApproved();
}
_beforeTokenTransfers(from, address(0), tokenId, 1);
// Clear approvals from the previous owner.
assembly {
if approvedAddress {
// This is equivalent to `delete _tokenApprovals[tokenId]`.
sstore(approvedAddressSlot, 0)
}
}
// 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 {
// Updates:
// - `balance -= 1`.
// - `numberBurned += 1`.
//
// We can directly decrement the balance, and increment the number burned.
// This is equivalent to `packed -= 1; packed += 1 << _BITPOS_NUMBER_BURNED;`.
_packedAddressData[from] += (1 << _BITPOS_NUMBER_BURNED) - 1;
// Updates:
// - `address` to the last owner.
// - `startTimestamp` to the timestamp of burning.
// - `burned` to `true`.
// - `nextInitialized` to `true`.
_packedOwnerships[tokenId] = _packOwnershipData(
from,
(_BITMASK_BURNED | _BITMASK_NEXT_INITIALIZED) | _nextExtraData(from, address(0), prevOwnershipPacked)
);
// If the next slot may not have been initialized (i.e. `nextInitialized == false`) .
if (prevOwnershipPacked & _BITMASK_NEXT_INITIALIZED == 0) {
uint256 nextTokenId = tokenId + 1;
// If the next slot's address is zero and not burned (i.e. packed value is zero).
if (_packedOwnerships[nextTokenId] == 0) {
// If the next slot is within bounds.
if (nextTokenId != _currentIndex) {
// Initialize the next slot to maintain correctness for `ownerOf(tokenId + 1)`.
_packedOwnerships[nextTokenId] = prevOwnershipPacked;
}
}
}
}
emit Transfer(from, address(0), tokenId);
_afterTokenTransfers(from, address(0), tokenId, 1);
// Overflow not possible, as _burnCounter cannot be exceed _currentIndex times.
unchecked {
_burnCounter++;
}
}
// =============================================================
// EXTRA DATA OPERATIONS
// =============================================================
/**
* @dev Directly sets the extra data for the ownership data `index`.
*/
function _setExtraDataAt(uint256 index, uint24 extraData) internal virtual {
uint256 packed = _packedOwnerships[index];
if (packed == 0) revert OwnershipNotInitializedForExtraData();
uint256 extraDataCasted;
// Cast `extraData` with assembly to avoid redundant masking.
assembly {
extraDataCasted := extraData
}
packed = (packed & _BITMASK_EXTRA_DATA_COMPLEMENT) | (extraDataCasted << _BITPOS_EXTRA_DATA);
_packedOwnerships[index] = packed;
}
/**
* @dev Called during each token transfer to set the 24bit `extraData` field.
* Intended to be overridden by the cosumer contract.
*
* `previousExtraData` - the value of `extraData` before transfer.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, `from`'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, `tokenId` will be burned by `from`.
* - `from` and `to` are never both zero.
*/
function _extraData(
address from,
address to,
uint24 previousExtraData
) internal view virtual returns (uint24) {}
/**
* @dev Returns the next extra data for the packed ownership data.
* The returned result is shifted into position.
*/
function _nextExtraData(
address from,
address to,
uint256 prevOwnershipPacked
) private view returns (uint256) {
uint24 extraData = uint24(prevOwnershipPacked >> _BITPOS_EXTRA_DATA);
return uint256(_extraData(from, to, extraData)) << _BITPOS_EXTRA_DATA;
}
// =============================================================
// OTHER OPERATIONS
// =============================================================
/**
* @dev Returns the message sender (defaults to `msg.sender`).
*
* If you are writing GSN compatible contracts, you need to override this function.
*/
function _msgSenderERC721A() internal view virtual returns (address) {
return msg.sender;
}
/**
* @dev Converts a uint256 to its ASCII string decimal representation.
*/
function _toString(uint256 value) internal pure virtual returns (string memory str) {
assembly {
// The maximum value of a uint256 contains 78 digits (1 byte per digit), but
// we allocate 0xa0 bytes to keep the free memory pointer 32-byte word aligned.
// We will need 1 word for the trailing zeros padding, 1 word for the length,
// and 3 words for a maximum of 78 digits. Total: 5 * 0x20 = 0xa0.
let m := add(mload(0x40), 0xa0)
// Update the free memory pointer to allocate.
mstore(0x40, m)
// Assign the `str` to the end.
str := sub(m, 0x20)
// Zeroize the slot after the string.
mstore(str, 0)
// Cache the end of the memory to calculate the length later.
let end := str
// We write the string from rightmost digit to leftmost digit.
// The following is essentially a do-while loop that also handles the zero case.
// prettier-ignore
for { let temp := value } 1 {} {
str := sub(str, 1)
// Write the character to the pointer.
// The ASCII index of the '0' character is 48.
mstore8(str, add(48, mod(temp, 10)))
// Keep dividing `temp` until zero.
temp := div(temp, 10)
// prettier-ignore
if iszero(temp) { break }
}
let length := sub(end, str)
// Move the pointer 32 bytes leftwards to make room for the length.
str := sub(str, 0x20)
// Store the length.
mstore(str, length)
}
}
}
IERC721A.sol 282 lines
// SPDX-License-Identifier: MIT
// ERC721A Contracts v4.2.3
// Creator: Chiru Labs
pragma solidity ^0.8.4;
/**
* @dev Interface of ERC721A.
*/
interface IERC721A {
/**
* The caller must own the token or be an approved operator.
*/
error ApprovalCallerNotOwnerNorApproved();
/**
* The token does not exist.
*/
error ApprovalQueryForNonexistentToken();
/**
* Cannot query the balance for the zero address.
*/
error BalanceQueryForZeroAddress();
/**
* Cannot mint to the zero address.
*/
error MintToZeroAddress();
/**
* The quantity of tokens minted must be more than zero.
*/
error MintZeroQuantity();
/**
* The token does not exist.
*/
error OwnerQueryForNonexistentToken();
/**
* The caller must own the token or be an approved operator.
*/
error TransferCallerNotOwnerNorApproved();
/**
* The token must be owned by `from`.
*/
error TransferFromIncorrectOwner();
/**
* Cannot safely transfer to a contract that does not implement the
* ERC721Receiver interface.
*/
error TransferToNonERC721ReceiverImplementer();
/**
* Cannot transfer to the zero address.
*/
error TransferToZeroAddress();
/**
* The token does not exist.
*/
error URIQueryForNonexistentToken();
/**
* The `quantity` minted with ERC2309 exceeds the safety limit.
*/
error MintERC2309QuantityExceedsLimit();
/**
* The `extraData` cannot be set on an unintialized ownership slot.
*/
error OwnershipNotInitializedForExtraData();
// =============================================================
// STRUCTS
// =============================================================
struct TokenOwnership {
// The address of the owner.
address addr;
// Stores the start time of ownership with minimal overhead for tokenomics.
uint64 startTimestamp;
// Whether the token has been burned.
bool burned;
// Arbitrary data similar to `startTimestamp` that can be set via {_extraData}.
uint24 extraData;
}
// =============================================================
// TOKEN COUNTERS
// =============================================================
/**
* @dev Returns the total number of tokens in existence.
* Burned tokens will reduce the count.
* To get the total number of tokens minted, please see {_totalMinted}.
*/
function totalSupply() external view returns (uint256);
// =============================================================
// IERC165
// =============================================================
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* [EIP section](https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified)
* to learn more about how these ids are created.
*
* This function call must use less than 30000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
// =============================================================
// IERC721
// =============================================================
/**
* @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,
bytes calldata data
) external payable;
/**
* @dev Equivalent to `safeTransferFrom(from, to, tokenId, '')`.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external payable;
/**
* @dev Transfers `tokenId` 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 payable;
/**
* @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 payable;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom}
* for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
// =============================================================
// IERC721Metadata
// =============================================================
/**
* @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);
// =============================================================
// IERC2309
// =============================================================
/**
* @dev Emitted when tokens in `fromTokenId` to `toTokenId`
* (inclusive) is transferred from `from` to `to`, as defined in the
* [ERC2309](https://eips.ethereum.org/EIPS/eip-2309) standard.
*
* See {_mintERC2309} for more details.
*/
event ConsecutiveTransfer(uint256 indexed fromTokenId, uint256 toTokenId, address indexed from, address indexed to);
}
Phase4_Playground.sol 846 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
/*
██
██████ ██
██ ██ ██
██ ██ █████
██ ██
██████
██████ ███ ██
██ ██ ████ ██
██ ██ ██ ██ ██
██ ██ ██ ██ ██
██████ ██ ████
██████ ██ ██ █████ ██ ███ ██
██ ██ ██ ██ ██ ██ ████ ██
██ ███████ ███████ ██ ██ ██ ██
██ ██ ██ ██ ██ ██ ██ ██ ██
██████ ██ ██ ██ ██ ██ ██ ████
███ ███ ███████ ███████ ██████ ███████
████ ████ ██ ██ ██ ██ ██
██ ████ ██ █████ █████ ██████ ███████
██ ██ ██ ██ ██ ██ ██ ██
██ ██ ██ ███████ ██ ██ ███████
(phase 4)
vision: @DadMod_xyz & @galtoshi
art: @thompsonNFT
devs: @JofaMcBender & @0xSomeGuy
with the support of:
sartoshi: 0xF95752fD023fD8802Abdd9cbe8e9965F623F8A84
mfer community: 0x79FCDEF22feeD20eDDacbB2587640e45491b757f
*/
import "./extras/SSTORE2.sol";
import "erc721a/contracts/ERC721A.sol";
import "@openzeppelin/contracts/utils/Base64.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/security/ReentrancyGuard.sol";
error WhoaFriendCantUpdateGoodiesForTokensYouDontOwn();
error NaahhhhhhhhhhThisIndexNeedsMoreThanEightBits();
error DaaaaaaaaangThisMferIsAlreadyTaken();
error SorryCouldntWithdrawYourFundsDude();
error NeedTheRightFundsToMintHomie();
error ThisTokenIsLostInSpace();
error PartyIsDeadAtTheMoment();
error ThisDnaIsNoGoodAmigo();
error NoFreeMintsHomie();
contract OnChainMfersPlayground is ERC721A, Ownable, ReentrancyGuard
{
//-------------------------------------------------------------------------
//
// contract shiz
//
//-------------------------------------------------------------------------
constructor() ERC721A("OnChainMfersPlayground", "FAFO")
{
JeffFromAccounting = msg.sender;
// nothing else to see here folks 👇
}
// mint status
bool public IsPartyStarted;
// toggle mint status
function letsGetThisPartyStarted() external onlyOwner
{
IsPartyStarted = !IsPartyStarted;
}
// mint price
uint256 public PlaygroundMintPrice;
// update mint price, will attempt to always keep mint price at ~$69 USD
function updateMintPrice(uint256 _newPrice) external onlyOwner
{
PlaygroundMintPrice = _newPrice;
}
// maps token index to dna
mapping (uint256 => uint256) public TokenToDnaMap;
// maps dna to claimed status to avoid dupes
mapping (uint256 => bool) public PlaygroundDnaToClaimedMap;
// maps address to number of free claims
mapping (address => uint256) public AddressToFreebiesMap;
// maps token to special status
mapping (uint256 => bool) public TokenToIsSpecialMap;
// maps token to special pointers
mapping (uint256 => address[]) public TokenToSpecialPointersMap;
// maps token index to goodies enabled for individual tokens
mapping(uint256 => bool) public TokenToGoodiesMap;
// svg strings
string[7] public SvgStrings;
// metadata strings
string[8] public MetadataStrings;
// trait counts for dna check
uint256[14] public TraitCounts;
// infinity symbol
string public InfinityString;
// sartoshi signature
string public SartoshiString;
// goodies go before this trait index
uint256 public GoodiesPosition;
// goodie string
string[2] public DaGoodies;
// bool to enable or disable goodies in collection
bool public GoodiesEnabled;
// contract address for the layer contract to pull/read trait assets
IMferLayers private MferLayerContract = IMferLayers(address(0x5377c667acc68ea7cc5768D75388d7a97af5492c));
// update layer contract address
function setLayerContractAddress(address _newAddress) external onlyOwner
{
MferLayerContract = IMferLayers(address(_newAddress));
}
// on chain mfers contract to check if og dnas are trying to be used
IOgChainContract private OgChainContract = IOgChainContract(address(0xF647f29860335E064fAc9f1Fe28BC8C9fd5331b0));
// update chain contract address
function setChainContractAddress(address _newAddress) external onlyOwner
{
OgChainContract = IOgChainContract(address(_newAddress));
}
//-------------------------------------------------------------------------
//
// erc721 functions
//
//-------------------------------------------------------------------------
// start token id override
function _startTokenId() internal view override returns (uint256)
{
return 10021;
}
// free mint
function freePlaygroundMint(uint256 _dna) public
{
// check if free mints available
if(AddressToFreebiesMap[msg.sender] == 0) revert NoFreeMintsHomie();
// decrease free mint count
AddressToFreebiesMap[msg.sender]--;
// mint
mintOnChainMfer(_dna);
}
// paid mint
function paidPlaygroundMint(uint256 _dna) public payable
{
// check payment
if(msg.value != PlaygroundMintPrice) revert NeedTheRightFundsToMintHomie();
// mint
mintOnChainMfer(_dna);
}
// mint mint
function mintOnChainMfer(uint256 _dna) private nonReentrant
{
// check if mint is active
if(!IsPartyStarted) revert PartyIsDeadAtTheMoment();
// check if dna is valid
if(!isDnaValid(_dna)) revert ThisDnaIsNoGoodAmigo();
// check if og dna taken
if(OgChainContract.DnaToClaimedMap(_dna)) revert DaaaaaaaaangThisMferIsAlreadyTaken();
// check if dna is already minted
if(PlaygroundDnaToClaimedMap[_dna]) revert DaaaaaaaaangThisMferIsAlreadyTaken();
// update token to dna map
TokenToDnaMap[_nextTokenId()] = _dna;
// update dna claimed map
PlaygroundDnaToClaimedMap[_dna] = true;
// mint that thing!
_mint(msg.sender, 1);
}
// mint for da ownersssss
function bossMint(uint256 _dna, bool _isSpecial) external onlyOwner
{
// check if minting special token
if(!_isSpecial)
{
// check if og dna taken
if(OgChainContract.DnaToClaimedMap(_dna)) revert DaaaaaaaaangThisMferIsAlreadyTaken();
// check if dna is already minted
if(PlaygroundDnaToClaimedMap[_dna]) revert DaaaaaaaaangThisMferIsAlreadyTaken();
// check if dna is valid
if(!isDnaValid(_dna)) revert ThisDnaIsNoGoodAmigo();
// update token to dna map
TokenToDnaMap[_nextTokenId()] = _dna;
// update dna claimed map
PlaygroundDnaToClaimedMap[_dna] = true;
} else
{
// update special mappings
TokenToIsSpecialMap[_nextTokenId()] = true;
}
// mint that thing!
_mint(msg.sender, 1);
}
// you get a mint, you get a mint
function bestowMintsGratis(address _addy, uint256 _numMints) external onlyOwner
{
AddressToFreebiesMap[_addy] += _numMints;
}
//-------------------------------------------------------------------------
//
// erc721 metadata functions
//
//-------------------------------------------------------------------------
// token uri
function tokenURI(uint256 _tokenId) public view override returns(string memory)
{
// check token exists
if(!_exists(_tokenId)) revert ThisTokenIsLostInSpace();
// check if token is special
if(TokenToIsSpecialMap[_tokenId])
{
return readPointerArray(TokenToSpecialPointersMap[_tokenId]);
}
// check for goodies
bool GoodiesAreOn = (GoodiesEnabled && TokenToGoodiesMap[_tokenId]);
if(GoodiesAreOn)
{
return goodieURI(_tokenId);
} else
{
return nonGoodieURI(_tokenId);
}
}
// get non goodie metadata
function nonGoodieURI(uint256 _tokenId) private view returns(string memory)
{
// get dna
uint256 tokenDna = TokenToDnaMap[_tokenId];
// get temporary variables
IMferLayers.Trait memory trait;
IMferLayers.Layer memory layer;
uint256 attIndex;
bool firstTraitFound;
// metadata
string memory metadata = string.concat(
MetadataStrings[0],
_toString(_tokenId),
MetadataStrings[1]
);
// start the svg image
string memory svg = SvgStrings[0];
// loopty loop
for(uint256 i=0; i<15; i++)
{
// get attribute index
attIndex = getTraitIndex(tokenDna, i);
// check if trait is blank
if(attIndex == 0)
{
// blank trait, keep it moving
continue;
}
// get trait from layer contract
trait = MferLayerContract.getTrait(i);
// get the attribute index
attIndex = attIndex-1;
// get layer from trait
layer = trait.layers[attIndex];
// append layer to svg
svg = string.concat(
svg,
getLayerSvg(layer)
);
// check for surprise
if(i == 2)
{
if(attIndex == 6)
{
svg = string.concat(
svg,
getSurpriseString(0),
SurpriseStuff
);
} else if(attIndex == 2)
{
svg = string.concat(
svg,
getSurpriseString(1),
SurpriseStuff
);
}
}
// update metadata
metadata = string.concat(
metadata,
firstTraitFound ? MetadataStrings[2] : MetadataStrings[3],
trait.name,
MetadataStrings[4],
layer.name,
MetadataStrings[5]
);
// update trait exists for correct metadata
firstTraitFound = true;
}
// complete the svg
svg = string.concat(
svg,
_tokenId > 10024 ? InfinityString : '',
getTraitIndex(tokenDna, 1) == 0 ? SartoshiString : "",
SvgStrings[6]);
// complete the metadata
metadata = string.concat(
metadata,
MetadataStrings[6],
svg,
MetadataStrings[7]
);
// return that shizzle!
return metadata;
}
// get goodie metadata
function goodieURI(uint256 _tokenId) private view returns(string memory)
{
// get dna
uint256 tokenDna = TokenToDnaMap[_tokenId];
// get temporary variables
IMferLayers.Trait memory trait;
IMferLayers.Layer memory layer;
uint256 attIndex;
bool firstTraitFound;
// metadata
string memory metadata = string.concat(
MetadataStrings[0],
_toString(_tokenId),
MetadataStrings[1]
);
// start the svg image
string memory svg = SvgStrings[0];
// loopty loop
for(uint256 i=0; i<15; i++)
{
// check if goodies should be added
if(i == GoodiesPosition)
{
// add goodies
svg = string.concat(
svg,
DaGoodies[0]
);
}
// get attribute index
attIndex = getTraitIndex(tokenDna, i);
// check if trait is blank
if(attIndex == 0)
{
// check if no type trait for sartoshi signature
if(i == 1)
{
svg = string.concat(
svg,
SartoshiString
);
}
// blank trait, keep it moving
continue;
}
// get trait from layer contract
trait = MferLayerContract.getTrait(i);
// get the attribute index
attIndex = attIndex-1;
// get layer from trait
layer = trait.layers[attIndex];
// append layer to svg
svg = string.concat(
svg,
getLayerSvg(layer)
);
// check for surprise
if(i == 2)
{
if(attIndex == 6)
{
svg = string.concat(
svg,
getSurpriseString(0),
SurpriseStuff
);
} else if(attIndex == 2)
{
svg = string.concat(
svg,
getSurpriseString(1),
SurpriseStuff
);
}
}
// check if goodies should be added
if(i == GoodiesPosition)
{
// add goodies
svg = string.concat(
svg,
DaGoodies[1]
);
}
// update metadata
metadata = string.concat(
metadata,
firstTraitFound ? MetadataStrings[2] : MetadataStrings[3],
trait.name,
MetadataStrings[4],
layer.name,
MetadataStrings[5]
);
// update trait exists for correct metadata
firstTraitFound = true;
}
// complete the svg
svg = string.concat(
svg,
_tokenId > 10024 ? InfinityString : '',
getTraitIndex(tokenDna, 1) == 0 ? SartoshiString : "",
SvgStrings[6]);
// complete the metadata
metadata = string.concat(
metadata,
MetadataStrings[6],
svg,
MetadataStrings[7]
);
// return that shizzle!
return metadata;
}
// allows token owners to decide if they want goodies in their image
function toggleTokenGoodies(uint256 _tokenId) public
{
// check if token exists
if(!_exists(_tokenId)) revert ThisTokenIsLostInSpace();
// ensure that msg.sender is token owner
if(msg.sender != ownerOf(_tokenId)) revert WhoaFriendCantUpdateGoodiesForTokensYouDontOwn();
// update goodies
TokenToGoodiesMap[_tokenId] = !TokenToGoodiesMap[_tokenId];
}
// get layer svg
function getLayerSvg(IMferLayers.Layer memory _layer) public view returns(string memory)
{
return string.concat(
SvgStrings[1],
_layer.name,
SvgStrings[2],
_toString(_layer.x),
SvgStrings[3],
_toString(_layer.y),
SvgStrings[4],
readPointerArray(_layer.pointers),
SvgStrings[5]
);
}
// get the suuuuuurprise string
function getSurpriseString(uint256 _index) private view returns(string memory)
{
IMferLayers.Layer memory tempLayer;
if(_index == 0)
{
tempLayer = MferLayerContract.getLayer(2, 2);
return string.concat(
SvgStrings[1],
tempLayer.name,
SvgStrings[2],
_toString(tempLayer.x),
SvgStrings[3],
_toString(tempLayer.y),
SurpriseFiller,
readPointerArray(tempLayer.pointers),
SvgStrings[5]
);
}
tempLayer = MferLayerContract.getLayer(2, 6);
return string.concat(
SvgStrings[1],
tempLayer.name,
SvgStrings[2],
_toString(tempLayer.x),
SvgStrings[3],
_toString(tempLayer.y),
SurpriseFiller,
readPointerArray(tempLayer.pointers),
SvgStrings[5]
);
}
// read array of pointers
function readPointerArray(address[] memory _pointers) public view returns(string memory)
{
// if complex shape not loaded, return empty string
if(_pointers.length == 0)
{
return "";
}
// return layer string
uint256 i;
string memory output;
unchecked
{
do
{
output = string.concat(output, string(SSTORE2.read(_pointers[i])));
++i;
} while(i<_pointers.length);
}
return output;
}
//-------------------------------------------------------------------------
//
// extra tings
//
//-------------------------------------------------------------------------
// update svg strings
function updateSvgStrings(uint256 _index, string memory _newString) external onlyOwner
{
SvgStrings[_index] = _newString;
}
// update metadata strings
function updateMetadataStrings(uint256 _index, string memory _newString) external onlyOwner
{
MetadataStrings[_index] = _newString;
}
// toggle special token
function toggleSpecialStatus(uint256 _tokenId) external onlyOwner
{
TokenToIsSpecialMap[_tokenId] = !TokenToIsSpecialMap[_tokenId];
}
// update special pointers
function addSpecialTokenPointer(uint256 _tokenId, address _pointer) external onlyOwner
{
TokenToSpecialPointersMap[_tokenId].push(_pointer);
}
// reset special token pointers
function resetSpecialTokenPointers(uint256 _tokenId) external onlyOwner
{
delete TokenToSpecialPointersMap[_tokenId];
}
// update infinity string
function setInfinityString(string memory _newString) external onlyOwner
{
InfinityString = _newString;
}
// update sartoshi string
function setSartoshiString(string memory _newString) external onlyOwner
{
SartoshiString = _newString;
}
// update goodies position
function updateGoodiesPosition(uint256 _index) external onlyOwner
{
GoodiesPosition = _index;
}
// update the goodies string
function updateTheGoodies(uint256 _index, string memory _newString) external onlyOwner
{
DaGoodies[_index] = _newString;
}
// toggle goodies enabled for contract
function toggleGoodiesEnabled() external onlyOwner
{
GoodiesEnabled = !GoodiesEnabled;
}
// get surprise stuffs
string private SurpriseStuff;
function updateSurpriseStuff(string memory _newString) external onlyOwner
{
SurpriseStuff = _newString;
}
string private SurpriseFiller;
function setSurpriseFiller(string memory _newString) external onlyOwner
{
SurpriseFiller = _newString;
}
//-------------------------------------------------------------------------
//
// other functions
//
//-------------------------------------------------------------------------
// set token dna
function setTokenDna(uint256 _tokenId, uint256 _dna) external onlyOwner
{
// check if dna is valid
if(!isDnaValid(_dna)) revert ThisDnaIsNoGoodAmigo();
// get current token dna
uint256 curDna = TokenToDnaMap[_tokenId];
// check if dna for this token exists
if(curDna != 0)
{
// clear dna to claimed map
PlaygroundDnaToClaimedMap[curDna] = false;
}
// update token to dna map
TokenToDnaMap[_tokenId] = _dna;
// update dna claimed map
PlaygroundDnaToClaimedMap[_dna] = true;
}
// update trait counts for dna check
function updateTraitCount(uint256 _index, uint256 _count) external onlyOwner
{
TraitCounts[_index] = _count;
}
//-------------------------------------------------------------------------
//
// for your enjoyment
//
//-------------------------------------------------------------------------
// get trait index from dna
function getTraitIndex(uint256 _intDna, uint256 _traitIndex) public pure returns(uint256)
{
// check if trait index is too high
if(_traitIndex > 14) revert("trait index too high");
// get trait index
uint256 bitTraitIndex = 14-_traitIndex;
uint256 bitMask = 255 << (8 * bitTraitIndex);
uint256 value = (_intDna & bitMask) >> (8 * bitTraitIndex);
return value;
}
// check if dna is valid
function isDnaValid(uint256 _dna) public view returns(bool)
{
// check if > than 15 8-bit nubers
if(_dna > ((1 << 120)-1))
{
return false;
}
// check for 0 dna
if(_dna == 0)
{
return false;
}
// get 1/1 trait index
uint256 attIndex = getTraitIndex(_dna, 14);
// check if 1/1 trait used
if(attIndex != 0)
{
// 1/1s are special!
return false;
}
// loopty loop to check individual trait values
for(uint256 i=0; i<14; i++)
{
// get trait index at position i
attIndex = getTraitIndex(_dna, i);
// check if trait index is valid
if(attIndex > TraitCounts[i])
{
return false;
}
}
// all good
return true;
}
// convert uint256[15] into uint256 dna for anyone who wants it
function arrayToDna(uint256[15] memory _dnaArray) public pure returns(uint256)
{
// leggo
uint256 intDna = 0;
// loop through trait array
for (uint256 i = 0; i < 15; i++)
{
// get trait index
uint256 value = _dnaArray[i];
// make sure its 8-bit
if(value >255) revert NaahhhhhhhhhhThisIndexNeedsMoreThanEightBits();
// shift the value to the appropriate position and add trait index
intDna = (intDna << 8) | value;
}
// all done!
return intDna;
}
//-------------------------------------------------------------------------
//
// da rest
//
//-------------------------------------------------------------------------
// withdraw address (nod to NN)
address private JeffFromAccounting;
// update withdraw address
function updateAccountant(address _newAddress) external onlyOwner
{
JeffFromAccounting = _newAddress;
}
// withdraw contract eth
function moveThatGuap() public
{
(bool success, ) = JeffFromAccounting.call{value: address(this).balance}("");
if(!success) revert SorryCouldntWithdrawYourFundsDude();
}
}
// interface for the goodblocks contract
interface IMferLayers
{
// trait data struct
struct Trait
{
string name;
Layer[] layers;
}
// layer data struct
struct Layer
{
uint256 x;
uint256 y;
uint256 width;
uint256 height;
string name;
address layerOwner;
address[] pointers;
}
function getTrait(uint256 _traitIndex) external view returns(Trait memory);
function getLayer(uint256 _traitIndex, uint256 _layerIndex) external view returns(Layer memory);
function readLayerString(uint256 _traitIndex, uint256 _layerIndex) external view returns(string memory);
function ownerOf(uint256) external view returns(address);
}
interface IOgChainContract
{
function DnaToClaimedMap(uint256 key) external view returns (bool);
}
///////////////////////////////////////////////////////////////
// do good ❤ ///////////////////////////////////////////////
///////////////////////////////////////////////////////////////
Base64.sol 92 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.7.0) (utils/Base64.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides a set of functions to operate with Base64 strings.
*
* _Available since v4.5._
*/
library Base64 {
/**
* @dev Base64 Encoding/Decoding Table
*/
string internal constant _TABLE = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
/**
* @dev Converts a `bytes` to its Bytes64 `string` representation.
*/
function encode(bytes memory data) internal pure returns (string memory) {
/**
* Inspired by Brecht Devos (Brechtpd) implementation - MIT licence
* https://github.com/Brechtpd/base64/blob/e78d9fd951e7b0977ddca77d92dc85183770daf4/base64.sol
*/
if (data.length == 0) return "";
// Loads the table into memory
string memory table = _TABLE;
// Encoding takes 3 bytes chunks of binary data from `bytes` data parameter
// and split into 4 numbers of 6 bits.
// The final Base64 length should be `bytes` data length multiplied by 4/3 rounded up
// - `data.length + 2` -> Round up
// - `/ 3` -> Number of 3-bytes chunks
// - `4 *` -> 4 characters for each chunk
string memory result = new string(4 * ((data.length + 2) / 3));
/// @solidity memory-safe-assembly
assembly {
// Prepare the lookup table (skip the first "length" byte)
let tablePtr := add(table, 1)
// Prepare result pointer, jump over length
let resultPtr := add(result, 32)
// Run over the input, 3 bytes at a time
for {
let dataPtr := data
let endPtr := add(data, mload(data))
} lt(dataPtr, endPtr) {
} {
// Advance 3 bytes
dataPtr := add(dataPtr, 3)
let input := mload(dataPtr)
// To write each character, shift the 3 bytes (18 bits) chunk
// 4 times in blocks of 6 bits for each character (18, 12, 6, 0)
// and apply logical AND with 0x3F which is the number of
// the previous character in the ASCII table prior to the Base64 Table
// The result is then added to the table to get the character to write,
// and finally write it in the result pointer but with a left shift
// of 256 (1 byte) - 8 (1 ASCII char) = 248 bits
mstore8(resultPtr, mload(add(tablePtr, and(shr(18, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(shr(12, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(shr(6, input), 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
mstore8(resultPtr, mload(add(tablePtr, and(input, 0x3F))))
resultPtr := add(resultPtr, 1) // Advance
}
// When data `bytes` is not exactly 3 bytes long
// it is padded with `=` characters at the end
switch mod(mload(data), 3)
case 1 {
mstore8(sub(resultPtr, 1), 0x3d)
mstore8(sub(resultPtr, 2), 0x3d)
}
case 2 {
mstore8(sub(resultPtr, 1), 0x3d)
}
}
return result;
}
}
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;
}
}
Ownable.sol 83 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (access/Ownable.sol)
pragma solidity ^0.8.0;
import "../utils/Context.sol";
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
_checkOwner();
_;
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if the sender is not the owner.
*/
function _checkOwner() internal view virtual {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby disabling 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);
}
}
ReentrancyGuard.sol 77 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.9.0) (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() {
_nonReentrantBefore();
_;
_nonReentrantAfter();
}
function _nonReentrantBefore() private {
// On the first call to nonReentrant, _status will be _NOT_ENTERED
require(_status != _ENTERED, "ReentrancyGuard: reentrant call");
// Any calls to nonReentrant after this point will fail
_status = _ENTERED;
}
function _nonReentrantAfter() private {
// By storing the original value once again, a refund is triggered (see
// https://eips.ethereum.org/EIPS/eip-2200)
_status = _NOT_ENTERED;
}
/**
* @dev Returns true if the reentrancy guard is currently set to "entered", which indicates there is a
* `nonReentrant` function in the call stack.
*/
function _reentrancyGuardEntered() internal view returns (bool) {
return _status == _ENTERED;
}
}
Read Contract
AddressToFreebiesMap 0xc161d6f0 → uint256
DaGoodies 0x137c6dee → string
GoodiesEnabled 0x406c1f6b → bool
GoodiesPosition 0x53455f4e → uint256
InfinityString 0x66aac399 → string
IsPartyStarted 0x40629884 → bool
MetadataStrings 0x5af2eff2 → string
PlaygroundDnaToClaimedMap 0xf03d60af → bool
PlaygroundMintPrice 0xfc3dcb44 → uint256
SartoshiString 0x75bc2d71 → string
SvgStrings 0x0b113f65 → string
TokenToDnaMap 0xb69c9625 → uint256
TokenToGoodiesMap 0x919e0763 → bool
TokenToIsSpecialMap 0x96c5085b → bool
TokenToSpecialPointersMap 0x4819564b → address
TraitCounts 0x01a10b4d → uint256
arrayToDna 0x29d625b1 → uint256
balanceOf 0x70a08231 → uint256
getApproved 0x081812fc → address
getLayerSvg 0xcbea7e34 → string
getTraitIndex 0x14449fa7 → uint256
isApprovedForAll 0xe985e9c5 → bool
isDnaValid 0x656225cb → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
readPointerArray 0x277eebd0 → string
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
totalSupply 0x18160ddd → uint256
Write Contract 32 functions
These functions modify contract state and require a wallet transaction to execute.
addSpecialTokenPointer 0x14705d2f
uint256 _tokenId
address _pointer
approve 0x095ea7b3
address to
uint256 tokenId
bestowMintsGratis 0xed6f74a7
address _addy
uint256 _numMints
bossMint 0x4eea60de
uint256 _dna
bool _isSpecial
freePlaygroundMint 0x12a52bf5
uint256 _dna
letsGetThisPartyStarted 0x706f6977
No parameters
moveThatGuap 0x52c9188f
No parameters
paidPlaygroundMint 0x1321d832
uint256 _dna
renounceOwnership 0x715018a6
No parameters
resetSpecialTokenPointers 0x8af35c90
uint256 _tokenId
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setChainContractAddress 0x638681dc
address _newAddress
setInfinityString 0x331bd0e7
string _newString
setLayerContractAddress 0xd2a8fb51
address _newAddress
setSartoshiString 0x1e5cb0f7
string _newString
setSurpriseFiller 0x2cd5027d
string _newString
setTokenDna 0x98a3402a
uint256 _tokenId
uint256 _dna
toggleGoodiesEnabled 0x9ce4b680
No parameters
toggleSpecialStatus 0x2e60ea97
uint256 _tokenId
toggleTokenGoodies 0x90ecdd9d
uint256 _tokenId
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
updateAccountant 0x6c222b17
address _newAddress
updateGoodiesPosition 0x5c0f4cd7
uint256 _index
updateMetadataStrings 0x0ab46fcf
uint256 _index
string _newString
updateMintPrice 0x00728e46
uint256 _newPrice
updateSurpriseStuff 0x43dc27a2
string _newString
updateSvgStrings 0x85e62a0e
uint256 _index
string _newString
updateTheGoodies 0x6767af98
uint256 _index
string _newString
updateTraitCount 0xaa4be35f
uint256 _index
uint256 _count
Token Balances (1)
View Transfers →Recent Transactions
No transactions found for this address