Address Contract Verified
Address
0x77a6149395cA96B13DF5bBd634965BCFbEEdb1C9
Balance
0 ETH
Nonce
1
Code Size
11089 bytes
Creator
0x355605Ea...c918 at tx 0x0ac00839...9b5564
Indexed Transactions
0
Contract Bytecode
11089 bytes
0x60806040526004361061014b5760003560e01c806382bfefc8116100b6578063cfd2afa91161006f578063cfd2afa914610493578063d547741f146104af578063dcd18dd4146104d8578063e8f134b714610501578063e9b3b8771461052a578063ee070805146105535761014b565b806382bfefc814610390578063853b1422146103bb5780638f26c84a146103e457806391d1485414610400578063a00642ca1461043d578063a217fddf146104685761014b565b806334aedecd1161010857806334aedecd1461026e57806336568abe14610299578063402914f5146102c25780634838ed19146102ff5780636717e41c1461032a5780636c5a7d1e146103675761014b565b806301ffc9a714610150578063149694561461018d5780631bbe9d8c146101b6578063248a9ca3146101df5780632f2ff15d1461021c5780632f940c7014610245575b600080fd5b34801561015c57600080fd5b5061017760048036038101906101729190611aa3565b61057e565b6040516101849190611aeb565b60405180910390f35b34801561019957600080fd5b506101b460048036038101906101af9190611b9a565b6105f8565b005b3480156101c257600080fd5b506101dd60048036038101906101d89190611bda565b6107a6565b005b3480156101eb57600080fd5b5061020660048036038101906102019190611c3d565b6107e1565b6040516102139190611c79565b60405180910390f35b34801561022857600080fd5b50610243600480360381019061023e9190611c94565b610800565b005b34801561025157600080fd5b5061026c60048036038101906102679190611b9a565b610822565b005b34801561027a57600080fd5b506102836108e4565b6040516102909190611c79565b60405180910390f35b3480156102a557600080fd5b506102c060048036038101906102bb9190611c94565b610908565b005b3480156102ce57600080fd5b506102e960048036038101906102e49190611bda565b61093a565b6040516102f69190611ce3565b60405180910390f35b34801561030b57600080fd5b50610314610952565b6040516103219190611ce3565b60405180910390f35b34801561033657600080fd5b50610351600480360381019061034c9190611cfe565b610958565b60405161035e9190611aeb565b60405180910390f35b34801561037357600080fd5b5061038e60048036038101906103899190611d57565b610978565b005b34801561039c57600080fd5b506103a56109a3565b6040516103b29190611de3565b60405180910390f35b3480156103c757600080fd5b506103e260048036038101906103dd9190611e63565b6109c7565b005b6103fe60048036038101906103f99190611eec565b6109eb565b005b34801561040c57600080fd5b5061042760048036038101906104229190611c94565b610bc0565b6040516104349190611aeb565b60405180910390f35b34801561044957600080fd5b50610452610c2a565b60405161045f9190611fbc565b60405180910390f35b34801561047457600080fd5b5061047d610cb8565b60405161048a9190611c79565b60405180910390f35b6104ad60048036038101906104a89190611fde565b610cbf565b005b3480156104bb57600080fd5b506104d660048036038101906104d19190611c94565b610e4f565b005b3480156104e457600080fd5b506104ff60048036038101906104fa9190611bda565b610edd565b005b34801561050d57600080fd5b50610528600480360381019061052391906120b7565b610f18565b005b34801561053657600080fd5b50610551600480360381019061054c919061214c565b61122a565b005b34801561055f57600080fd5b50610568611324565b6040516105759190611aeb565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806105f157506105f082611337565b5b9050919050565b6000801b610605816113a1565b60007f00000000000000000000000028d38df637db75533bd3f71426f3410a8204154473ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610660919061219b565b602060405180830381865afa15801561067d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906106a191906121cb565b90506000600354826106b39190612227565b9050808511156106ef576040517f4e41ec9100000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b61073a84867f00000000000000000000000028d38df637db75533bd3f71426f3410a8204154473ffffffffffffffffffffffffffffffffffffffff166113b59092919063ffffffff16565b8373ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167faa82bd036a52619abcf98d93faf9ffd11ffeee3807f3ffc822da9a2deda85ff3876040516107979190611ce3565b60405180910390a35050505050565b6000801b6107b3816113a1565b6107dd7f0914bb97ca83e85ef385857d9d418f187ff630589e0c9f44db92976d8e4519cb83610800565b5050565b6000806000838152602001908152602001600020600101549050919050565b610809826107e1565b610812816113a1565b61081c8383611434565b50505050565b6000801b61082f816113a1565b61087a82847f00000000000000000000000028d38df637db75533bd3f71426f3410a8204154473ffffffffffffffffffffffffffffffffffffffff166113b59092919063ffffffff16565b8173ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff167faa82bd036a52619abcf98d93faf9ffd11ffeee3807f3ffc822da9a2deda85ff3856040516108d79190611ce3565b60405180910390a3505050565b7f0914bb97ca83e85ef385857d9d418f187ff630589e0c9f44db92976d8e4519cb81565b6040517fe15fb00e00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60026020528060005260406000206000915090505481565b60035481565b60066020528060005260406000206000915054906101000a900460ff1681565b6000801b610985816113a1565b81600560006101000a81548160ff0219169083151502179055505050565b7f00000000000000000000000028d38df637db75533bd3f71426f3410a8204154481565b6000801b6109d4816113a1565b8282600491826109e5929190612497565b50505050565b6109f3611525565b600560009054906101000a900460ff1615610a3a576040517f3056283500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60008211610a74576040517ff197674c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082811015610af2576040517f4f1d426300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b8281610afe9190612227565b600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508260036000828254610b539190612227565b92505081905550610b6533848461156b565b3373ffffffffffffffffffffffffffffffffffffffff167f5bf4ffbba2c193e74d733f69408011d333232e84b98a68ecb638621dab65fff584604051610bab9190611ce3565b60405180910390a250610bbc611841565b5050565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60048054610c37906122c4565b80601f0160208091040260200160405190810160405280929190818152602001828054610c63906122c4565b8015610cb05780601f10610c8557610100808354040283529160200191610cb0565b820191906000526020600020905b815481529060010190602001808311610c9357829003601f168201915b505050505081565b6000801b81565b610cc7611525565b600560009054906101000a900460ff1615610d0e576040517f3056283500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905060008111610d8c576040517fb8d485a500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6000600260003373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020819055508060036000828254610de39190612227565b92505081905550610df533828461156b565b3373ffffffffffffffffffffffffffffffffffffffff167f810b977535d525522ce93aae94d554692f9ccff8a835d1e2fa03eb4f1283634882604051610e3b9190611ce3565b60405180910390a250610e4c611841565b50565b610e58826107e1565b610e61816113a1565b610e6961184a565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff1603610ecd576040517f4f3b7c2700000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b610ed78383611852565b50505050565b6000801b610eea816113a1565b610f147f0914bb97ca83e85ef385857d9d418f187ff630589e0c9f44db92976d8e4519cb83610e4f565b5050565b7f0914bb97ca83e85ef385857d9d418f187ff630589e0c9f44db92976d8e4519cb610f42816113a1565b838390508686905014610f81576040517f568efce200000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6006600083815260200190815260200160002060009054906101000a900460ff1615610fd9576040517f1fb09b8000000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b60016006600084815260200190815260200160002060006101000a81548160ff02191690831515021790555060008087879050905060005b818110156110e15786868281811061102c5761102b612567565b5b905060200201358361103e9190612596565b925086868281811061105357611052612567565b5b90506020020135600260008b8b8581811061107157611070612567565b5b90506020020160208101906110869190611bda565b73ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546110cf9190612596565b92505081905550806001019050611011565b5060007f00000000000000000000000028d38df637db75533bd3f71426f3410a8204154473ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b815260040161113d919061219b565b602060405180830381865afa15801561115a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061117e91906121cb565b90508260035461118e9190612596565b8110156111c7576040517f22bbb43c00000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b82600360008282546111d99190612596565b925050819055507f6a27e916863b51264ea8204cae227473405950445de4d02e91f498fc55ace27b8989898989604051611217959493929190612708565b60405180910390a1505050505050505050565b6000801b611237816113a1565b6000600260008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002054905082600260008673ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002081905550808311156112f05780836112d39190612227565b600360008282546112e49190612596565b9250508190555061131e565b8083101561131d5782816113049190612227565b600360008282546113159190612227565b925050819055505b5b50505050565b600560009054906101000a900460ff1681565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6113b2816113ad61184a565b611944565b50565b61142f838473ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85856040516024016113e8929190612751565b604051602081830303815290604052915060e01b6020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff8381831617835250505050611995565b505050565b60006114408383610bc0565b61151a57600160008085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506114b761184a565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a46001905061151f565b600090505b92915050565b600260015403611561576040517f3ee5aeb500000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6002600181905550565b468163ffffffff160361160257600034146115b2576040517fff7418a300000000000000000000000000000000000000000000000000000000815260040160405180910390fd5b6115fd83837f00000000000000000000000028d38df637db75533bd3f71426f3410a8204154473ffffffffffffffffffffffffffffffffffffffff166113b59092919063ffffffff16565b61183c565b60006040518060e001604052808363ffffffff1681526020018573ffffffffffffffffffffffffffffffffffffffff1660001b815260200184815260200184815260200160048054611653906122c4565b80601f016020809104026020016040519081016040528092919081815260200182805461167f906122c4565b80156116cc5780601f106116a1576101008083540402835291602001916116cc565b820191906000526020600020905b8154815290600101906020018083116116af57829003601f168201915b50505050508152602001600067ffffffffffffffff8111156116f1576116f0612266565b5b6040519080825280601f01601f1916602001820160405280156117235781602001600182028036833780820191505090505b508152602001600067ffffffffffffffff81111561174457611743612266565b5b6040519080825280601f01601f1916602001820160405280156117765781602001600182028036833780820191505090505b50815250905060006040518060400160405280348152602001600081525090507f00000000000000000000000028d38df637db75533bd3f71426f3410a8204154473ffffffffffffffffffffffffffffffffffffffff1663c7c7f5b3348484896040518563ffffffff1660e01b81526004016117f4939291906128ca565b60c06040518083038185885af1158015611812573d6000803e3d6000fd5b50505050506040513d601f19601f820116820180604052508101906118379190612ab2565b505050505b505050565b60018081905550565b600033905090565b600061185e8383610bc0565b1561193957600080600085815260200190815260200160002060000160008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506118d661184a565b73ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16847ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a46001905061193e565b600090505b92915050565b61194e8282610bc0565b6119915780826040517fe2517d3f000000000000000000000000000000000000000000000000000000008152600401611988929190612af2565b60405180910390fd5b5050565b600080602060008451602086016000885af1806119b8576040513d6000823e3d81fd5b3d9250600051915050600082146119d35760018114156119ef565b60008473ffffffffffffffffffffffffffffffffffffffff163b145b15611a3157836040517f5274afe7000000000000000000000000000000000000000000000000000000008152600401611a28919061219b565b60405180910390fd5b50505050565b6000604051905090565b600080fd5b600080fd5b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b611a8081611a4b565b8114611a8b57600080fd5b50565b600081359050611a9d81611a77565b92915050565b600060208284031215611ab957611ab8611a41565b5b6000611ac784828501611a8e565b91505092915050565b60008115159050919050565b611ae581611ad0565b82525050565b6000602082019050611b006000830184611adc565b92915050565b6000819050919050565b611b1981611b06565b8114611b2457600080fd5b50565b600081359050611b3681611b10565b92915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000611b6782611b3c565b9050919050565b611b7781611b5c565b8114611b8257600080fd5b50565b600081359050611b9481611b6e565b92915050565b60008060408385031215611bb157611bb0611a41565b5b6000611bbf85828601611b27565b9250506020611bd085828601611b85565b9150509250929050565b600060208284031215611bf057611bef611a41565b5b6000611bfe84828501611b85565b91505092915050565b6000819050919050565b611c1a81611c07565b8114611c2557600080fd5b50565b600081359050611c3781611c11565b92915050565b600060208284031215611c5357611c52611a41565b5b6000611c6184828501611c28565b91505092915050565b611c7381611c07565b82525050565b6000602082019050611c8e6000830184611c6a565b92915050565b60008060408385031215611cab57611caa611a41565b5b6000611cb985828601611c28565b9250506020611cca85828601611b85565b9150509250929050565b611cdd81611b06565b82525050565b6000602082019050611cf86000830184611cd4565b92915050565b600060208284031215611d1457611d13611a41565b5b6000611d2284828501611b27565b91505092915050565b611d3481611ad0565b8114611d3f57600080fd5b50565b600081359050611d5181611d2b565b92915050565b600060208284031215611d6d57611d6c611a41565b5b6000611d7b84828501611d42565b91505092915050565b6000819050919050565b6000611da9611da4611d9f84611b3c565b611d84565b611b3c565b9050919050565b6000611dbb82611d8e565b9050919050565b6000611dcd82611db0565b9050919050565b611ddd81611dc2565b82525050565b6000602082019050611df86000830184611dd4565b92915050565b600080fd5b600080fd5b600080fd5b60008083601f840112611e2357611e22611dfe565b5b8235905067ffffffffffffffff811115611e4057611e3f611e03565b5b602083019150836001820283011115611e5c57611e5b611e08565b5b9250929050565b60008060208385031215611e7a57611e79611a41565b5b600083013567ffffffffffffffff811115611e9857611e97611a46565b5b611ea485828601611e0d565b92509250509250929050565b600063ffffffff82169050919050565b611ec981611eb0565b8114611ed457600080fd5b50565b600081359050611ee681611ec0565b92915050565b60008060408385031215611f0357611f02611a41565b5b6000611f1185828601611b27565b9250506020611f2285828601611ed7565b9150509250929050565b600081519050919050565b600082825260208201905092915050565b60005b83811015611f66578082015181840152602081019050611f4b565b60008484015250505050565b6000601f19601f8301169050919050565b6000611f8e82611f2c565b611f988185611f37565b9350611fa8818560208601611f48565b611fb181611f72565b840191505092915050565b60006020820190508181036000830152611fd68184611f83565b905092915050565b600060208284031215611ff457611ff3611a41565b5b600061200284828501611ed7565b91505092915050565b60008083601f84011261202157612020611dfe565b5b8235905067ffffffffffffffff81111561203e5761203d611e03565b5b60208301915083602082028301111561205a57612059611e08565b5b9250929050565b60008083601f84011261207757612076611dfe565b5b8235905067ffffffffffffffff81111561209457612093611e03565b5b6020830191508360208202830111156120b0576120af611e08565b5b9250929050565b6000806000806000606086880312156120d3576120d2611a41565b5b600086013567ffffffffffffffff8111156120f1576120f0611a46565b5b6120fd8882890161200b565b9550955050602086013567ffffffffffffffff8111156121205761211f611a46565b5b61212c88828901612061565b9350935050604061213f88828901611b27565b9150509295509295909350565b6000806040838503121561216357612162611a41565b5b600061217185828601611b85565b925050602061218285828601611b27565b9150509250929050565b61219581611b5c565b82525050565b60006020820190506121b0600083018461218c565b92915050565b6000815190506121c581611b10565b92915050565b6000602082840312156121e1576121e0611a41565b5b60006121ef848285016121b6565b91505092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b600061223282611b06565b915061223d83611b06565b9250828203905081811115612255576122546121f8565b5b92915050565b600082905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806122dc57607f821691505b6020821081036122ef576122ee612295565b5b50919050565b60008190508160005260206000209050919050565b60006020601f8301049050919050565b600082821b905092915050565b6000600883026123577fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8261231a565b612361868361231a565b95508019841693508086168417925050509392505050565b600061239461238f61238a84611b06565b611d84565b611b06565b9050919050565b6000819050919050565b6123ae83612379565b6123c26123ba8261239b565b848454612327565b825550505050565b600090565b6123d76123ca565b6123e28184846123a5565b505050565b5b81811015612406576123fb6000826123cf565b6001810190506123e8565b5050565b601f82111561244b5761241c816122f5565b6124258461230a565b81016020851015612434578190505b6124486124408561230a565b8301826123e7565b50505b505050565b600082821c905092915050565b600061246e60001984600802612450565b1980831691505092915050565b6000612487838361245d565b9150826002028217905092915050565b6124a1838361225b565b67ffffffffffffffff8111156124ba576124b9612266565b5b6124c482546122c4565b6124cf82828561240a565b6000601f8311600181146124fe57600084156124ec578287013590505b6124f6858261247b565b86555061255e565b601f19841661250c866122f5565b60005b828110156125345784890135825560018201915060208501945060208101905061250f565b86831015612551578489013561254d601f89168261245d565b8355505b6001600288020188555050505b50505050505050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60006125a182611b06565b91506125ac83611b06565b92508282019050808211156125c4576125c36121f8565b5b92915050565b600082825260208201905092915050565b6000819050919050565b6125ee81611b5c565b82525050565b600061260083836125e5565b60208301905092915050565b600061261b6020840184611b85565b905092915050565b6000602082019050919050565b600061263c83856125ca565b9350612647826125db565b8060005b858110156126805761265d828461260c565b61266788826125f4565b975061267283612623565b92505060018101905061264b565b5085925050509392505050565b600082825260208201905092915050565b600080fd5b82818337505050565b60006126b8838561268d565b93507f07ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8311156126eb576126ea61269e565b5b6020830292506126fc8385846126a3565b82840190509392505050565b60006060820190508181036000830152612723818789612630565b905081810360208301526127388185876126ac565b90506127476040830184611cd4565b9695505050505050565b6000604082019050612766600083018561218c565b6127736020830184611cd4565b9392505050565b61278381611eb0565b82525050565b61279281611c07565b82525050565b6127a181611b06565b82525050565b600082825260208201905092915050565b60006127c382611f2c565b6127cd81856127a7565b93506127dd818560208601611f48565b6127e681611f72565b840191505092915050565b600060e083016000830151612809600086018261277a565b50602083015161281c6020860182612789565b50604083015161282f6040860182612798565b5060608301516128426060860182612798565b506080830151848203608086015261285a82826127b8565b91505060a083015184820360a086015261287482826127b8565b91505060c083015184820360c086015261288e82826127b8565b9150508091505092915050565b6040820160008201516128b16000850182612798565b5060208201516128c46020850182612798565b50505050565b600060808201905081810360008301526128e481866127f1565b90506128f3602083018561289b565b612900606083018461218c565b949350505050565b600080fd5b61291682611f72565b810181811067ffffffffffffffff8211171561293557612934612266565b5b80604052505050565b6000612948611a37565b9050612954828261290d565b919050565b60008151905061296881611c11565b92915050565b600067ffffffffffffffff82169050919050565b61298b8161296e565b811461299657600080fd5b50565b6000815190506129a881612982565b92915050565b6000604082840312156129c4576129c3612908565b5b6129ce604061293e565b905060006129de848285016121b6565b60008301525060206129f2848285016121b6565b60208301525092915050565b600060808284031215612a1457612a13612908565b5b612a1e606061293e565b90506000612a2e84828501612959565b6000830152506020612a4284828501612999565b6020830152506040612a56848285016129ae565b60408301525092915050565b600060408284031215612a7857612a77612908565b5b612a82604061293e565b90506000612a92848285016121b6565b6000830152506020612aa6848285016121b6565b60208301525092915050565b60008060c08385031215612ac957612ac8611a41565b5b6000612ad7858286016129fe565b9250506080612ae885828601612a62565b9150509250929050565b6000604082019050612b07600083018561218c565b612b146020830184611c6a565b939250505056fea2646970667358221220a32253f5186a19c34fcfa0d55c1e75306165d4ae000c1e304795477cdddfba8d64736f6c634300081c0033
Verified Source Code Full Match
Compiler: v0.8.28+commit.7893614a
EVM: paris
Optimization: No
AccessControl.sol 209 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (access/AccessControl.sol)
pragma solidity ^0.8.20;
import {IAccessControl} from "./IAccessControl.sol";
import {Context} from "../utils/Context.sol";
import {ERC165} from "../utils/introspection/ERC165.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms. This is a lightweight version that doesn't allow enumerating role
* members except through off-chain means by accessing the contract event logs. Some
* applications may benefit from on-chain enumerability, for those cases see
* {AccessControlEnumerable}.
*
* Roles are referred to by their `bytes32` identifier. These should be exposed
* in the external API and be unique. The best way to achieve this is by
* using `public constant` hash digests:
*
* ```solidity
* bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
* ```
*
* Roles can be used to represent a set of permissions. To restrict access to a
* function call, use {hasRole}:
*
* ```solidity
* function foo() public {
* require(hasRole(MY_ROLE, msg.sender));
* ...
* }
* ```
*
* Roles can be granted and revoked dynamically via the {grantRole} and
* {revokeRole} functions. Each role has an associated admin role, and only
* accounts that have a role's admin role can call {grantRole} and {revokeRole}.
*
* By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
* that only accounts with this role will be able to grant or revoke other
* roles. More complex role relationships can be created by using
* {_setRoleAdmin}.
*
* WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
* grant and revoke this role. Extra precautions should be taken to secure
* accounts that have been granted it. We recommend using {AccessControlDefaultAdminRules}
* to enforce additional security measures for this role.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address account => bool) hasRole;
bytes32 adminRole;
}
mapping(bytes32 role => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with an {AccessControlUnauthorizedAccount} error including the required role.
*/
modifier onlyRole(bytes32 role) {
_checkRole(role);
_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IAccessControl).interfaceId || super.supportsInterface(interfaceId);
}
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) public view virtual returns (bool) {
return _roles[role].hasRole[account];
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `_msgSender()`
* is missing `role`. Overriding this function changes the behavior of the {onlyRole} modifier.
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Reverts with an {AccessControlUnauthorizedAccount} error if `account`
* is missing `role`.
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert AccessControlUnauthorizedAccount(account, role);
}
}
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) public view virtual returns (bytes32) {
return _roles[role].adminRole;
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleGranted} event.
*/
function grantRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_grantRole(role, account);
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*
* May emit a {RoleRevoked} event.
*/
function revokeRole(bytes32 role, address account) public virtual onlyRole(getRoleAdmin(role)) {
_revokeRole(role, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been revoked `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*
* May emit a {RoleRevoked} event.
*/
function renounceRole(bytes32 role, address callerConfirmation) public virtual {
if (callerConfirmation != _msgSender()) {
revert AccessControlBadConfirmation();
}
_revokeRole(role, callerConfirmation);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*
* Emits a {RoleAdminChanged} event.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
bytes32 previousAdminRole = getRoleAdmin(role);
_roles[role].adminRole = adminRole;
emit RoleAdminChanged(role, previousAdminRole, adminRole);
}
/**
* @dev Attempts to grant `role` to `account` and returns a boolean indicating if `role` was granted.
*
* Internal function without access restriction.
*
* May emit a {RoleGranted} event.
*/
function _grantRole(bytes32 role, address account) internal virtual returns (bool) {
if (!hasRole(role, account)) {
_roles[role].hasRole[account] = true;
emit RoleGranted(role, account, _msgSender());
return true;
} else {
return false;
}
}
/**
* @dev Attempts to revoke `role` to `account` and returns a boolean indicating if `role` was revoked.
*
* Internal function without access restriction.
*
* May emit a {RoleRevoked} event.
*/
function _revokeRole(bytes32 role, address account) internal virtual returns (bool) {
if (hasRole(role, account)) {
_roles[role].hasRole[account] = false;
emit RoleRevoked(role, account, _msgSender());
return true;
} else {
return false;
}
}
}
IAccessControl.sol 98 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (access/IAccessControl.sol)
pragma solidity ^0.8.20;
/**
* @dev External interface of AccessControl declared to support ERC-165 detection.
*/
interface IAccessControl {
/**
* @dev The `account` is missing a role.
*/
error AccessControlUnauthorizedAccount(address account, bytes32 neededRole);
/**
* @dev The caller of a function is not the expected one.
*
* NOTE: Don't confuse with {AccessControlUnauthorizedAccount}.
*/
error AccessControlBadConfirmation();
/**
* @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
*
* `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
* {RoleAdminChanged} not being emitted signaling this.
*/
event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call. This account bears the admin role (for the granted role).
* Expected in cases where the role was granted using the internal {AccessControl-_grantRole}.
*/
event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Emitted when `account` is revoked `role`.
*
* `sender` is the account that originated the contract call:
* - if using `revokeRole`, it is the admin role bearer
* - if using `renounceRole`, it is the role bearer (i.e. `account`)
*/
event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);
/**
* @dev Returns `true` if `account` has been granted `role`.
*/
function hasRole(bytes32 role, address account) external view returns (bool);
/**
* @dev Returns the admin role that controls `role`. See {grantRole} and
* {revokeRole}.
*
* To change a role's admin, use {AccessControl-_setRoleAdmin}.
*/
function getRoleAdmin(bytes32 role) external view returns (bytes32);
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function grantRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
*/
function revokeRole(bytes32 role, address account) external;
/**
* @dev Revokes `role` from the calling account.
*
* Roles are often managed via {grantRole} and {revokeRole}: this function's
* purpose is to provide a mechanism for accounts to lose their privileges
* if they are compromised (such as when a trusted device is misplaced).
*
* If the calling account had been granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `callerConfirmation`.
*/
function renounceRole(bytes32 role, address callerConfirmation) external;
}
IERC1363.sol 86 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (interfaces/IERC1363.sol)
pragma solidity ^0.8.20;
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.0.0) (interfaces/IERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "../utils/introspection/IERC165.sol";
IERC20.sol 6 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.0.0) (interfaces/IERC20.sol)
pragma solidity ^0.8.20;
import {IERC20} from "../token/ERC20/IERC20.sol";
IERC20.sol 79 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.20;
/**
* @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 198 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.2.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 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);
}
}
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;
}
}
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;
}
}
ERC165.sol 27 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/ERC165.sol)
pragma solidity ^0.8.20;
import {IERC165} from "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC-165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v5.1.0) (utils/introspection/IERC165.sol)
pragma solidity ^0.8.20;
/**
* @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);
}
PromptClaim.sol 295 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
import {AccessControl} from "@openzeppelin/contracts/access/AccessControl.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {ReentrancyGuard} from "@openzeppelin/contracts/utils/ReentrancyGuard.sol";
import {IOFT, SendParam, MessagingFee} from "./interfaces/IOFT.sol";
/**
* @title PromptClaim
* @notice A contract that manages token claims with role-based access control
* @dev Allows to add claimable tokens and users to claim them
*/
contract PromptClaim is AccessControl, ReentrancyGuard {
using SafeERC20 for IERC20;
bytes32 public constant FUNDER_ROLE = keccak256("FUNDER_ROLE");
// If you want a dynamic address, use a constructor param:
IERC20 public immutable TOKEN;
// Mapping of user -> claimable token amount
mapping(address => uint256) public claimable;
// Track total outstanding claimable tokens
uint256 public totalClaimable;
bytes public extraOptions =
hex"0003010011010000000000000000000000000000ea60";
// Flag to disable claim functions
bool public disabled = true;
// Track used nonces for addClaimable
mapping(uint256 => bool) public usedNonces;
// Events
event PartialClaim(address indexed claimant, uint256 amount);
event FullClaim(address indexed claimant, uint256 amount);
event AddClaimable(address[] recipients, uint256[] amounts, uint256 nonce);
event WithdrawExcess(
address indexed admin,
address indexed to,
uint256 amount
);
error MustClaimMoreThan0Tokens();
error NotEnoughClaimableTokens();
error NoClaimableTokens();
error UnnecessaryFee();
error NotEnoughTokens();
error MismatchedArrayLengths();
error CannotWithdrawMoreThanExcess();
error CannotRenounceRole();
error CannotRevokeRoleFromSelf();
error ClaimingDisabled();
error NonceAlreadyUsed();
/**
* @notice Initializes the contract with the token address
* @param tokenAddress The address of the ERC20 token to be used for claims
*/
constructor(IERC20 tokenAddress) {
// If you want it truly "hardcoded," you can directly assign:
// TOKEN = IERC20(0x1234567890123456789012345678901234567890);
// But for easier testing, we'll pass it in as a constructor argument:
TOKEN = tokenAddress;
// Grant the deployer the admin role
_grantRole(DEFAULT_ADMIN_ROLE, 0xAf9A2fBd4B33B92308A1F44643225Da01Eb516FE);
}
/**
* @notice Allows a user to claim a specific amount of their claimable tokens
* @param amount The amount of tokens to claim
* @dev This function is protected against reentrancy attacks
*/
function partialClaim(
uint256 amount,
uint32 clainId
) external payable nonReentrant {
require(!disabled, ClaimingDisabled());
require(amount > 0, MustClaimMoreThan0Tokens());
uint256 userClaimable = claimable[msg.sender];
require(userClaimable >= amount, NotEnoughClaimableTokens());
claimable[msg.sender] = userClaimable - amount;
totalClaimable -= amount;
_send(msg.sender, amount, clainId);
emit PartialClaim(msg.sender, amount);
}
/**
* @notice Allows a user to claim all of their claimable tokens
* @dev This function is protected against reentrancy attacks
*/
function fullClaim(uint32 clainId) external payable nonReentrant {
require(!disabled, ClaimingDisabled());
uint256 userClaimable = claimable[msg.sender];
require(userClaimable > 0, NoClaimableTokens());
claimable[msg.sender] = 0;
totalClaimable -= userClaimable;
_send(msg.sender, userClaimable, clainId);
emit FullClaim(msg.sender, userClaimable);
}
/**
* @notice Sends tokens to the recipient
* @param to The address to send the tokens to
* @param amount The amount of tokens to send
* @param clainId The destination chain ID
*/
function _send(address to, uint256 amount, uint32 clainId) internal {
if (clainId == block.chainid) {
require(msg.value == 0, UnnecessaryFee());
TOKEN.safeTransfer(to, amount);
} else {
SendParam memory sendParam = SendParam({
dstEid: clainId,
to: bytes32(uint256(uint160(to))),
amountLD: amount,
minAmountLD: amount,
extraOptions: extraOptions,
composeMsg: new bytes(0),
oftCmd: new bytes(0)
});
MessagingFee memory fee = MessagingFee({
nativeFee: msg.value,
lzTokenFee: 0
});
IOFT(address(TOKEN)).send{value: msg.value}(sendParam, fee, to);
}
}
/**
* @notice Allows to add claimable tokens for multiple recipients
* @param recipients Array of addresses that can claim tokens
* @param amounts Array of token amounts corresponding to each recipient
* @param nonce Unique identifier to prevent duplicate calls
* @dev Only callable by addresses with the FUNDER_ROLE
*/
function addClaimable(
address[] calldata recipients,
uint256[] calldata amounts,
uint256 nonce
) external onlyRole(FUNDER_ROLE) {
require(recipients.length == amounts.length, MismatchedArrayLengths());
require(!usedNonces[nonce], NonceAlreadyUsed());
usedNonces[nonce] = true;
uint256 totalToAdd = 0;
uint256 recipientsLength = recipients.length;
for (uint256 i = 0; i < recipientsLength; ++i) {
totalToAdd += amounts[i];
claimable[recipients[i]] += amounts[i];
}
// Check contract balance
uint256 currentBalance = TOKEN.balanceOf(address(this));
require(
currentBalance >= totalClaimable + totalToAdd,
NotEnoughTokens()
);
totalClaimable += totalToAdd;
emit AddClaimable(recipients, amounts, nonce);
}
/**
* @notice Allows admin to withdraw excess tokens from the contract
* @param amount The amount of tokens to withdraw
* @param to The address to send the tokens to
* @dev Only callable by addresses with the DEFAULT_ADMIN_ROLE
*/
function withdrawExcessTokens(
uint256 amount,
address to
) external onlyRole(DEFAULT_ADMIN_ROLE) {
uint256 currentBalance = TOKEN.balanceOf(address(this));
uint256 excess = currentBalance - totalClaimable;
require(amount <= excess, CannotWithdrawMoreThanExcess());
TOKEN.safeTransfer(to, amount);
emit WithdrawExcess(msg.sender, to, amount);
}
/**
* @notice Allows the admin to set the extra options
* @param newExtraOptions The new extra options
* @dev Only callable by addresses with the DEFAULT_ADMIN_ROLE
*/
function setExtraOptions(
bytes calldata newExtraOptions
) external onlyRole(DEFAULT_ADMIN_ROLE) {
extraOptions = newExtraOptions;
}
/**
* @notice Grants the FUNDER_ROLE to an account
* @param account The address to grant the role to
* @dev Only callable by addresses with the DEFAULT_ADMIN_ROLE
*/
function addFunder(address account) external onlyRole(DEFAULT_ADMIN_ROLE) {
grantRole(FUNDER_ROLE, account);
}
/**
* @notice Revokes the FUNDER_ROLE from an account
* @param account The address to revoke the role from
* @dev Only callable by addresses with the DEFAULT_ADMIN_ROLE
*/
function removeFunder(
address account
) external onlyRole(DEFAULT_ADMIN_ROLE) {
revokeRole(FUNDER_ROLE, account);
}
/**
* @dev Revokes `role` from the calling account.
*
* Preventing renouncing role.
*/
function renounceRole(bytes32, address) public virtual override {
revert CannotRenounceRole();
}
/**
* @dev Revokes `role` from `account`.
*
* If `account` had been granted `role`, emits a {RoleRevoked} event.
*
* Requirements:
*
* - the caller must have ``role``'s admin role.
* - the caller must not be the account
*/
function revokeRole(
bytes32 role,
address account
) public virtual override onlyRole(getRoleAdmin(role)) {
require(account != _msgSender(), CannotRevokeRoleFromSelf());
_revokeRole(role, account);
}
/**
* @notice Sets the disabled flag to enable or disable claim functions
* @param isDisabled Whether to disable claiming or not
* @dev Only callable by addresses with the DEFAULT_ADMIN_ROLE
*/
function setDisabled(bool isDisabled) external onlyRole(DEFAULT_ADMIN_ROLE) {
disabled = isDisabled;
}
/**
* @notice Allows admin to withdraw tokens from the contract without balance checks
* @param amount The amount of tokens to withdraw
* @param to The address to send the tokens to
* @dev Only callable by addresses with the DEFAULT_ADMIN_ROLE
*/
function emergencyWithdraw(
uint256 amount,
address to
) external onlyRole(DEFAULT_ADMIN_ROLE) {
TOKEN.safeTransfer(to, amount);
emit WithdrawExcess(msg.sender, to, amount);
}
/**
* @notice Allows admin to update the claimable amount for a specific address
* @param wallet The address to update the claimable amount for
* @param amount The new claimable amount
* @dev Only callable by addresses with the DEFAULT_ADMIN_ROLE
*/
function updateClaimableAmount(
address wallet,
uint256 amount
) external onlyRole(DEFAULT_ADMIN_ROLE) {
uint256 oldAmount = claimable[wallet];
claimable[wallet] = amount;
if (amount > oldAmount) {
totalClaimable += (amount - oldAmount);
} else if (amount < oldAmount) {
totalClaimable -= (oldAmount - amount);
}
}
}
IOFT.sol 171 lines
// SPDX-License-Identifier: MIT
pragma solidity 0.8.28;
/**
* @dev Struct representing token parameters for the OFT send() operation.
*/
struct SendParam {
uint32 dstEid; // Destination endpoint ID.
bytes32 to; // Recipient address.
uint256 amountLD; // Amount to send in local decimals.
uint256 minAmountLD; // Minimum amount to send in local decimals.
bytes extraOptions; // Additional options supplied by the caller to be used in the LayerZero message.
bytes composeMsg; // The composed message for the send() operation.
bytes oftCmd; // The OFT command to be executed, unused in default OFT implementations.
}
/**
* @dev Struct representing OFT limit information.
* @dev These amounts can change dynamically and are up the specific oft implementation.
*/
struct OFTLimit {
uint256 minAmountLD; // Minimum amount in local decimals that can be sent to the recipient.
uint256 maxAmountLD; // Maximum amount in local decimals that can be sent to the recipient.
}
/**
* @dev Struct representing OFT receipt information.
*/
struct OFTReceipt {
uint256 amountSentLD; // Amount of tokens ACTUALLY debited from the sender in local decimals.
// @dev In non-default implementations, the amountReceivedLD COULD differ from this value.
uint256 amountReceivedLD; // Amount of tokens to be received on the remote side.
}
/**
* @dev Struct representing OFT fee details.
* @dev Future proof mechanism to provide a standardized way to communicate fees to things like a UI.
*/
struct OFTFeeDetail {
int256 feeAmountLD; // Amount of the fee in local decimals.
string description; // Description of the fee.
}
struct MessagingReceipt {
bytes32 guid;
uint64 nonce;
MessagingFee fee;
}
struct MessagingFee {
uint256 nativeFee;
uint256 lzTokenFee;
}
/**
* @title IOFT
* @dev Interface for the OftChain (OFT) token.
* @dev Does not inherit ERC20 to accommodate usage by OFTAdapter as well.
* @dev This specific interface ID is '0x02e49c2c'.
*/
interface IOFT {
// Custom error messages
error InvalidLocalDecimals();
error SlippageExceeded(uint256 amountLD, uint256 minAmountLD);
// Events
event OFTSent(
bytes32 indexed guid, // GUID of the OFT message.
uint32 dstEid, // Destination Endpoint ID.
address indexed fromAddress, // Address of the sender on the src chain.
uint256 amountSentLD, // Amount of tokens sent in local decimals.
uint256 amountReceivedLD // Amount of tokens received in local decimals.
);
event OFTReceived(
bytes32 indexed guid, // GUID of the OFT message.
uint32 srcEid, // Source Endpoint ID.
address indexed toAddress, // Address of the recipient on the dst chain.
uint256 amountReceivedLD // Amount of tokens received in local decimals.
);
/**
* @notice Retrieves interfaceID and the version of the OFT.
* @return interfaceId The interface ID.
* @return version The version.
*
* @dev interfaceId: This specific interface ID is '0x02e49c2c'.
* @dev version: Indicates a cross-chain compatible msg encoding with other OFTs.
* @dev If a new feature is added to the OFT cross-chain msg encoding, the version will be incremented.
* ie. localOFT version(x,1) CAN send messages to remoteOFT version(x,1)
*/
function oftVersion()
external
view
returns (bytes4 interfaceId, uint64 version);
/**
* @notice Retrieves the address of the token associated with the OFT.
* @return token The address of the ERC20 token implementation.
*/
function token() external view returns (address);
/**
* @notice Indicates whether the OFT contract requires approval of the 'token()' to send.
* @return requiresApproval Needs approval of the underlying token implementation.
*
* @dev Allows things like wallet implementers to determine integration requirements,
* without understanding the underlying token implementation.
*/
function approvalRequired() external view returns (bool);
/**
* @notice Retrieves the shared decimals of the OFT.
* @return sharedDecimals The shared decimals of the OFT.
*/
function sharedDecimals() external view returns (uint8);
/**
* @notice Provides the fee breakdown and settings data for an OFT. Unused in the default implementation.
* @param _sendParam The parameters for the send operation.
* @return limit The OFT limit information.
* @return oftFeeDetails The details of OFT fees.
* @return receipt The OFT receipt information.
*/
function quoteOFT(
SendParam calldata _sendParam
)
external
view
returns (
OFTLimit memory,
OFTFeeDetail[] memory oftFeeDetails,
OFTReceipt memory
);
/**
* @notice Provides a quote for the send() operation.
* @param _sendParam The parameters for the send() operation.
* @param _payInLzToken Flag indicating whether the caller is paying in the LZ token.
* @return fee The calculated LayerZero messaging fee from the send() operation.
*
* @dev MessagingFee: LayerZero msg fee
* - nativeFee: The native fee.
* - lzTokenFee: The lzToken fee.
*/
function quoteSend(
SendParam calldata _sendParam,
bool _payInLzToken
) external view returns (MessagingFee memory);
/**
* @notice Executes the send() operation.
* @param _sendParam The parameters for the send operation.
* @param _fee The fee information supplied by the caller.
* - nativeFee: The native fee.
* - lzTokenFee: The lzToken fee.
* @param _refundAddress The address to receive any excess funds from fees etc. on the src.
* @return receipt The LayerZero messaging receipt from the send() operation.
* @return oftReceipt The OFT receipt information.
*
* @dev MessagingReceipt: LayerZero msg receipt
* - guid: The unique identifier for the sent message.
* - nonce: The nonce of the sent message.
* - fee: The LayerZero fee incurred for the message.
*/
function send(
SendParam calldata _sendParam,
MessagingFee calldata _fee,
address _refundAddress
) external payable returns (MessagingReceipt memory, OFTReceipt memory);
}
Read Contract
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
FUNDER_ROLE 0x34aedecd → bytes32
TOKEN 0x82bfefc8 → address
claimable 0x402914f5 → uint256
disabled 0xee070805 → bool
extraOptions 0xa00642ca → bytes
getRoleAdmin 0x248a9ca3 → bytes32
hasRole 0x91d14854 → bool
supportsInterface 0x01ffc9a7 → bool
totalClaimable 0x4838ed19 → uint256
usedNonces 0x6717e41c → bool
Write Contract 13 functions
These functions modify contract state and require a wallet transaction to execute.
addClaimable 0xe8f134b7
address[] recipients
uint256[] amounts
uint256 nonce
addFunder 0x1bbe9d8c
address account
emergencyWithdraw 0x2f940c70
uint256 amount
address to
fullClaim 0xcfd2afa9
uint32 clainId
grantRole 0x2f2ff15d
bytes32 role
address account
partialClaim 0x8f26c84a
uint256 amount
uint32 clainId
removeFunder 0xdcd18dd4
address account
renounceRole 0x36568abe
bytes32
address
revokeRole 0xd547741f
bytes32 role
address account
setDisabled 0x6c5a7d1e
bool isDisabled
setExtraOptions 0x853b1422
bytes newExtraOptions
updateClaimableAmount 0xe9b3b877
address wallet
uint256 amount
withdrawExcessTokens 0x14969456
uint256 amount
address to
Recent Transactions
No transactions found for this address