Address Contract Verified
Address
0xBDc14c9946A957C7038900dE19Fb2Aa3f72CFAc2
Balance
0.001866 ETH
Nonce
1
Code Size
10503 bytes
Creator
0xc8fff6BB...B974 at tx 0xe4c92cad...b83ab4
Indexed Transactions
0
Contract Bytecode
10503 bytes
0x60806040526004361061017e575f3560e01c80637129607a116100cd5780638e93366c11610087578063bf333f2c11610062578063bf333f2c14610477578063c1e9267c1461048b578063f2fde38b146104aa578063f64b7385146104c9575f5ffd5b80638e93366c14610420578063af301e451461043f578063babcc53914610458575f5ffd5b80637129607a14610374578063715018a61461039357806375d4d4a5146103a757806387cac0a4146103bc5780638d157db8146103db5780638da5cb5b146103fa575f5ffd5b806347e924af116101385780636177fd18116101135780636177fd18146102d15780636637e38c1461031f57806366c0e6c5146103425780636ae2a99b14610355575f5ffd5b806347e924af146102395780634e5d8bb1146102585780635521406914610277575f5ffd5b806301943c2314610189578063109b7c28146101aa57806312e855ea146101bd57806341dfeca5146101dc57806344004cc1146101fb5780634782f7791461021a575f5ffd5b3661018557005b5f5ffd5b348015610194575f5ffd5b506101a86101a336600461237c565b6104e8565b005b6101a86101b836600461241e565b610500565b3480156101c8575f5ffd5b506101a86101d736600461247b565b610650565b3480156101e7575f5ffd5b506101a86101f6366004612494565b610664565b348015610206575f5ffd5b506101a86102153660046124fd565b6108cf565b348015610225575f5ffd5b506101a8610234366004612537565b610926565b348015610244575f5ffd5b506101a861025336600461255f565b6109c5565b348015610263575f5ffd5b506101a8610272366004612590565b6109db565b348015610282575f5ffd5b506102b46102913660046125d6565b6001600160a01b03165f908152600360205260409020546001600160401b031690565b6040516001600160401b0390911681526020015b60405180910390f35b3480156102dc575f5ffd5b5061030f6102eb3660046125d6565b6001600160a01b03165f90815260036020526040902054600160401b900460ff1690565b60405190151581526020016102c8565b34801561032a575f5ffd5b5061033461271081565b6040519081526020016102c8565b6101a86103503660046125ef565b6109ee565b348015610360575f5ffd5b506101a861036f3660046125ef565b610d57565b34801561037f575f5ffd5b506101a861038e36600461262d565b610d69565b34801561039e575f5ffd5b506101a8610f31565b3480156103b2575f5ffd5b5061033461011881565b3480156103c7575f5ffd5b506101a86103d636600461269f565b610f44565b3480156103e6575f5ffd5b506101a86103f5366004612494565b610f56565b348015610405575f5ffd5b505f546040516001600160a01b0390911681526020016102c8565b34801561042b575f5ffd5b506101a861043a3660046125ef565b6110f2565b34801561044a575f5ffd5b5060025461030f9060ff1681565b348015610463575f5ffd5b5061030f6104723660046125d6565b61154d565b348015610482575f5ffd5b50610334606481565b348015610496575f5ffd5b506101a86104a53660046125ef565b6115bf565b3480156104b5575f5ffd5b506101a86104c43660046125d6565b6119de565b3480156104d4575f5ffd5b506101a86104e33660046125ef565b611a18565b6104f0611db8565b6104fb838383611de4565b505050565b610508611ece565b6001600160a01b03831661052f57604051634e46966960e11b815260040160405180910390fd5b345f0361054f5760405163f2365b5b60e01b815260040160405180910390fd5b6101188111156105725760405163ef3d005b60e01b815260040160405180910390fd5b5f6127106105816064346126db565b61058b91906126f8565b90505f6105988234612717565b90505f856001600160a01b0316826040515f6040518083038185875af1925050503d805f81146105e3576040519150601f19603f3d011682016040523d82523d5f602084013e6105e8565b606091505b505090508061060a57604051630db2c7f160e31b815260040160405180910390fd5b5f336001600160a01b0388165f5160206128b25f395f51905f5288883489875f60405161063c96959493929190612752565b60405180910390a45050506104fb60018055565b610658611db8565b61066181611ef8565b50565b61066c611ece565b6001600160a01b03851661069357604051634e46966960e11b815260040160405180910390fd5b6001600160a01b0383166106ba5760405163c1ab6dc160e01b815260040160405180910390fd5b835f036106da5760405163f2365b5b60e01b815260040160405180910390fd5b6101188111156106fd5760405163ef3d005b60e01b815260040160405180910390fd5b6040516370a0823160e01b815230600482015283905f906001600160a01b038316906370a0823190602401602060405180830381865afa158015610743573d5f5f3e3d5ffd5b505050506040513d601f19601f82011682018060405250810190610767919061278d565b905061077e6001600160a01b038316333089611f3f565b6040516370a0823160e01b81523060048201525f9082906001600160a01b038516906370a0823190602401602060405180830381865afa1580156107c4573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906107e8919061278d565b6107f29190612717565b9050805f03610814576040516311e9444560e01b815260040160405180910390fd5b5f6127106108236064846126db565b61082d91906126f8565b90505f61083a8284612717565b90506108506001600160a01b0386168b83611fa6565b811561087b5761087b61086a5f546001600160a01b031690565b6001600160a01b0387169084611fa6565b6001600160a01b038089169033908c165f5160206128b25f395f51905f528a8a888860015f6040516108b296959493929190612752565b60405180910390a450505050506108c860018055565b5050505050565b6108d7611db8565b6001600160a01b03831615806108f457506001600160a01b038216155b15610912576040516313fe84b160e11b815260040160405180910390fd5b6104fb6001600160a01b0384168383611fa6565b61092e611db8565b6001600160a01b038216610955576040516313fe84b160e11b815260040160405180910390fd5b5f826001600160a01b0316826040515f6040518083038185875af1925050503d805f811461099e576040519150601f19603f3d011682016040523d82523d5f602084013e6109a3565b606091505b50509050806104fb57604051630db2c7f160e31b815260040160405180910390fd5b6109cd611db8565b6109d78282611fd7565b5050565b6109e3611db8565b6104fb838383612045565b6109f6611ece565b805f805b82811015610b35575f858583818110610a1557610a156127a4565b9050602002810190610a2791906127b8565b610a359060208101906125d6565b6001600160a01b031603610a5c57604051634e46966960e11b815260040160405180910390fd5b848482818110610a6e57610a6e6127a4565b9050602002810190610a8091906127b8565b602001355f03610aa35760405163f2365b5b60e01b815260040160405180910390fd5b610118858583818110610ab857610ab86127a4565b9050602002810190610aca91906127b8565b610ad89060408101906127d6565b90501115610af95760405163ef3d005b60e01b815260040160405180910390fd5b848482818110610b0b57610b0b6127a4565b9050602002810190610b1d91906127b8565b610b2b906020013583612818565b91506001016109fa565b50348114610b5657604051632125a1e760e11b815260040160405180910390fd5b5f5b82811015610d4b575f6127106064878785818110610b7857610b786127a4565b9050602002810190610b8a91906127b8565b60200135610b9891906126db565b610ba291906126f8565b90505f81878785818110610bb857610bb86127a4565b9050602002810190610bca91906127b8565b60200135610bd89190612717565b90505f878785818110610bed57610bed6127a4565b9050602002810190610bff91906127b8565b610c0d9060208101906125d6565b6001600160a01b0316826040515f6040518083038185875af1925050503d805f8114610c54576040519150601f19603f3d011682016040523d82523d5f602084013e610c59565b606091505b5050905080610c7b57604051630db2c7f160e31b815260040160405180910390fd5b5f33898987818110610c8f57610c8f6127a4565b9050602002810190610ca191906127b8565b610caf9060208101906125d6565b6001600160a01b03165f5160206128b25f395f51905f528b8b89818110610cd857610cd86127a4565b9050602002810190610cea91906127b8565b610cf89060408101906127d6565b8d8d8b818110610d0a57610d0a6127a4565b9050602002810190610d1c91906127b8565b60200135895f5f604051610d3596959493929190612752565b60405180910390a4836001019350505050610b58565b5050506109d760018055565b610d5f611db8565b6109d7828261211f565b610d71611ece565b60025460ff1615610df157335f908152600360209081526040918290208251808401909352546001600160401b0381168352600160401b900460ff16151590820181905280610dca575080516001600160401b03164211155b610def5760405162461bcd60e51b8152600401610de69061282b565b60405180910390fd5b505b6001600160a01b038616610e1857604051634e46966960e11b815260040160405180910390fd5b6001600160a01b038316610e3f5760405163c1ab6dc160e01b815260040160405180910390fd5b835f03610e5f5760405163f2365b5b60e01b815260040160405180910390fd5b610118811115610e825760405163ef3d005b60e01b815260040160405180910390fd5b604051637921219560e11b81526001600160a01b0384169063f242432a90610eb49033908a908a908a90600401612852565b5f604051808303815f87803b158015610ecb575f5ffd5b505af1158015610edd573d5f5f3e3d5ffd5b50506001600160a01b03808616925033915088165f5160206128b25f395f51905f528585895f60038d604051610f1896959493929190612752565b60405180910390a4610f2960018055565b505050505050565b610f39611db8565b610f425f6121fa565b565b610f4c611db8565b6109d78282612249565b610f5e611ece565b60025460ff1615610fd557335f908152600360209081526040918290208251808401909352546001600160401b0381168352600160401b900460ff16151590820181905280610fb7575080516001600160401b03164211155b610fd35760405162461bcd60e51b8152600401610de69061282b565b505b6001600160a01b038516610ffc57604051634e46966960e11b815260040160405180910390fd5b6001600160a01b0383166110235760405163c1ab6dc160e01b815260040160405180910390fd5b6101188111156110465760405163ef3d005b60e01b815260040160405180910390fd5b604051632142170760e11b81523360048201526001600160a01b038681166024830152604482018690528416906342842e0e906064015f604051808303815f87803b158015611093575f5ffd5b505af11580156110a5573d5f5f3e3d5ffd5b50506001600160a01b03808616925033915087165f5160206128b25f395f51905f52858560015f60028c6040516110e196959493929190612752565b60405180910390a46108c860018055565b6110fa611ece565b805f5b81811015611542575f848483818110611118576111186127a4565b905060200281019061112a9190612889565b6111389060208101906125d6565b6001600160a01b03160361115f57604051634e46966960e11b815260040160405180910390fd5b5f848483818110611172576111726127a4565b90506020028101906111849190612889565b6111959060608101906040016125d6565b6001600160a01b0316036111bc5760405163c1ab6dc160e01b815260040160405180910390fd5b8383828181106111ce576111ce6127a4565b90506020028101906111e09190612889565b602001355f036112035760405163f2365b5b60e01b815260040160405180910390fd5b610118848483818110611218576112186127a4565b905060200281019061122a9190612889565b6112389060608101906127d6565b905011156112595760405163ef3d005b60e01b815260040160405180910390fd5b5f84848381811061126c5761126c6127a4565b905060200281019061127e9190612889565b61128f9060608101906040016125d6565b6040516370a0823160e01b81523060048201529091505f906001600160a01b038316906370a0823190602401602060405180830381865afa1580156112d6573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906112fa919061278d565b905061133b3330888887818110611313576113136127a4565b90506020028101906113259190612889565b6001600160a01b03861692919060200135611f3f565b6040516370a0823160e01b81523060048201525f9082906001600160a01b038516906370a0823190602401602060405180830381865afa158015611381573d5f5f3e3d5ffd5b505050506040513d601f19601f820116820180604052508101906113a5919061278d565b6113af9190612717565b9050805f036113d1576040516311e9444560e01b815260040160405180910390fd5b5f6127106113e06064846126db565b6113ea91906126f8565b90505f6113f78284612717565b905061143f89898881811061140e5761140e6127a4565b90506020028101906114209190612889565b61142e9060208101906125d6565b6001600160a01b0387169083611fa6565b81156114595761145961086a5f546001600160a01b031690565b88888781811061146b5761146b6127a4565b905060200281019061147d9190612889565b61148e9060608101906040016125d6565b6001600160a01b0316338a8a898181106114aa576114aa6127a4565b90506020028101906114bc9190612889565b6114ca9060208101906125d6565b6001600160a01b03165f5160206128b25f395f51905f528c8c8b8181106114f3576114f36127a4565b90506020028101906115059190612889565b6115139060608101906127d6565b888860015f60405161152a96959493929190612752565b60405180910390a485600101955050505050506110fd565b50506109d760018055565b6002545f9060ff1661156157506001919050565b6001600160a01b0382165f908152600360209081526040918290208251808401909352546001600160401b0381168352600160401b900460ff161515908201819052806115b8575080516001600160401b03164211155b9392505050565b6115c7611ece565b60025460ff161561163e57335f908152600360209081526040918290208251808401909352546001600160401b0381168352600160401b900460ff16151590820181905280611620575080516001600160401b03164211155b61163c5760405162461bcd60e51b8152600401610de69061282b565b505b805f5b81811015611542575f84848381811061165c5761165c6127a4565b905060200281019061166e919061289d565b61167c9060208101906125d6565b6001600160a01b0316036116a357604051634e46966960e11b815260040160405180910390fd5b5f8484838181106116b6576116b66127a4565b90506020028101906116c8919061289d565b6116d99060808101906060016125d6565b6001600160a01b0316036117005760405163c1ab6dc160e01b815260040160405180910390fd5b838382818110611712576117126127a4565b9050602002810190611724919061289d565b604001355f036117475760405163f2365b5b60e01b815260040160405180910390fd5b61011884848381811061175c5761175c6127a4565b905060200281019061176e919061289d565b61177c9060808101906127d6565b9050111561179d5760405163ef3d005b60e01b815260040160405180910390fd5b8383828181106117af576117af6127a4565b90506020028101906117c1919061289d565b6117d29060808101906060016125d6565b6001600160a01b031663f242432a338686858181106117f3576117f36127a4565b9050602002810190611805919061289d565b6118139060208101906125d6565b878786818110611825576118256127a4565b9050602002810190611837919061289d565b6020013588888781811061184d5761184d6127a4565b905060200281019061185f919061289d565b604001356040518563ffffffff1660e01b81526004016118829493929190612852565b5f604051808303815f87803b158015611899575f5ffd5b505af11580156118ab573d5f5f3e3d5ffd5b505050508383828181106118c1576118c16127a4565b90506020028101906118d3919061289d565b6118e49060808101906060016125d6565b6001600160a01b031633858584818110611900576119006127a4565b9050602002810190611912919061289d565b6119209060208101906125d6565b6001600160a01b03165f5160206128b25f395f51905f52878786818110611949576119496127a4565b905060200281019061195b919061289d565b6119699060808101906127d6565b89898881811061197b5761197b6127a4565b905060200281019061198d919061289d565b604001355f60038c8c8b8181106119a6576119a66127a4565b90506020028101906119b8919061289d565b602001356040516119ce96959493929190612752565b60405180910390a4600101611641565b6119e6611db8565b6001600160a01b038116611a0f57604051631e4fbdf760e01b81525f6004820152602401610de6565b610661816121fa565b611a20611ece565b60025460ff1615611a9757335f908152600360209081526040918290208251808401909352546001600160401b0381168352600160401b900460ff16151590820181905280611a79575080516001600160401b03164211155b611a955760405162461bcd60e51b8152600401610de69061282b565b505b805f5b81811015611542575f848483818110611ab557611ab56127a4565b9050602002810190611ac79190612889565b611ad59060208101906125d6565b6001600160a01b031603611afc57604051634e46966960e11b815260040160405180910390fd5b5f848483818110611b0f57611b0f6127a4565b9050602002810190611b219190612889565b611b329060608101906040016125d6565b6001600160a01b031603611b595760405163c1ab6dc160e01b815260040160405180910390fd5b610118848483818110611b6e57611b6e6127a4565b9050602002810190611b809190612889565b611b8e9060608101906127d6565b90501115611baf5760405163ef3d005b60e01b815260040160405180910390fd5b838382818110611bc157611bc16127a4565b9050602002810190611bd39190612889565b611be49060608101906040016125d6565b6001600160a01b03166342842e0e33868685818110611c0557611c056127a4565b9050602002810190611c179190612889565b611c259060208101906125d6565b878786818110611c3757611c376127a4565b9050602002810190611c499190612889565b6040516001600160e01b031960e086901b1681526001600160a01b0393841660048201529290911660248301526020013560448201526064015f604051808303815f87803b158015611c99575f5ffd5b505af1158015611cab573d5f5f3e3d5ffd5b50505050838382818110611cc157611cc16127a4565b9050602002810190611cd39190612889565b611ce49060608101906040016125d6565b6001600160a01b031633858584818110611d0057611d006127a4565b9050602002810190611d129190612889565b611d209060208101906125d6565b6001600160a01b03165f5160206128b25f395f51905f52878786818110611d4957611d496127a4565b9050602002810190611d5b9190612889565b611d699060608101906127d6565b60015f60028c8c8b818110611d8057611d806127a4565b9050602002810190611d929190612889565b60200135604051611da896959493929190612752565b60405180910390a4600101611a9a565b5f546001600160a01b03163314610f425760405163118cdaa760e01b8152336004820152602401610de6565b5f5b82811015611ec8578160035f868685818110611e0457611e046127a4565b9050602002016020810190611e1991906125d6565b6001600160a01b0316815260208101919091526040015f20805467ffffffffffffffff19166001600160401b0392909216919091179055838382818110611e6257611e626127a4565b9050602002016020810190611e7791906125d6565b6040516001600160401b03841681526001600160a01b0391909116907ff88f2e39dea3a2d3e55260ba6b594fa4afc4053775ed6c362d366d3d659e0f6e9060200160405180910390a2600101611de6565b50505050565b600260015403611ef157604051633ee5aeb560e01b815260040160405180910390fd5b6002600155565b6002805460ff19168215159081179091556040519081527fffdc37679173d29a0c26bc53c8c09098cc5d080799458a93571deb9c25a172029060200160405180910390a150565b6040516001600160a01b038481166024830152838116604483015260648201839052611ec89186918216906323b872dd906084015b604051602081830303815290604052915060e01b6020820180516001600160e01b0383818316178352505050506122ae565b6040516001600160a01b038381166024830152604482018390526104fb91859182169063a9059cbb90606401611f74565b6001600160a01b0382165f81815260036020526040908190208054841515600160401b0260ff60401b19909116179055517f7352c4cdeaa076d3f1487ef94aaf13ce42c7bad07d0cda64df4950e4c772c3249061203990841515815260200190565b60405180910390a25050565b5f5b82811015611ec8578160035f868685818110612065576120656127a4565b905060200201602081019061207a91906125d6565b6001600160a01b0316815260208101919091526040015f208054911515600160401b0260ff60401b199092169190911790558383828181106120be576120be6127a4565b90506020020160208101906120d391906125d6565b6001600160a01b03167f7352c4cdeaa076d3f1487ef94aaf13ce42c7bad07d0cda64df4950e4c772c3248360405161210f911515815260200190565b60405180910390a2600101612047565b5f5b818110156104fb575f60035f85858581811061213f5761213f6127a4565b905060200201602081019061215491906125d6565b6001600160a01b0316815260208101919091526040015f20805467ffffffffffffffff19166001600160401b039290921691909117905582828281811061219d5761219d6127a4565b90506020020160208101906121b291906125d6565b6040515f81526001600160a01b0391909116907ff88f2e39dea3a2d3e55260ba6b594fa4afc4053775ed6c362d366d3d659e0f6e9060200160405180910390a2600101612121565b5f80546001600160a01b038381166001600160a01b0319831681178455604051919092169283917f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e09190a35050565b6001600160a01b0382165f81815260036020908152604091829020805467ffffffffffffffff19166001600160401b03861690811790915591519182527ff88f2e39dea3a2d3e55260ba6b594fa4afc4053775ed6c362d366d3d659e0f6e9101612039565b5f5f60205f8451602086015f885af1806122cd576040513d5f823e3d81fd5b50505f513d915081156122e45780600114156122f1565b6001600160a01b0384163b155b15611ec857604051635274afe760e01b81526001600160a01b0385166004820152602401610de6565b5f5f83601f84011261232a575f5ffd5b5081356001600160401b03811115612340575f5ffd5b6020830191508360208260051b850101111561235a575f5ffd5b9250929050565b80356001600160401b0381168114612377575f5ffd5b919050565b5f5f5f6040848603121561238e575f5ffd5b83356001600160401b038111156123a3575f5ffd5b6123af8682870161231a565b90945092506123c2905060208501612361565b90509250925092565b80356001600160a01b0381168114612377575f5ffd5b5f5f83601f8401126123f1575f5ffd5b5081356001600160401b03811115612407575f5ffd5b60208301915083602082850101111561235a575f5ffd5b5f5f5f60408486031215612430575f5ffd5b612439846123cb565b925060208401356001600160401b03811115612453575f5ffd5b61245f868287016123e1565b9497909650939450505050565b80358015158114612377575f5ffd5b5f6020828403121561248b575f5ffd5b6115b88261246c565b5f5f5f5f5f608086880312156124a8575f5ffd5b6124b1866123cb565b9450602086013593506124c6604087016123cb565b925060608601356001600160401b038111156124e0575f5ffd5b6124ec888289016123e1565b969995985093965092949392505050565b5f5f5f6060848603121561250f575f5ffd5b612518846123cb565b9250612526602085016123cb565b929592945050506040919091013590565b5f5f60408385031215612548575f5ffd5b612551836123cb565b946020939093013593505050565b5f5f60408385031215612570575f5ffd5b612579836123cb565b91506125876020840161246c565b90509250929050565b5f5f5f604084860312156125a2575f5ffd5b83356001600160401b038111156125b7575f5ffd5b6125c38682870161231a565b90945092506123c290506020850161246c565b5f602082840312156125e6575f5ffd5b6115b8826123cb565b5f5f60208385031215612600575f5ffd5b82356001600160401b03811115612615575f5ffd5b6126218582860161231a565b90969095509350505050565b5f5f5f5f5f5f60a08789031215612642575f5ffd5b61264b876123cb565b95506020870135945060408701359350612667606088016123cb565b925060808701356001600160401b03811115612681575f5ffd5b61268d89828a016123e1565b979a9699509497509295939492505050565b5f5f604083850312156126b0575f5ffd5b6126b9836123cb565b915061258760208401612361565b634e487b7160e01b5f52601160045260245ffd5b80820281158282048414176126f2576126f26126c7565b92915050565b5f8261271257634e487b7160e01b5f52601260045260245ffd5b500490565b818103818111156126f2576126f26126c7565b81835281816020850137505f828201602090810191909152601f909101601f19169091010190565b60a081525f61276560a08301888a61272a565b905085602083015284604083015260ff84166060830152826080830152979650505050505050565b5f6020828403121561279d575f5ffd5b5051919050565b634e487b7160e01b5f52603260045260245ffd5b5f8235605e198336030181126127cc575f5ffd5b9190910192915050565b5f5f8335601e198436030181126127eb575f5ffd5b8301803591506001600160401b03821115612804575f5ffd5b60200191503681900382131561235a575f5ffd5b808201808211156126f2576126f26126c7565b6020808252600d908201526c1050d0d154d4d7d11153925151609a1b604082015260600190565b6001600160a01b0394851681529290931660208301526040820152606081019190915260a0608082018190525f9082015260c00190565b5f8235607e198336030181126127cc575f5ffd5b5f8235609e198336030181126127cc575f5ffdfece2008a8e3adbd380ce4be297372d5c774c834ebe23b1279e18169507290dea8a2646970667358221220c638e0865d47ecb6bdfc2245c2dd849ea0caa6d289043aee6f2d4bb09f1ba40864736f6c634300081c0033
Verified Source Code Full Match
Compiler: v0.8.28+commit.7893614a
EVM: cancun
Optimization: Yes (200 runs)
Ownable.sol 100 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/Ownable.sol)
pragma solidity ^0.8.20;
import {Context} from "../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.
*
* The initial owner is set to the address provided by the deployer. 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;
/**
* @dev The caller account is not authorized to perform an operation.
*/
error OwnableUnauthorizedAccount(address account);
/**
* @dev The owner is not a valid owner account. (eg. `address(0)`)
*/
error OwnableInvalidOwner(address owner);
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the address provided by the deployer as the initial owner.
*/
constructor(address initialOwner) {
if (initialOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_transferOwnership(initialOwner);
}
/**
* @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 {
if (owner() != _msgSender()) {
revert OwnableUnauthorizedAccount(_msgSender());
}
}
/**
* @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 {
if (newOwner == address(0)) {
revert OwnableInvalidOwner(address(0));
}
_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);
}
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC1363.sol)
pragma solidity >=0.6.2;
import {IERC20} from "./IERC20.sol";
import {IERC165} from "./IERC165.sol";
/**
* @title IERC1363
* @dev Interface of the ERC-1363 standard as defined in the https://eips.ethereum.org/EIPS/eip-1363[ERC-1363].
*
* Defines an extension interface for ERC-20 tokens that supports executing code on a recipient contract
* after `transfer` or `transferFrom`, or code on a spender contract after `approve`, in a single transaction.
*/
interface IERC1363 is IERC20, IERC165 {
/*
* Note: the ERC-165 identifier for this interface is 0xb0202a11.
* 0xb0202a11 ===
* bytes4(keccak256('transferAndCall(address,uint256)')) ^
* bytes4(keccak256('transferAndCall(address,uint256,bytes)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256)')) ^
* bytes4(keccak256('transferFromAndCall(address,address,uint256,bytes)')) ^
* bytes4(keccak256('approveAndCall(address,uint256)')) ^
* bytes4(keccak256('approveAndCall(address,uint256,bytes)'))
*/
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferAndCall(address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the allowance mechanism
* and then calls {IERC1363Receiver-onTransferReceived} on `to`.
* @param from The address which you want to send tokens from.
* @param to The address which you want to transfer to.
* @param value The amount of tokens to be transferred.
* @param data Additional data with no specified format, sent in call to `to`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function transferFromAndCall(address from, address to, uint256 value, bytes calldata data) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value) external returns (bool);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens and then calls {IERC1363Spender-onApprovalReceived} on `spender`.
* @param spender The address which will spend the funds.
* @param value The amount of tokens to be spent.
* @param data Additional data with no specified format, sent in call to `spender`.
* @return A boolean value indicating whether the operation succeeded unless throwing.
*/
function approveAndCall(address spender, uint256 value, bytes calldata data) external returns (bool);
}
IERC165.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC165.sol)
pragma solidity >=0.4.16;
import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (interfaces/IERC20.sol)
pragma solidity >=0.4.16;
import {IERC20} from "../token/ERC20/IERC20.sol";
IERC1155.sol 123 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC1155/IERC1155.sol)
pragma solidity >=0.6.2;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-1155 compliant contract, as defined in the
* https://eips.ethereum.org/EIPS/eip-1155[ERC].
*/
interface IERC1155 is IERC165 {
/**
* @dev Emitted when `value` amount of tokens of type `id` are transferred from `from` to `to` by `operator`.
*/
event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
/**
* @dev Equivalent to multiple {TransferSingle} events, where `operator`, `from` and `to` are the same for all
* transfers.
*/
event TransferBatch(
address indexed operator,
address indexed from,
address indexed to,
uint256[] ids,
uint256[] values
);
/**
* @dev Emitted when `account` grants or revokes permission to `operator` to transfer their tokens, according to
* `approved`.
*/
event ApprovalForAll(address indexed account, address indexed operator, bool approved);
/**
* @dev Emitted when the URI for token type `id` changes to `value`, if it is a non-programmatic URI.
*
* If an {URI} event was emitted for `id`, the standard
* https://eips.ethereum.org/EIPS/eip-1155#metadata-extensions[guarantees] that `value` will equal the value
* returned by {IERC1155MetadataURI-uri}.
*/
event URI(string value, uint256 indexed id);
/**
* @dev Returns the value of tokens of token type `id` owned by `account`.
*/
function balanceOf(address account, uint256 id) external view returns (uint256);
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {balanceOf}.
*
* Requirements:
*
* - `accounts` and `ids` must have the same length.
*/
function balanceOfBatch(
address[] calldata accounts,
uint256[] calldata ids
) external view returns (uint256[] memory);
/**
* @dev Grants or revokes permission to `operator` to transfer the caller's tokens, according to `approved`,
*
* Emits an {ApprovalForAll} event.
*
* Requirements:
*
* - `operator` cannot be the zero address.
*/
function setApprovalForAll(address operator, bool approved) external;
/**
* @dev Returns true if `operator` is approved to transfer ``account``'s tokens.
*
* See {setApprovalForAll}.
*/
function isApprovedForAll(address account, address operator) external view returns (bool);
/**
* @dev Transfers a `value` amount of tokens of type `id` from `from` to `to`.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {IERC1155Receiver-onERC1155Received} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits a {TransferSingle} event.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - If the caller is not `from`, it must have been approved to spend ``from``'s tokens via {setApprovalForAll}.
* - `from` must have a balance of tokens of type `id` of at least `value` amount.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155Received} and return the
* acceptance magic value.
*/
function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;
/**
* @dev xref:ROOT:erc1155.adoc#batch-operations[Batched] version of {safeTransferFrom}.
*
* WARNING: This function can potentially allow a reentrancy attack when transferring tokens
* to an untrusted contract, when invoking {IERC1155Receiver-onERC1155BatchReceived} on the receiver.
* Ensure to follow the checks-effects-interactions pattern and consider employing
* reentrancy guards when interacting with untrusted contracts.
*
* Emits either a {TransferSingle} or a {TransferBatch} event, depending on the length of the array arguments.
*
* Requirements:
*
* - `ids` and `values` must have the same length.
* - If `to` refers to a smart contract, it must implement {IERC1155Receiver-onERC1155BatchReceived} and return the
* acceptance magic value.
*/
function safeBatchTransferFrom(
address from,
address to,
uint256[] calldata ids,
uint256[] calldata values,
bytes calldata data
) external;
}
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC20/IERC20.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-20 standard as defined in the ERC.
*/
interface IERC20 {
/**
* @dev Emitted when `value` tokens are moved from one account (`from`) to
* another (`to`).
*
* Note that `value` may be zero.
*/
event Transfer(address indexed from, address indexed to, uint256 value);
/**
* @dev Emitted when the allowance of a `spender` for an `owner` is set by
* a call to {approve}. `value` is the new allowance.
*/
event Approval(address indexed owner, address indexed spender, uint256 value);
/**
* @dev Returns the value of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the value of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves a `value` amount of tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 value) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets a `value` amount of tokens as the allowance of `spender` over the
* caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 value) external returns (bool);
/**
* @dev Moves a `value` amount of tokens from `from` to `to` using the
* allowance mechanism. `value` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 value) external returns (bool);
}
SafeERC20.sol 212 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.3.0) (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../IERC20.sol";
import {IERC1363} from "../../../interfaces/IERC1363.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC-20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
/**
* @dev An operation with an ERC-20 token failed.
*/
error SafeERC20FailedOperation(address token);
/**
* @dev Indicates a failed `decreaseAllowance` request.
*/
error SafeERC20FailedDecreaseAllowance(address spender, uint256 currentAllowance, uint256 requestedDecrease);
/**
* @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*/
function safeTransfer(IERC20 token, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the
* calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.
*/
function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
_callOptionalReturn(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Variant of {safeTransfer} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransfer(IERC20 token, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transfer, (to, value)));
}
/**
* @dev Variant of {safeTransferFrom} that returns a bool instead of reverting if the operation is not successful.
*/
function trySafeTransferFrom(IERC20 token, address from, address to, uint256 value) internal returns (bool) {
return _callOptionalReturnBool(token, abi.encodeCall(token.transferFrom, (from, to, value)));
}
/**
* @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
uint256 oldAllowance = token.allowance(address(this), spender);
forceApprove(token, spender, oldAllowance + value);
}
/**
* @dev Decrease the calling contract's allowance toward `spender` by `requestedDecrease`. If `token` returns no
* value, non-reverting calls are assumed to be successful.
*
* IMPORTANT: If the token implements ERC-7674 (ERC-20 with temporary allowance), and if the "client"
* smart contract uses ERC-7674 to set temporary allowances, then the "client" smart contract should avoid using
* this function. Performing a {safeIncreaseAllowance} or {safeDecreaseAllowance} operation on a token contract
* that has a non-zero temporary allowance (for that particular owner-spender) will result in unexpected behavior.
*/
function safeDecreaseAllowance(IERC20 token, address spender, uint256 requestedDecrease) internal {
unchecked {
uint256 currentAllowance = token.allowance(address(this), spender);
if (currentAllowance < requestedDecrease) {
revert SafeERC20FailedDecreaseAllowance(spender, currentAllowance, requestedDecrease);
}
forceApprove(token, spender, currentAllowance - requestedDecrease);
}
}
/**
* @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,
* non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval
* to be set to zero before setting it to a non-zero value, such as USDT.
*
* NOTE: If the token implements ERC-7674, this function will not modify any temporary allowance. This function
* only sets the "standard" allowance. Any temporary allowance will remain active, in addition to the value being
* set here.
*/
function forceApprove(IERC20 token, address spender, uint256 value) internal {
bytes memory approvalCall = abi.encodeCall(token.approve, (spender, value));
if (!_callOptionalReturnBool(token, approvalCall)) {
_callOptionalReturn(token, abi.encodeCall(token.approve, (spender, 0)));
_callOptionalReturn(token, approvalCall);
}
}
/**
* @dev Performs an {ERC1363} transferAndCall, with a fallback to the simple {ERC20} transfer if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
safeTransfer(token, to, value);
} else if (!token.transferAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} transferFromAndCall, with a fallback to the simple {ERC20} transferFrom if the target
* has no code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* Reverts if the returned value is other than `true`.
*/
function transferFromAndCallRelaxed(
IERC1363 token,
address from,
address to,
uint256 value,
bytes memory data
) internal {
if (to.code.length == 0) {
safeTransferFrom(token, from, to, value);
} else if (!token.transferFromAndCall(from, to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Performs an {ERC1363} approveAndCall, with a fallback to the simple {ERC20} approve if the target has no
* code. This can be used to implement an {ERC721}-like safe transfer that rely on {ERC1363} checks when
* targeting contracts.
*
* NOTE: When the recipient address (`to`) has no code (i.e. is an EOA), this function behaves as {forceApprove}.
* Opposedly, when the recipient address (`to`) has code, this function only attempts to call {ERC1363-approveAndCall}
* once without retrying, and relies on the returned value to be true.
*
* Reverts if the returned value is other than `true`.
*/
function approveAndCallRelaxed(IERC1363 token, address to, uint256 value, bytes memory data) internal {
if (to.code.length == 0) {
forceApprove(token, to, value);
} else if (!token.approveAndCall(to, value, data)) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturnBool} that reverts if call fails to meet the requirements.
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
let success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
// bubble errors
if iszero(success) {
let ptr := mload(0x40)
returndatacopy(ptr, 0, returndatasize())
revert(ptr, returndatasize())
}
returnSize := returndatasize()
returnValue := mload(0)
}
if (returnSize == 0 ? address(token).code.length == 0 : returnValue != 1) {
revert SafeERC20FailedOperation(address(token));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*
* This is a variant of {_callOptionalReturn} that silently catches all reverts and returns a bool instead.
*/
function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {
bool success;
uint256 returnSize;
uint256 returnValue;
assembly ("memory-safe") {
success := call(gas(), token, 0, add(data, 0x20), mload(data), 0, 0x20)
returnSize := returndatasize()
returnValue := mload(0)
}
return success && (returnSize == 0 ? address(token).code.length > 0 : returnValue == 1);
}
}
IERC721.sol 135 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (token/ERC721/IERC721.sol)
pragma solidity >=0.6.2;
import {IERC165} from "../../utils/introspection/IERC165.sol";
/**
* @dev Required interface of an ERC-721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId, bytes calldata data) external;
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC-721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must have been allowed to move this token by either {approve} or
* {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon
* a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Note that the caller is responsible to confirm that the recipient is capable of receiving ERC-721
* or else they may be permanently lost. Usage of {safeTransferFrom} prevents loss, though the caller must
* understand this adds an external call which potentially creates a reentrancy vulnerability.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(address from, address to, uint256 tokenId) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the address zero.
*
* 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);
}
Context.sol 28 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.1) (utils/Context.sol)
pragma solidity ^0.8.20;
/**
* @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;
}
function _contextSuffixLength() internal view virtual returns (uint256) {
return 0;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.4.0) (utils/introspection/IERC165.sol)
pragma solidity >=0.4.16;
/**
* @dev Interface of the ERC-165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[ERC].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[ERC section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
ReentrancyGuard.sol 87 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/ReentrancyGuard.sol)
pragma solidity ^0.8.20;
/**
* @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 EIP-1153 (transient storage) is available on the chain you're deploying at,
* consider using {ReentrancyGuardTransient} instead.
*
* 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;
/**
* @dev Unauthorized reentrant call.
*/
error ReentrancyGuardReentrantCall();
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
if (_status == ENTERED) {
revert ReentrancyGuardReentrantCall();
}
// 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;
}
}
AccessGate.sol 76 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
/// @notice Generic feature-gating mixin (used for NFT send unlocks).
abstract contract AccessGate {
struct Access {
uint64 paidUntil;
bool staked;
} // packed in 1 slot
bool public gateEnabled; // default false
mapping(address => Access) internal _access;
event GateSet(bool enabled);
event PaidUntilSet(address indexed user, uint64 until);
event StakedSet(address indexed user, bool staked);
modifier onlyAllowedAccess() {
if (gateEnabled) {
Access memory a = _access[msg.sender];
require(
a.staked || block.timestamp <= a.paidUntil,
"ACCESS_DENIED"
);
}
_;
}
// views
function isAllowed(address user) public view returns (bool) {
if (!gateEnabled) return true;
Access memory a = _access[user];
return a.staked || block.timestamp <= a.paidUntil;
}
function paidUntilOf(address user) public view returns (uint64) {
return _access[user].paidUntil;
}
function isStaked(address user) public view returns (bool) {
return _access[user].staked;
}
// internal setters (wrap with onlyOwner in inheritor)
function _setGateEnabled(bool enabled) internal {
gateEnabled = enabled;
emit GateSet(enabled);
}
function _setPaidUntil(address user, uint64 until) internal {
_access[user].paidUntil = until;
emit PaidUntilSet(user, until);
}
function _setPaidUntilBatch(
address[] calldata users,
uint64 until
) internal {
for (uint256 i; i < users.length; i++) {
_access[users[i]].paidUntil = until;
emit PaidUntilSet(users[i], until);
}
}
function _revokePaidBatch(address[] calldata users) internal {
for (uint256 i; i < users.length; i++) {
_access[users[i]].paidUntil = 0;
emit PaidUntilSet(users[i], 0);
}
}
function _setStaked(address user, bool staked_) internal {
_access[user].staked = staked_;
emit StakedSet(user, staked_);
}
function _setStakedBatch(address[] calldata users, bool staked_) internal {
for (uint256 i; i < users.length; i++) {
_access[users[i]].staked = staked_;
emit StakedSet(users[i], staked_);
}
}
}
Tipping.sol 387 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.28;
import {AccessGate} from "./AccessGate.sol";
import {Ownable} from "@openzeppelin/contracts/access/Ownable.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC721} from "@openzeppelin/contracts/token/ERC721/IERC721.sol";
import {IERC1155} from "@openzeppelin/contracts/token/ERC1155/IERC1155.sol";
contract Tipping is Ownable, ReentrancyGuard, AccessGate {
using SafeERC20 for IERC20;
constructor() Ownable(msg.sender) {}
enum AssetType {
Native,
ERC20,
ERC721,
ERC1155
}
uint256 public constant FEE_BPS = 100;
uint256 public constant BPS_DENOM = 10_000;
uint256 public constant MAX_MSG = 280;
error InvalidRecipient();
error NoValue();
error InvalidToken();
error MsgTooLong();
error EthTransferFailed();
error BadMsgValue();
error NoReceive();
error BadAddr();
event TipMessage(
address indexed recipientAddress,
string message,
address indexed sender,
address indexed tokenAddress,
uint256 amount,
uint256 fee,
uint8 assetType,
uint256 assetId
);
// -------- single sends --------
function sendTo(
address _recipient,
string calldata _message
) external payable nonReentrant {
if (_recipient == address(0)) revert InvalidRecipient();
if (msg.value == 0) revert NoValue();
if (bytes(_message).length > MAX_MSG) revert MsgTooLong();
uint256 fee = (msg.value * FEE_BPS) / BPS_DENOM;
uint256 payout = msg.value - fee;
(bool ok, ) = payable(_recipient).call{value: payout}("");
if (!ok) revert EthTransferFailed();
emit TipMessage(
_recipient,
_message,
msg.sender,
address(0),
msg.value,
fee,
uint8(AssetType.Native),
0
);
}
function sendTokenTo(
address _recipient,
uint256 _amount,
address _tokenAddress,
string calldata _message
) external nonReentrant {
if (_recipient == address(0)) revert InvalidRecipient();
if (_tokenAddress == address(0)) revert InvalidToken();
if (_amount == 0) revert NoValue();
if (bytes(_message).length > MAX_MSG) revert MsgTooLong();
IERC20 token = IERC20(_tokenAddress);
uint256 beforeBal = token.balanceOf(address(this));
token.safeTransferFrom(msg.sender, address(this), _amount);
uint256 received = token.balanceOf(address(this)) - beforeBal;
if (received == 0) revert NoReceive();
uint256 fee = (received * FEE_BPS) / BPS_DENOM;
uint256 payout = received - fee;
token.safeTransfer(_recipient, payout);
if (fee > 0) token.safeTransfer(owner(), fee);
emit TipMessage(
_recipient,
_message,
msg.sender,
_tokenAddress,
received,
fee,
uint8(AssetType.ERC20),
0
);
}
function sendERC721To(
address _recipient,
uint256 _tokenId,
address _nftAddress,
string calldata _message
) external nonReentrant onlyAllowedAccess {
if (_recipient == address(0)) revert InvalidRecipient();
if (_nftAddress == address(0)) revert InvalidToken();
if (bytes(_message).length > MAX_MSG) revert MsgTooLong();
IERC721(_nftAddress).safeTransferFrom(msg.sender, _recipient, _tokenId);
emit TipMessage(
_recipient,
_message,
msg.sender,
_nftAddress,
1,
0,
uint8(AssetType.ERC721),
_tokenId
);
}
function sendERC1155To(
address _recipient,
uint256 _assetId,
uint256 _amount,
address _assetAddress,
string calldata _message
) external nonReentrant onlyAllowedAccess {
if (_recipient == address(0)) revert InvalidRecipient();
if (_assetAddress == address(0)) revert InvalidToken();
if (_amount == 0) revert NoValue();
if (bytes(_message).length > MAX_MSG) revert MsgTooLong();
IERC1155(_assetAddress).safeTransferFrom(
msg.sender,
_recipient,
_assetId,
_amount,
""
);
emit TipMessage(
_recipient,
_message,
msg.sender,
_assetAddress,
_amount,
0,
uint8(AssetType.ERC1155),
_assetId
);
}
// -------- multisend --------
struct NativeTip {
address recipient;
uint256 amount;
string message;
}
struct ERC20Tip {
address recipient;
uint256 amount;
address token;
string message;
}
struct ERC721Tip {
address recipient;
uint256 tokenId;
address token;
string message;
}
struct ERC1155Tip {
address recipient;
uint256 id;
uint256 amount;
address token;
string message;
}
function sendToMany(
NativeTip[] calldata tips
) external payable nonReentrant {
uint256 len = tips.length;
uint256 total;
for (uint256 i; i < len; ) {
if (tips[i].recipient == address(0)) revert InvalidRecipient();
if (tips[i].amount == 0) revert NoValue();
if (bytes(tips[i].message).length > MAX_MSG) revert MsgTooLong();
total += tips[i].amount;
unchecked {
++i;
}
}
if (total != msg.value) revert BadMsgValue();
for (uint256 i; i < len; ) {
uint256 fee = (tips[i].amount * FEE_BPS) / BPS_DENOM;
uint256 payout = tips[i].amount - fee;
(bool ok, ) = payable(tips[i].recipient).call{value: payout}("");
if (!ok) revert EthTransferFailed();
emit TipMessage(
tips[i].recipient,
tips[i].message,
msg.sender,
address(0),
tips[i].amount,
fee,
uint8(AssetType.Native),
0
);
unchecked {
++i;
}
}
}
function sendTokensToMany(ERC20Tip[] calldata tips) external nonReentrant {
uint256 len = tips.length;
for (uint256 i; i < len; ) {
if (tips[i].recipient == address(0)) revert InvalidRecipient();
if (tips[i].token == address(0)) revert InvalidToken();
if (tips[i].amount == 0) revert NoValue();
if (bytes(tips[i].message).length > MAX_MSG) revert MsgTooLong();
IERC20 token = IERC20(tips[i].token);
uint256 beforeBal = token.balanceOf(address(this));
token.safeTransferFrom(msg.sender, address(this), tips[i].amount);
uint256 received = token.balanceOf(address(this)) - beforeBal;
if (received == 0) revert NoReceive();
uint256 fee = (received * FEE_BPS) / BPS_DENOM;
uint256 payout = received - fee;
token.safeTransfer(tips[i].recipient, payout);
if (fee > 0) token.safeTransfer(owner(), fee);
emit TipMessage(
tips[i].recipient,
tips[i].message,
msg.sender,
tips[i].token,
received,
fee,
uint8(AssetType.ERC20),
0
);
unchecked {
++i;
}
}
}
function sendERC721ToMany(
ERC721Tip[] calldata tips
) external nonReentrant onlyAllowedAccess {
uint256 len = tips.length;
for (uint256 i; i < len; ) {
if (tips[i].recipient == address(0)) revert InvalidRecipient();
if (tips[i].token == address(0)) revert InvalidToken();
if (bytes(tips[i].message).length > MAX_MSG) revert MsgTooLong();
IERC721(tips[i].token).safeTransferFrom(
msg.sender,
tips[i].recipient,
tips[i].tokenId
);
emit TipMessage(
tips[i].recipient,
tips[i].message,
msg.sender,
tips[i].token,
1,
0,
uint8(AssetType.ERC721),
tips[i].tokenId
);
unchecked {
++i;
}
}
}
function sendERC1155ToMany(
ERC1155Tip[] calldata tips
) external nonReentrant onlyAllowedAccess {
uint256 len = tips.length;
for (uint256 i; i < len; ) {
if (tips[i].recipient == address(0)) revert InvalidRecipient();
if (tips[i].token == address(0)) revert InvalidToken();
if (tips[i].amount == 0) revert NoValue();
if (bytes(tips[i].message).length > MAX_MSG) revert MsgTooLong();
IERC1155(tips[i].token).safeTransferFrom(
msg.sender,
tips[i].recipient,
tips[i].id,
tips[i].amount,
""
);
emit TipMessage(
tips[i].recipient,
tips[i].message,
msg.sender,
tips[i].token,
tips[i].amount,
0,
uint8(AssetType.ERC1155),
tips[i].id
);
unchecked {
++i;
}
}
}
// -------- owner withdrawals --------
function withdrawETH(address to, uint256 amount) external onlyOwner {
if (to == address(0)) revert BadAddr();
(bool ok, ) = payable(to).call{value: amount}("");
if (!ok) revert EthTransferFailed();
}
function withdrawERC20(
address token,
address to,
uint256 amount
) external onlyOwner {
if (token == address(0) || to == address(0)) revert BadAddr();
IERC20(token).safeTransfer(to, amount);
}
// -------- owner wrappers for AccessGate --------
function setGateEnabled(bool enabled) external onlyOwner {
_setGateEnabled(enabled);
}
function setPaidUntil(address user, uint64 until) external onlyOwner {
_setPaidUntil(user, until);
}
function setPaidUntilBatch(
address[] calldata users,
uint64 until
) external onlyOwner {
_setPaidUntilBatch(users, until);
}
function revokePaidBatch(address[] calldata users) external onlyOwner {
_revokePaidBatch(users);
}
function setStaked(address user, bool staked_) external onlyOwner {
_setStaked(user, staked_);
}
function setStakedBatch(
address[] calldata users,
bool staked_
) external onlyOwner {
_setStakedBatch(users, staked_);
}
receive() external payable {}
}
Read Contract
BPS_DENOM 0x6637e38c → uint256
FEE_BPS 0xbf333f2c → uint256
MAX_MSG 0x75d4d4a5 → uint256
gateEnabled 0xaf301e45 → bool
isAllowed 0xbabcc539 → bool
isStaked 0x6177fd18 → bool
owner 0x8da5cb5b → address
paidUntilOf 0x55214069 → uint64
Write Contract 18 functions
These functions modify contract state and require a wallet transaction to execute.
renounceOwnership 0x715018a6
No parameters
revokePaidBatch 0x6ae2a99b
address[] users
sendERC1155To 0x7129607a
address _recipient
uint256 _assetId
uint256 _amount
address _assetAddress
string _message
sendERC1155ToMany 0xf1a28a29
tuple[] tips
sendERC721To 0x8d157db8
address _recipient
uint256 _tokenId
address _nftAddress
string _message
sendERC721ToMany 0xe22976de
tuple[] tips
sendTo 0x109b7c28
address _recipient
string _message
sendToMany 0xc0985247
tuple[] tips
sendTokenTo 0x41dfeca5
address _recipient
uint256 _amount
address _tokenAddress
string _message
sendTokensToMany 0x21be1501
tuple[] tips
setGateEnabled 0x12e855ea
bool enabled
setPaidUntil 0x87cac0a4
address user
uint64 until
setPaidUntilBatch 0x01943c23
address[] users
uint64 until
setStaked 0x47e924af
address user
bool staked_
setStakedBatch 0x4e5d8bb1
address[] users
bool staked_
transferOwnership 0xf2fde38b
address newOwner
withdrawERC20 0x44004cc1
address token
address to
uint256 amount
withdrawETH 0x4782f779
address to
uint256 amount
Recent Transactions
No transactions found for this address