Address Contract Verified
Address
0xE89c80a76A66f26f6149D270b88d3Bfc4eC07056
Balance
0 ETH
Nonce
1
Code Size
19665 bytes
Creator
0x11e66CD7...e3e0 at tx 0x8fa953a1...06ec45
Indexed Transactions
0
Contract Bytecode
19665 bytes
0x6080604052600436106101c15760003560e01c80637533d788116100f7578063b88d4fde11610095578063e985e9c511610064578063e985e9c514610623578063eb8d72b714610660578063ed88c68e14610689578063f2fde38b14610693576101c1565b8063b88d4fde14610585578063c87b56dd146105ae578063cf89fa03146105eb578063d1deba1f14610607576101c1565b8063943fb872116100d1578063943fb872146104dd57806395d89b4114610506578063a22cb46514610531578063b2bdfa7b1461055a576101c1565b80637533d788146104375780638da5cb5b146104745780638ee749121461049f576101c1565b80632e1a7d4d116101645780636352211e1161013e5780636352211e1461038a5780636ecd2306146103c757806370a08231146103e3578063715018a614610420576101c1565b80632e1a7d4d1461030f57806342842e0e1461033857806355f804b314610361576101c1565b8063081812fc116101a0578063081812fc14610257578063095ea7b3146102945780631c37a822146102bd57806323b872dd146102e6576101c1565b80621d3567146101c657806301ffc9a7146101ef57806306fdde031461022c575b600080fd5b3480156101d257600080fd5b506101ed60048036038101906101e89190612d32565b6106bc565b005b3480156101fb57600080fd5b5061021660048036038101906102119190612e29565b6108fe565b6040516102239190612e71565b60405180910390f35b34801561023857600080fd5b506102416109e0565b60405161024e9190612f14565b60405180910390f35b34801561026357600080fd5b5061027e60048036038101906102799190612f6c565b610a72565b60405161028b9190612fda565b60405180910390f35b3480156102a057600080fd5b506102bb60048036038101906102b69190613021565b610af7565b005b3480156102c957600080fd5b506102e460048036038101906102df9190612d32565b610c0f565b005b3480156102f257600080fd5b5061030d60048036038101906103089190613061565b610c8f565b005b34801561031b57600080fd5b5061033660048036038101906103319190612f6c565b610cef565b005b34801561034457600080fd5b5061035f600480360381019061035a9190613061565b610e3d565b005b34801561036d57600080fd5b5061038860048036038101906103839190613155565b610e5d565b005b34801561039657600080fd5b506103b160048036038101906103ac9190612f6c565b610ef3565b6040516103be9190612fda565b60405180910390f35b6103e160048036038101906103dc91906131d7565b610fa5565b005b3480156103ef57600080fd5b5061040a60048036038101906104059190613204565b611090565b6040516104179190613240565b60405180910390f35b34801561042c57600080fd5b50610435611148565b005b34801561044357600080fd5b5061045e6004803603810190610459919061325b565b6111d0565b60405161046b91906132dd565b60405180910390f35b34801561048057600080fd5b50610489611270565b6040516104969190612fda565b60405180910390f35b3480156104ab57600080fd5b506104c660048036038101906104c191906132ff565b611299565b6040516104d4929190613387565b60405180910390f35b3480156104e957600080fd5b5061050460048036038101906104ff9190612f6c565b6112ed565b005b34801561051257600080fd5b5061051b611373565b6040516105289190612f14565b60405180910390f35b34801561053d57600080fd5b50610558600480360381019061055391906133dc565b611405565b005b34801561056657600080fd5b5061056f61141b565b60405161057c9190612fda565b60405180910390f35b34801561059157600080fd5b506105ac60048036038101906105a7919061341c565b611441565b005b3480156105ba57600080fd5b506105d560048036038101906105d09190612f6c565b6114a3565b6040516105e29190612f14565b60405180910390f35b6106056004803603810190610600919061349f565b61154a565b005b610621600480360381019061061c919061353f565b61182e565b005b34801561062f57600080fd5b5061064a600480360381019061064591906135e3565b6119ce565b6040516106579190612e71565b60405180910390f35b34801561066c57600080fd5b5061068760048036038101906106829190613623565b611a62565b005b610691611b0e565b005b34801561069f57600080fd5b506106ba60048036038101906106b59190613204565b611b10565b005b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff161461071657600080fd5b600960008561ffff1661ffff168152602001908152602001600020805461073c906136b2565b905083511480156107825750600960008561ffff1661ffff1681526020019081526020016000206040516107709190613783565b60405180910390208380519060200120145b6107c1576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016107b89061380c565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff16631c37a822858585856040518563ffffffff1660e01b8152600401610800949392919061384a565b600060405180830381600087803b15801561081a57600080fd5b505af192505050801561082b575060015b6108f7576040518060400160405280825181526020018280519060200120815250600860008661ffff1661ffff1681526020019081526020016000208460405161087591906138ce565b908152602001604051809103902060008467ffffffffffffffff16815260200190815260200160002060008201518160000155602082015181600101559050507fe6f254030bcb01ffd20558175c13fcaed6d1520be7becee4c961b65f79243b0d848484846040516108ea949392919061384a565b60405180910390a16108f8565b5b50505050565b60007f80ac58cd000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806109c957507f5b5e139f000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916145b806109d957506109d882611c08565b5b9050919050565b6060600180546109ef906136b2565b80601f0160208091040260200160405190810160405280929190818152602001828054610a1b906136b2565b8015610a685780601f10610a3d57610100808354040283529160200191610a68565b820191906000526020600020905b815481529060010190602001808311610a4b57829003601f168201915b5050505050905090565b6000610a7d82611c72565b610abc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ab390613957565b60405180910390fd5b6005600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050919050565b6000610b0282610ef3565b90508073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610b73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b6a906139e9565b60405180910390fd5b8073ffffffffffffffffffffffffffffffffffffffff16610b92611cde565b73ffffffffffffffffffffffffffffffffffffffff161480610bc15750610bc081610bbb611cde565b6119ce565b5b610c00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bf790613a7b565b60405180910390fd5b610c0a8383611ce6565b505050565b3073ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614610c7d576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c7490613b0d565b60405180910390fd5b610c8984848484611d9f565b50505050565b610ca0610c9a611cde565b82611dcc565b610cdf576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610cd690613b9f565b60405180910390fd5b610cea838383611eaa565b505050565b610cf7611cde565b73ffffffffffffffffffffffffffffffffffffffff16610d15611270565b73ffffffffffffffffffffffffffffffffffffffff1614610d6b576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610d6290613c0b565b60405180910390fd5b6000600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1682604051610db390613c51565b60006040518083038185875af1925050503d8060008114610df0576040519150601f19603f3d011682016040523d82523d6000602084013e610df5565b606091505b5050905080610e39576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e3090613cb2565b60405180910390fd5b5050565b610e5883838360405180602001604052806000815250611441565b505050565b610e65611cde565b73ffffffffffffffffffffffffffffffffffffffff16610e83611270565b73ffffffffffffffffffffffffffffffffffffffff1614610ed9576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ed090613c0b565b60405180910390fd5b80600b9080519060200190610eef929190612a35565b5050565b6000806003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415610f9c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f9390613d44565b60405180910390fd5b80915050919050565b348160ff16600e54610fb79190613d93565b1115610ff8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fef90613e39565b60405180910390fd5b600d548160ff16600c5461100c9190613e59565b111561104d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161104490613efb565b60405180910390fd5b60005b8160ff1681101561108c5761107933600c6000815461106e90613f1b565b919050819055612106565b808061108490613f1b565b915050611050565b5050565b60008073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611101576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016110f890613fd6565b60405180910390fd5b600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020549050919050565b611150611cde565b73ffffffffffffffffffffffffffffffffffffffff1661116e611270565b73ffffffffffffffffffffffffffffffffffffffff16146111c4576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111bb90613c0b565b60405180910390fd5b6111ce6000612124565b565b600960205280600052604060002060009150905080546111ef906136b2565b80601f016020809104026020016040519081016040528092919081815260200182805461121b906136b2565b80156112685780601f1061123d57610100808354040283529160200191611268565b820191906000526020600020905b81548152906001019060200180831161124b57829003601f168201915b505050505081565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905090565b60086020528260005260406000208280516020810182018051848252602083016020850120818352809550505050505060205280600052604060002060009250925050508060000154908060010154905082565b6112f5611cde565b73ffffffffffffffffffffffffffffffffffffffff16611313611270565b73ffffffffffffffffffffffffffffffffffffffff1614611369576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161136090613c0b565b60405180910390fd5b80600f8190555050565b606060028054611382906136b2565b80601f01602080910402602001604051908101604052809291908181526020018280546113ae906136b2565b80156113fb5780601f106113d0576101008083540402835291602001916113fb565b820191906000526020600020905b8154815290600101906020018083116113de57829003601f168201915b5050505050905090565b611417611410611cde565b83836121e8565b5050565b600a60009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b61145261144c611cde565b83611dcc565b611491576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161148890613b9f565b60405180910390fd5b61149d84848484612355565b50505050565b60606114ae82611c72565b6114ed576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016114e490614068565b60405180910390fd5b60006114f76123b1565b905060008151116115175760405180602001604052806000815250611542565b8061152184612443565b6040516020016115329291906140c4565b6040516020818303038152906040525b915050919050565b61155381610ef3565b73ffffffffffffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff16146115c0576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016115b79061415a565b60405180910390fd5b6000600960008461ffff1661ffff16815260200190815260200160002080546115e8906136b2565b90501161162a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611621906141ec565b60405180910390fd5b611633816125a4565b6000338260405160200161164892919061420c565b6040516020818303038152906040529050600060019050600081600f5460405160200161167692919061428c565b60405160208183030381529060405290506000600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff166340a7bb108730876000876040518663ffffffff1660e01b81526004016116ed9594939291906142b8565b6040805180830381865afa158015611709573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061172d919061432e565b50905080341015611773576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161176a90614406565b60405180910390fd5b600760009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663c58031003488600960008b61ffff1661ffff16815260200190815260200160002088336000896040518863ffffffff1660e01b81526004016117f4969594939291906144c7565b6000604051808303818588803b15801561180d57600080fd5b505af1158015611821573d6000803e3d6000fd5b5050505050505050505050565b6000600860008761ffff1661ffff1681526020019081526020016000208560405161185991906138ce565b908152602001604051809103902060008567ffffffffffffffff16815260200190815260200160002090506000801b816001015414156118ce576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016118c5906145af565b60405180910390fd5b8060000154838390501480156118fe5750806001015483836040516118f49291906145f4565b6040518091039020145b61193d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161193490614659565b60405180910390fd5b600081600001819055506000801b81600101819055503073ffffffffffffffffffffffffffffffffffffffff16631c37a82287878787876040518663ffffffff1660e01b81526004016119949594939291906146a6565b600060405180830381600087803b1580156119ae57600080fd5b505af11580156119c2573d6000803e3d6000fd5b50505050505050505050565b6000600660008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b611a6a611cde565b73ffffffffffffffffffffffffffffffffffffffff16611a88611270565b73ffffffffffffffffffffffffffffffffffffffff1614611ade576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ad590613c0b565b60405180910390fd5b8181600960008661ffff1661ffff1681526020019081526020016000209190611b08929190612abb565b50505050565b565b611b18611cde565b73ffffffffffffffffffffffffffffffffffffffff16611b36611270565b73ffffffffffffffffffffffffffffffffffffffff1614611b8c576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611b8390613c0b565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611bfc576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611bf39061476d565b60405180910390fd5b611c0581612124565b50565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b60008073ffffffffffffffffffffffffffffffffffffffff166003600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1614159050919050565b600033905090565b816005600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16611d5983610ef3565b73ffffffffffffffffffffffffffffffffffffffff167f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b92560405160405180910390a45050565b60008082806020019051810190611db691906147b9565b91509150611dc48282612106565b505050505050565b6000611dd782611c72565b611e16576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611e0d9061486b565b60405180910390fd5b6000611e2183610ef3565b90508073ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff161480611e9057508373ffffffffffffffffffffffffffffffffffffffff16611e7884610a72565b73ffffffffffffffffffffffffffffffffffffffff16145b80611ea15750611ea081856119ce565b5b91505092915050565b8273ffffffffffffffffffffffffffffffffffffffff16611eca82610ef3565b73ffffffffffffffffffffffffffffffffffffffff1614611f20576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f17906148fd565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161415611f90576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f879061498f565b60405180910390fd5b611f9b8383836126b5565b611fa6600082611ce6565b6001600460008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019081526020016000206000828254611ff691906149af565b925050819055506001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461204d9190613e59565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff168473ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a4505050565b6121208282604051806020016040528060008152506126ba565b5050565b60008060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050816000806101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055508173ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e060405160405180910390a35050565b8173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415612257576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161224e90614a2f565b60405180910390fd5b80600660008573ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508173ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff167f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c31836040516123489190612e71565b60405180910390a3505050565b612360848484611eaa565b61236c84848484612715565b6123ab576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016123a290614ac1565b60405180910390fd5b50505050565b6060600b80546123c0906136b2565b80601f01602080910402602001604051908101604052809291908181526020018280546123ec906136b2565b80156124395780601f1061240e57610100808354040283529160200191612439565b820191906000526020600020905b81548152906001019060200180831161241c57829003601f168201915b5050505050905090565b6060600082141561248b576040518060400160405280600181526020017f3000000000000000000000000000000000000000000000000000000000000000815250905061259f565b600082905060005b600082146124bd5780806124a690613f1b565b915050600a826124b69190614b10565b9150612493565b60008167ffffffffffffffff8111156124d9576124d8612bc7565b5b6040519080825280601f01601f19166020018201604052801561250b5781602001600182028036833780820191505090505b5090505b600085146125985760018261252491906149af565b9150600a856125339190614b41565b603061253f9190613e59565b60f81b81838151811061255557612554614b72565b5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600a856125919190614b10565b945061250f565b8093505050505b919050565b60006125af82610ef3565b90506125bd816000846126b5565b6125c8600083611ce6565b6001600460008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff168152602001908152602001600020600082825461261891906149af565b925050819055506003600083815260200190815260200160002060006101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905581600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b505050565b6126c4838361289d565b6126d16000848484612715565b612710576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161270790614ac1565b60405180910390fd5b505050565b60006127368473ffffffffffffffffffffffffffffffffffffffff16612a22565b15612890578373ffffffffffffffffffffffffffffffffffffffff1663150b7a0261275f611cde565b8786866040518563ffffffff1660e01b81526004016127819493929190614ba1565b6020604051808303816000875af19250505080156127bd57506040513d601f19601f820116820180604052508101906127ba9190614c02565b60015b612840573d80600081146127ed576040519150601f19603f3d011682016040523d82523d6000602084013e6127f2565b606091505b50600081511415612838576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161282f90614ac1565b60405180910390fd5b805181602001fd5b63150b7a0260e01b7bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916817bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614915050612895565b600190505b949350505050565b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16141561290d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161290490614c7b565b60405180910390fd5b612919600083836126b5565b6001600460008473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060008282546129699190613e59565b92505081905550816003600083815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff160217905550808273ffffffffffffffffffffffffffffffffffffffff16600073ffffffffffffffffffffffffffffffffffffffff167fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef60405160405180910390a45050565b600080823b905060008111915050919050565b828054612a41906136b2565b90600052602060002090601f016020900481019282612a635760008555612aaa565b82601f10612a7c57805160ff1916838001178555612aaa565b82800160010185558215612aaa579182015b82811115612aa9578251825591602001919060010190612a8e565b5b509050612ab79190612b41565b5090565b828054612ac7906136b2565b90600052602060002090601f016020900481019282612ae95760008555612b30565b82601f10612b0257803560ff1916838001178555612b30565b82800160010185558215612b30579182015b82811115612b2f578235825591602001919060010190612b14565b5b509050612b3d9190612b41565b5090565b5b80821115612b5a576000816000905550600101612b42565b5090565b6000604051905090565b600080fd5b600080fd5b600061ffff82169050919050565b612b8981612b72565b8114612b9457600080fd5b50565b600081359050612ba681612b80565b92915050565b600080fd5b600080fd5b6000601f19601f8301169050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b612bff82612bb6565b810181811067ffffffffffffffff82111715612c1e57612c1d612bc7565b5b80604052505050565b6000612c31612b5e565b9050612c3d8282612bf6565b919050565b600067ffffffffffffffff821115612c5d57612c5c612bc7565b5b612c6682612bb6565b9050602081019050919050565b82818337600083830152505050565b6000612c95612c9084612c42565b612c27565b905082815260208101848484011115612cb157612cb0612bb1565b5b612cbc848285612c73565b509392505050565b600082601f830112612cd957612cd8612bac565b5b8135612ce9848260208601612c82565b91505092915050565b600067ffffffffffffffff82169050919050565b612d0f81612cf2565b8114612d1a57600080fd5b50565b600081359050612d2c81612d06565b92915050565b60008060008060808587031215612d4c57612d4b612b68565b5b6000612d5a87828801612b97565b945050602085013567ffffffffffffffff811115612d7b57612d7a612b6d565b5b612d8787828801612cc4565b9350506040612d9887828801612d1d565b925050606085013567ffffffffffffffff811115612db957612db8612b6d565b5b612dc587828801612cc4565b91505092959194509250565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b612e0681612dd1565b8114612e1157600080fd5b50565b600081359050612e2381612dfd565b92915050565b600060208284031215612e3f57612e3e612b68565b5b6000612e4d84828501612e14565b91505092915050565b60008115159050919050565b612e6b81612e56565b82525050565b6000602082019050612e866000830184612e62565b92915050565b600081519050919050565b600082825260208201905092915050565b60005b83811015612ec6578082015181840152602081019050612eab565b83811115612ed5576000848401525b50505050565b6000612ee682612e8c565b612ef08185612e97565b9350612f00818560208601612ea8565b612f0981612bb6565b840191505092915050565b60006020820190508181036000830152612f2e8184612edb565b905092915050565b6000819050919050565b612f4981612f36565b8114612f5457600080fd5b50565b600081359050612f6681612f40565b92915050565b600060208284031215612f8257612f81612b68565b5b6000612f9084828501612f57565b91505092915050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000612fc482612f99565b9050919050565b612fd481612fb9565b82525050565b6000602082019050612fef6000830184612fcb565b92915050565b612ffe81612fb9565b811461300957600080fd5b50565b60008135905061301b81612ff5565b92915050565b6000806040838503121561303857613037612b68565b5b60006130468582860161300c565b925050602061305785828601612f57565b9150509250929050565b60008060006060848603121561307a57613079612b68565b5b60006130888682870161300c565b93505060206130998682870161300c565b92505060406130aa86828701612f57565b9150509250925092565b600067ffffffffffffffff8211156130cf576130ce612bc7565b5b6130d882612bb6565b9050602081019050919050565b60006130f86130f3846130b4565b612c27565b90508281526020810184848401111561311457613113612bb1565b5b61311f848285612c73565b509392505050565b600082601f83011261313c5761313b612bac565b5b813561314c8482602086016130e5565b91505092915050565b60006020828403121561316b5761316a612b68565b5b600082013567ffffffffffffffff81111561318957613188612b6d565b5b61319584828501613127565b91505092915050565b600060ff82169050919050565b6131b48161319e565b81146131bf57600080fd5b50565b6000813590506131d1816131ab565b92915050565b6000602082840312156131ed576131ec612b68565b5b60006131fb848285016131c2565b91505092915050565b60006020828403121561321a57613219612b68565b5b60006132288482850161300c565b91505092915050565b61323a81612f36565b82525050565b60006020820190506132556000830184613231565b92915050565b60006020828403121561327157613270612b68565b5b600061327f84828501612b97565b91505092915050565b600081519050919050565b600082825260208201905092915050565b60006132af82613288565b6132b98185613293565b93506132c9818560208601612ea8565b6132d281612bb6565b840191505092915050565b600060208201905081810360008301526132f781846132a4565b905092915050565b60008060006060848603121561331857613317612b68565b5b600061332686828701612b97565b935050602084013567ffffffffffffffff81111561334757613346612b6d565b5b61335386828701612cc4565b925050604061336486828701612f57565b9150509250925092565b6000819050919050565b6133818161336e565b82525050565b600060408201905061339c6000830185613231565b6133a96020830184613378565b9392505050565b6133b981612e56565b81146133c457600080fd5b50565b6000813590506133d6816133b0565b92915050565b600080604083850312156133f3576133f2612b68565b5b60006134018582860161300c565b9250506020613412858286016133c7565b9150509250929050565b6000806000806080858703121561343657613435612b68565b5b60006134448782880161300c565b94505060206134558782880161300c565b935050604061346687828801612f57565b925050606085013567ffffffffffffffff81111561348757613486612b6d565b5b61349387828801612cc4565b91505092959194509250565b600080604083850312156134b6576134b5612b68565b5b60006134c485828601612b97565b92505060206134d585828601612f57565b9150509250929050565b600080fd5b600080fd5b60008083601f8401126134ff576134fe612bac565b5b8235905067ffffffffffffffff81111561351c5761351b6134df565b5b602083019150836001820283011115613538576135376134e4565b5b9250929050565b60008060008060006080868803121561355b5761355a612b68565b5b600061356988828901612b97565b955050602086013567ffffffffffffffff81111561358a57613589612b6d565b5b61359688828901612cc4565b94505060406135a788828901612d1d565b935050606086013567ffffffffffffffff8111156135c8576135c7612b6d565b5b6135d4888289016134e9565b92509250509295509295909350565b600080604083850312156135fa576135f9612b68565b5b60006136088582860161300c565b92505060206136198582860161300c565b9150509250929050565b60008060006040848603121561363c5761363b612b68565b5b600061364a86828701612b97565b935050602084013567ffffffffffffffff81111561366b5761366a612b6d565b5b613677868287016134e9565b92509250509250925092565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052602260045260246000fd5b600060028204905060018216806136ca57607f821691505b602082108114156136de576136dd613683565b5b50919050565b600081905092915050565b60008190508160005260206000209050919050565b60008154613711816136b2565b61371b81866136e4565b9450600182166000811461373657600181146137475761377a565b60ff1983168652818601935061377a565b613750856136ef565b60005b8381101561377257815481890152600182019150602081019050613753565b838801955050505b50505092915050565b600061378f8284613704565b915081905092915050565b7f4e6f6e626c6f636b696e6752656365697665723a20696e76616c696420736f7560008201527f7263652073656e64696e6720636f6e7472616374000000000000000000000000602082015250565b60006137f6603483612e97565b91506138018261379a565b604082019050919050565b60006020820190508181036000830152613825816137e9565b9050919050565b61383581612b72565b82525050565b61384481612cf2565b82525050565b600060808201905061385f600083018761382c565b818103602083015261387181866132a4565b9050613880604083018561383b565b818103606083015261389281846132a4565b905095945050505050565b60006138a882613288565b6138b281856136e4565b93506138c2818560208601612ea8565b80840191505092915050565b60006138da828461389d565b915081905092915050565b7f4552433732313a20617070726f76656420717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000613941602c83612e97565b915061394c826138e5565b604082019050919050565b6000602082019050818103600083015261397081613934565b9050919050565b7f4552433732313a20617070726f76616c20746f2063757272656e74206f776e6560008201527f7200000000000000000000000000000000000000000000000000000000000000602082015250565b60006139d3602183612e97565b91506139de82613977565b604082019050919050565b60006020820190508181036000830152613a02816139c6565b9050919050565b7f4552433732313a20617070726f76652063616c6c6572206973206e6f74206f7760008201527f6e6572206e6f7220617070726f76656420666f7220616c6c0000000000000000602082015250565b6000613a65603883612e97565b9150613a7082613a09565b604082019050919050565b60006020820190508181036000830152613a9481613a58565b9050919050565b7f4e6f6e626c6f636b696e6752656365697665723a2063616c6c6572206d75737460008201527f206265204272696467652e000000000000000000000000000000000000000000602082015250565b6000613af7602b83612e97565b9150613b0282613a9b565b604082019050919050565b60006020820190508181036000830152613b2681613aea565b9050919050565b7f4552433732313a207472616e736665722063616c6c6572206973206e6f74206f60008201527f776e6572206e6f7220617070726f766564000000000000000000000000000000602082015250565b6000613b89603183612e97565b9150613b9482613b2d565b604082019050919050565b60006020820190508181036000830152613bb881613b7c565b9050919050565b7f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e6572600082015250565b6000613bf5602083612e97565b9150613c0082613bbf565b602082019050919050565b60006020820190508181036000830152613c2481613be8565b9050919050565b50565b6000613c3b6000836136e4565b9150613c4682613c2b565b600082019050919050565b6000613c5c82613c2e565b9150819050919050565b7f474f4b3a204661696c656420746f207769746864726177204574686572000000600082015250565b6000613c9c601d83612e97565b9150613ca782613c66565b602082019050919050565b60006020820190508181036000830152613ccb81613c8f565b9050919050565b7f4552433732313a206f776e657220717565727920666f72206e6f6e657869737460008201527f656e7420746f6b656e0000000000000000000000000000000000000000000000602082015250565b6000613d2e602983612e97565b9150613d3982613cd2565b604082019050919050565b60006020820190508181036000830152613d5d81613d21565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000613d9e82612f36565b9150613da983612f36565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff0483118215151615613de257613de1613d64565b5b828202905092915050565b7f4e6f7420656e6f75676820616d6f756e742073656e742e000000000000000000600082015250565b6000613e23601783612e97565b9150613e2e82613ded565b602082019050919050565b60006020820190508181036000830152613e5281613e16565b9050919050565b6000613e6482612f36565b9150613e6f83612f36565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff03821115613ea457613ea3613d64565b5b828201905092915050565b7f474f4b3a204d696e74206578636565647320737570706c790000000000000000600082015250565b6000613ee5601883612e97565b9150613ef082613eaf565b602082019050919050565b60006020820190508181036000830152613f1481613ed8565b9050919050565b6000613f2682612f36565b91507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff821415613f5957613f58613d64565b5b600182019050919050565b7f4552433732313a2062616c616e636520717565727920666f7220746865207a6560008201527f726f206164647265737300000000000000000000000000000000000000000000602082015250565b6000613fc0602a83612e97565b9150613fcb82613f64565b604082019050919050565b60006020820190508181036000830152613fef81613fb3565b9050919050565b7f4552433732314d657461646174613a2055524920717565727920666f72206e6f60008201527f6e6578697374656e7420746f6b656e0000000000000000000000000000000000602082015250565b6000614052602f83612e97565b915061405d82613ff6565b604082019050919050565b6000602082019050818103600083015261408181614045565b9050919050565b600081905092915050565b600061409e82612e8c565b6140a88185614088565b93506140b8818560208601612ea8565b80840191505092915050565b60006140d08285614093565b91506140dc8284614093565b91508190509392505050565b7f596f75206d757374206f776e2074686520746f6b656e20746f2074726176657260008201527f7365000000000000000000000000000000000000000000000000000000000000602082015250565b6000614144602283612e97565b915061414f826140e8565b604082019050919050565b6000602082019050818103600083015261417381614137565b9050919050565b7f5468697320636861696e2069732063757272656e746c7920756e617661696c6160008201527f626c6520666f722074726176656c000000000000000000000000000000000000602082015250565b60006141d6602e83612e97565b91506141e18261417a565b604082019050919050565b60006020820190508181036000830152614205816141c9565b9050919050565b60006040820190506142216000830185612fcb565b61422e6020830184613231565b9392505050565b60008160f01b9050919050565b600061424d82614235565b9050919050565b61426561426082612b72565b614242565b82525050565b6000819050919050565b61428661428182612f36565b61426b565b82525050565b60006142988285614254565b6002820191506142a88284614275565b6020820191508190509392505050565b600060a0820190506142cd600083018861382c565b6142da6020830187612fcb565b81810360408301526142ec81866132a4565b90506142fb6060830185612e62565b818103608083015261430d81846132a4565b90509695505050505050565b60008151905061432881612f40565b92915050565b6000806040838503121561434557614344612b68565b5b600061435385828601614319565b925050602061436485828601614319565b9150509250929050565b7f474f4b3a206d73672e76616c7565206e6f7420656e6f75676820746f20636f7660008201527f6572206d6573736167654665652e2053656e642067617320666f72206d65737360208201527f6167652066656573000000000000000000000000000000000000000000000000604082015250565b60006143f0604883612e97565b91506143fb8261436e565b606082019050919050565b6000602082019050818103600083015261441f816143e3565b9050919050565b60008154614433816136b2565b61443d8186613293565b94506001821660008114614458576001811461446a5761449d565b60ff198316865260208601935061449d565b614473856136ef565b60005b8381101561449557815481890152600182019150602081019050614476565b808801955050505b50505092915050565b60006144b182612f99565b9050919050565b6144c1816144a6565b82525050565b600060c0820190506144dc600083018961382c565b81810360208301526144ee8188614426565b9050818103604083015261450281876132a4565b905061451160608301866144b8565b61451e6080830185612fcb565b81810360a083015261453081846132a4565b9050979650505050505050565b7f4e6f6e626c6f636b696e6752656365697665723a206e6f2073746f726564206d60008201527f6573736167650000000000000000000000000000000000000000000000000000602082015250565b6000614599602683612e97565b91506145a48261453d565b604082019050919050565b600060208201905081810360008301526145c88161458c565b9050919050565b60006145db83856136e4565b93506145e8838584612c73565b82840190509392505050565b60006146018284866145cf565b91508190509392505050565b7f4c617965725a65726f3a20696e76616c6964207061796c6f6164000000000000600082015250565b6000614643601a83612e97565b915061464e8261460d565b602082019050919050565b6000602082019050818103600083015261467281614636565b9050919050565b60006146858385613293565b9350614692838584612c73565b61469b83612bb6565b840190509392505050565b60006080820190506146bb600083018861382c565b81810360208301526146cd81876132a4565b90506146dc604083018661383b565b81810360608301526146ef818486614679565b90509695505050505050565b7f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160008201527f6464726573730000000000000000000000000000000000000000000000000000602082015250565b6000614757602683612e97565b9150614762826146fb565b604082019050919050565b600060208201905081810360008301526147868161474a565b9050919050565b614796816144a6565b81146147a157600080fd5b50565b6000815190506147b38161478d565b92915050565b600080604083850312156147d0576147cf612b68565b5b60006147de858286016147a4565b92505060206147ef85828601614319565b9150509250929050565b7f4552433732313a206f70657261746f7220717565727920666f72206e6f6e657860008201527f697374656e7420746f6b656e0000000000000000000000000000000000000000602082015250565b6000614855602c83612e97565b9150614860826147f9565b604082019050919050565b6000602082019050818103600083015261488481614848565b9050919050565b7f4552433732313a207472616e73666572206f6620746f6b656e2074686174206960008201527f73206e6f74206f776e0000000000000000000000000000000000000000000000602082015250565b60006148e7602983612e97565b91506148f28261488b565b604082019050919050565b60006020820190508181036000830152614916816148da565b9050919050565b7f4552433732313a207472616e7366657220746f20746865207a65726f2061646460008201527f7265737300000000000000000000000000000000000000000000000000000000602082015250565b6000614979602483612e97565b91506149848261491d565b604082019050919050565b600060208201905081810360008301526149a88161496c565b9050919050565b60006149ba82612f36565b91506149c583612f36565b9250828210156149d8576149d7613d64565b5b828203905092915050565b7f4552433732313a20617070726f766520746f2063616c6c657200000000000000600082015250565b6000614a19601983612e97565b9150614a24826149e3565b602082019050919050565b60006020820190508181036000830152614a4881614a0c565b9050919050565b7f4552433732313a207472616e7366657220746f206e6f6e20455243373231526560008201527f63656976657220696d706c656d656e7465720000000000000000000000000000602082015250565b6000614aab603283612e97565b9150614ab682614a4f565b604082019050919050565b60006020820190508181036000830152614ada81614a9e565b9050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b6000614b1b82612f36565b9150614b2683612f36565b925082614b3657614b35614ae1565b5b828204905092915050565b6000614b4c82612f36565b9150614b5783612f36565b925082614b6757614b66614ae1565b5b828206905092915050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b6000608082019050614bb66000830187612fcb565b614bc36020830186612fcb565b614bd06040830185613231565b8181036060830152614be281846132a4565b905095945050505050565b600081519050614bfc81612dfd565b92915050565b600060208284031215614c1857614c17612b68565b5b6000614c2684828501614bed565b91505092915050565b7f4552433732313a206d696e7420746f20746865207a65726f2061646472657373600082015250565b6000614c65602083612e97565b9150614c7082614c2f565b602082019050919050565b60006020820190508181036000830152614c9481614c58565b905091905056fea26469706673582212209343b4f4c7aa69610cf402f52172cb23436d6daf1891becd8a8845e90df1542364736f6c634300080b0033
Verified Source Code Full Match
Compiler: v0.8.11+commit.d7f03943
EVM: london
Optimization: No
GhostlyOmnichainKeys.sol 1380 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0;
interface ILayerZeroUserApplicationConfig {
// @notice set the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _configType - type of configuration. every messaging library has its own convention.
// @param _config - configuration in the bytes. can encode arbitrary content.
function setConfig(uint16 _version, uint16 _chainId, uint _configType, bytes calldata _config) external;
// @notice set the send() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setSendVersion(uint16 _version) external;
// @notice set the lzReceive() LayerZero messaging library version to _version
// @param _version - new messaging library version
function setReceiveVersion(uint16 _version) external;
// @notice Only when the UA needs to resume the message flow in blocking mode and clear the stored payload
// @param _srcChainId - the chainId of the source chain
// @param _srcAddress - the contract address of the source contract at the source chain
function forceResumeReceive(uint16 _srcChainId, bytes calldata _srcAddress) external;
}
// File: contracts/interfaces/ILayerZeroEndpoint.sol
pragma solidity >=0.5.0;
interface ILayerZeroEndpoint is ILayerZeroUserApplicationConfig {
// @notice send a LayerZero message to the specified address at a LayerZero endpoint.
// @param _dstChainId - the destination chain identifier
// @param _destination - the address on destination chain (in bytes). address length/format may vary by chains
// @param _payload - a custom bytes payload to send to the destination contract
// @param _refundAddress - if the source transaction is cheaper than the amount of value passed, refund the additional amount to this address
// @param _zroPaymentAddress - the address of the ZRO token holder who would pay for the transaction
// @param _adapterParams - parameters for custom functionality. e.g. receive airdropped native gas from the relayer on destination
function send(uint16 _dstChainId, bytes calldata _destination, bytes calldata _payload, address payable _refundAddress, address _zroPaymentAddress, bytes calldata _adapterParams) external payable;
// @notice used by the messaging library to publish verified payload
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source contract (as bytes) at the source chain
// @param _dstAddress - the address on destination chain
// @param _nonce - the unbound message ordering nonce
// @param _gasLimit - the gas limit for external contract execution
// @param _payload - verified payload to send to the destination contract
function receivePayload(uint16 _srcChainId, bytes calldata _srcAddress, address _dstAddress, uint64 _nonce, uint _gasLimit, bytes calldata _payload) external;
// @notice get the inboundNonce of a receiver from a source chain which could be EVM or non-EVM chain
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function getInboundNonce(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (uint64);
// @notice get the outboundNonce from this source chain which, consequently, is always an EVM
// @param _srcAddress - the source chain contract address
function getOutboundNonce(uint16 _dstChainId, address _srcAddress) external view returns (uint64);
// @notice gets a quote in source native gas, for the amount that send() requires to pay for message delivery
// @param _dstChainId - the destination chain identifier
// @param _userApplication - the user app address on this EVM chain
// @param _payload - the custom message to send over LayerZero
// @param _payInZRO - if false, user app pays the protocol fee in native token
// @param _adapterParam - parameters for the adapter service, e.g. send some dust native token to dstChain
function estimateFees(uint16 _dstChainId, address _userApplication, bytes calldata _payload, bool _payInZRO, bytes calldata _adapterParam) external view returns (uint nativeFee, uint zroFee);
// @notice get this Endpoint's immutable source identifier
function getChainId() external view returns (uint16);
// @notice the interface to retry failed message on this Endpoint destination
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
// @param _payload - the payload to be retried
function retryPayload(uint16 _srcChainId, bytes calldata _srcAddress, bytes calldata _payload) external;
// @notice query if any STORED payload (message blocking) at the endpoint.
// @param _srcChainId - the source chain identifier
// @param _srcAddress - the source chain contract address
function hasStoredPayload(uint16 _srcChainId, bytes calldata _srcAddress) external view returns (bool);
// @notice query if the _libraryAddress is valid for sending msgs.
// @param _userApplication - the user app address on this EVM chain
function getSendLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the _libraryAddress is valid for receiving msgs.
// @param _userApplication - the user app address on this EVM chain
function getReceiveLibraryAddress(address _userApplication) external view returns (address);
// @notice query if the non-reentrancy guard for send() is on
// @return true if the guard is on. false otherwise
function isSendingPayload() external view returns (bool);
// @notice query if the non-reentrancy guard for receive() is on
// @return true if the guard is on. false otherwise
function isReceivingPayload() external view returns (bool);
// @notice get the configuration of the LayerZero messaging library of the specified version
// @param _version - messaging library version
// @param _chainId - the chainId for the pending config change
// @param _userApplication - the contract address of the user application
// @param _configType - type of configuration. every messaging library has its own convention.
function getConfig(uint16 _version, uint16 _chainId, address _userApplication, uint _configType) external view returns (bytes memory);
// @notice get the send() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getSendVersion(address _userApplication) external view returns (uint16);
// @notice get the lzReceive() LayerZero messaging library version
// @param _userApplication - the contract address of the user application
function getReceiveVersion(address _userApplication) external view returns (uint16);
}
// File: contracts/interfaces/ILayerZeroReceiver.sol
pragma solidity >=0.5.0;
interface ILayerZeroReceiver {
// @notice LayerZero endpoint will invoke this function to deliver the message on the destination
// @param _srcChainId - the source endpoint identifier
// @param _srcAddress - the source sending contract address from the source chain
// @param _nonce - the ordered message nonce
// @param _payload - the signed payload is the UA bytes has encoded to be sent
function lzReceive(uint16 _srcChainId, bytes calldata _srcAddress, uint64 _nonce, bytes calldata _payload) external;
}
// File: @openzeppelin/contracts/utils/Strings.sol
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
// File: @openzeppelin/contracts/utils/Context.sol
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
// File: @openzeppelin/contracts/access/Ownable.sol
// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)
pragma solidity ^0.8.0;
/**
* @dev Contract module which provides a basic access control mechanism, where
* there is an account (an owner) that can be granted exclusive access to
* specific functions.
*
* By default, the owner account will be the one that deploys the contract. This
* can later be changed with {transferOwnership}.
*
* This module is used through inheritance. It will make available the modifier
* `onlyOwner`, which can be applied to your functions to restrict their use to
* the owner.
*/
abstract contract Ownable is Context {
address private _owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
/**
* @dev Initializes the contract setting the deployer as the initial owner.
*/
constructor() {
_transferOwnership(_msgSender());
}
/**
* @dev Returns the address of the current owner.
*/
function owner() public view virtual returns (address) {
return _owner;
}
/**
* @dev Throws if called by any account other than the owner.
*/
modifier onlyOwner() {
require(owner() == _msgSender(), "Ownable: caller is not the owner");
_;
}
/**
* @dev Leaves the contract without owner. It will not be possible to call
* `onlyOwner` functions anymore. Can only be called by the current owner.
*
* NOTE: Renouncing ownership will leave the contract without an owner,
* thereby removing any functionality that is only available to the owner.
*/
function renounceOwnership() public virtual onlyOwner {
_transferOwnership(address(0));
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Can only be called by the current owner.
*/
function transferOwnership(address newOwner) public virtual onlyOwner {
require(newOwner != address(0), "Ownable: new owner is the zero address");
_transferOwnership(newOwner);
}
/**
* @dev Transfers ownership of the contract to a new account (`newOwner`).
* Internal function without access restriction.
*/
function _transferOwnership(address newOwner) internal virtual {
address oldOwner = _owner;
_owner = newOwner;
emit OwnershipTransferred(oldOwner, newOwner);
}
}
// File: @openzeppelin/contracts/utils/Address.sol
// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)
pragma solidity ^0.8.0;
/**
* @dev Collection of functions related to the address type
*/
library Address {
/**
* @dev Returns true if `account` is a contract.
*
* [IMPORTANT]
* ====
* It is unsafe to assume that an address for which this function returns
* false is an externally-owned account (EOA) and not a contract.
*
* Among others, `isContract` will return false for the following
* types of addresses:
*
* - an externally-owned account
* - a contract in construction
* - an address where a contract will be created
* - an address where a contract lived, but was destroyed
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize, which returns 0 for contracts in
// construction, since the code is only stored at the end of the
// constructor execution.
uint256 size;
assembly {
size := extcodesize(account)
}
return size > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721Receiver.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721Receiver.sol)
pragma solidity ^0.8.0;
/**
* @title ERC721 token receiver interface
* @dev Interface for any contract that wants to support safeTransfers
* from ERC721 asset contracts.
*/
interface IERC721Receiver {
/**
* @dev Whenever an {IERC721} `tokenId` token is transferred to this contract via {IERC721-safeTransferFrom}
* by `operator` from `from`, this function is called.
*
* It must return its Solidity selector to confirm the token transfer.
* If any other value is returned or the interface is not implemented by the recipient, the transfer will be reverted.
*
* The selector can be obtained in Solidity with `IERC721.onERC721Received.selector`.
*/
function onERC721Received(
address operator,
address from,
uint256 tokenId,
bytes calldata data
) external returns (bytes4);
}
// File: @openzeppelin/contracts/utils/introspection/IERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
// File: @openzeppelin/contracts/utils/introspection/ERC165.sol
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
// File: @openzeppelin/contracts/token/ERC721/IERC721.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/IERC721.sol)
pragma solidity ^0.8.0;
/**
* @dev Required interface of an ERC721 compliant contract.
*/
interface IERC721 is IERC165 {
/**
* @dev Emitted when `tokenId` token is transferred from `from` to `to`.
*/
event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables `approved` to manage the `tokenId` token.
*/
event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
/**
* @dev Emitted when `owner` enables or disables (`approved`) `operator` to manage all of its assets.
*/
event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
/**
* @dev Returns the number of tokens in ``owner``'s account.
*/
function balanceOf(address owner) external view returns (uint256 balance);
/**
* @dev Returns the owner of the `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function ownerOf(uint256 tokenId) external view returns (address owner);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be have been allowed to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Transfers `tokenId` token from `from` to `to`.
*
* WARNING: Usage of this method is discouraged, use {safeTransferFrom} whenever possible.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) external;
/**
* @dev Gives permission to `to` to transfer `tokenId` token to another account.
* The approval is cleared when the token is transferred.
*
* Only a single account can be approved at a time, so approving the zero address clears previous approvals.
*
* Requirements:
*
* - The caller must own the token or be an approved operator.
* - `tokenId` must exist.
*
* Emits an {Approval} event.
*/
function approve(address to, uint256 tokenId) external;
/**
* @dev Returns the account approved for `tokenId` token.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function getApproved(uint256 tokenId) external view returns (address operator);
/**
* @dev Approve or remove `operator` as an operator for the caller.
* Operators can call {transferFrom} or {safeTransferFrom} for any token owned by the caller.
*
* Requirements:
*
* - The `operator` cannot be the caller.
*
* Emits an {ApprovalForAll} event.
*/
function setApprovalForAll(address operator, bool _approved) external;
/**
* @dev Returns if the `operator` is allowed to manage all of the assets of `owner`.
*
* See {setApprovalForAll}
*/
function isApprovedForAll(address owner, address operator) external view returns (bool);
/**
* @dev Safely transfers `tokenId` token from `from` to `to`.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If the caller is not `from`, it must be approved to move this token by either {approve} or {setApprovalForAll}.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes calldata data
) external;
}
// File: @openzeppelin/contracts/token/ERC721/extensions/IERC721Metadata.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/extensions/IERC721Metadata.sol)
pragma solidity ^0.8.0;
/**
* @title ERC-721 Non-Fungible Token Standard, optional metadata extension
* @dev See https://eips.ethereum.org/EIPS/eip-721
*/
interface IERC721Metadata is IERC721 {
/**
* @dev Returns the token collection name.
*/
function name() external view returns (string memory);
/**
* @dev Returns the token collection symbol.
*/
function symbol() external view returns (string memory);
/**
* @dev Returns the Uniform Resource Identifier (URI) for `tokenId` token.
*/
function tokenURI(uint256 tokenId) external view returns (string memory);
}
// File: @openzeppelin/contracts/token/ERC721/ERC721.sol
// OpenZeppelin Contracts v4.4.1 (token/ERC721/ERC721.sol)
pragma solidity ^0.8.0;
/**
* @dev Implementation of https://eips.ethereum.org/EIPS/eip-721[ERC721] Non-Fungible Token Standard, including
* the Metadata extension, but not including the Enumerable extension, which is available separately as
* {ERC721Enumerable}.
*/
contract ERC721 is Context, ERC165, IERC721, IERC721Metadata {
using Address for address;
using Strings for uint256;
// Token name
string private _name;
// Token symbol
string private _symbol;
// Mapping from token ID to owner address
mapping(uint256 => address) private _owners;
// Mapping owner address to token count
mapping(address => uint256) private _balances;
// Mapping from token ID to approved address
mapping(uint256 => address) private _tokenApprovals;
// Mapping from owner to operator approvals
mapping(address => mapping(address => bool)) private _operatorApprovals;
/**
* @dev Initializes the contract by setting a `name` and a `symbol` to the token collection.
*/
constructor(string memory name_, string memory symbol_) {
_name = name_;
_symbol = symbol_;
}
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override(ERC165, IERC165) returns (bool) {
return
interfaceId == type(IERC721).interfaceId ||
interfaceId == type(IERC721Metadata).interfaceId ||
super.supportsInterface(interfaceId);
}
/**
* @dev See {IERC721-balanceOf}.
*/
function balanceOf(address owner) public view virtual override returns (uint256) {
require(owner != address(0), "ERC721: balance query for the zero address");
return _balances[owner];
}
/**
* @dev See {IERC721-ownerOf}.
*/
function ownerOf(uint256 tokenId) public view virtual override returns (address) {
address owner = _owners[tokenId];
require(owner != address(0), "ERC721: owner query for nonexistent token");
return owner;
}
/**
* @dev See {IERC721Metadata-name}.
*/
function name() public view virtual override returns (string memory) {
return _name;
}
/**
* @dev See {IERC721Metadata-symbol}.
*/
function symbol() public view virtual override returns (string memory) {
return _symbol;
}
/**
* @dev See {IERC721Metadata-tokenURI}.
*/
function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
string memory baseURI = _baseURI();
return bytes(baseURI).length > 0 ? string(abi.encodePacked(baseURI, tokenId.toString())) : "";
}
/**
* @dev Base URI for computing {tokenURI}. If set, the resulting URI for each
* token will be the concatenation of the `baseURI` and the `tokenId`. Empty
* by default, can be overriden in child contracts.
*/
function _baseURI() internal view virtual returns (string memory) {
return "";
}
/**
* @dev See {IERC721-approve}.
*/
function approve(address to, uint256 tokenId) public virtual override {
address owner = ERC721.ownerOf(tokenId);
require(to != owner, "ERC721: approval to current owner");
require(
_msgSender() == owner || isApprovedForAll(owner, _msgSender()),
"ERC721: approve caller is not owner nor approved for all"
);
_approve(to, tokenId);
}
/**
* @dev See {IERC721-getApproved}.
*/
function getApproved(uint256 tokenId) public view virtual override returns (address) {
require(_exists(tokenId), "ERC721: approved query for nonexistent token");
return _tokenApprovals[tokenId];
}
/**
* @dev See {IERC721-setApprovalForAll}.
*/
function setApprovalForAll(address operator, bool approved) public virtual override {
_setApprovalForAll(_msgSender(), operator, approved);
}
/**
* @dev See {IERC721-isApprovedForAll}.
*/
function isApprovedForAll(address owner, address operator) public view virtual override returns (bool) {
return _operatorApprovals[owner][operator];
}
/**
* @dev See {IERC721-transferFrom}.
*/
function transferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
//solhint-disable-next-line max-line-length
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_transfer(from, to, tokenId);
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId
) public virtual override {
safeTransferFrom(from, to, tokenId, "");
}
/**
* @dev See {IERC721-safeTransferFrom}.
*/
function safeTransferFrom(
address from,
address to,
uint256 tokenId,
bytes memory _data
) public virtual override {
require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721: transfer caller is not owner nor approved");
_safeTransfer(from, to, tokenId, _data);
}
/**
* @dev Safely transfers `tokenId` token from `from` to `to`, checking first that contract recipients
* are aware of the ERC721 protocol to prevent tokens from being forever locked.
*
* `_data` is additional data, it has no specified format and it is sent in call to `to`.
*
* This internal function is equivalent to {safeTransferFrom}, and can be used to e.g.
* implement alternative mechanisms to perform token transfer, such as signature-based.
*
* Requirements:
*
* - `from` cannot be the zero address.
* - `to` cannot be the zero address.
* - `tokenId` token must exist and be owned by `from`.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeTransfer(
address from,
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_transfer(from, to, tokenId);
require(_checkOnERC721Received(from, to, tokenId, _data), "ERC721: transfer to non ERC721Receiver implementer");
}
/**
* @dev Returns whether `tokenId` exists.
*
* Tokens can be managed by their owner or approved accounts via {approve} or {setApprovalForAll}.
*
* Tokens start existing when they are minted (`_mint`),
* and stop existing when they are burned (`_burn`).
*/
function _exists(uint256 tokenId) internal view virtual returns (bool) {
return _owners[tokenId] != address(0);
}
/**
* @dev Returns whether `spender` is allowed to manage `tokenId`.
*
* Requirements:
*
* - `tokenId` must exist.
*/
function _isApprovedOrOwner(address spender, uint256 tokenId) internal view virtual returns (bool) {
require(_exists(tokenId), "ERC721: operator query for nonexistent token");
address owner = ERC721.ownerOf(tokenId);
return (spender == owner || getApproved(tokenId) == spender || isApprovedForAll(owner, spender));
}
/**
* @dev Safely mints `tokenId` and transfers it to `to`.
*
* Requirements:
*
* - `tokenId` must not exist.
* - If `to` refers to a smart contract, it must implement {IERC721Receiver-onERC721Received}, which is called upon a safe transfer.
*
* Emits a {Transfer} event.
*/
function _safeMint(address to, uint256 tokenId) internal virtual {
_safeMint(to, tokenId, "");
}
/**
* @dev Same as {xref-ERC721-_safeMint-address-uint256-}[`_safeMint`], with an additional `data` parameter which is
* forwarded in {IERC721Receiver-onERC721Received} to contract recipients.
*/
function _safeMint(
address to,
uint256 tokenId,
bytes memory _data
) internal virtual {
_mint(to, tokenId);
require(
_checkOnERC721Received(address(0), to, tokenId, _data),
"ERC721: transfer to non ERC721Receiver implementer"
);
}
/**
* @dev Mints `tokenId` and transfers it to `to`.
*
* WARNING: Usage of this method is discouraged, use {_safeMint} whenever possible
*
* Requirements:
*
* - `tokenId` must not exist.
* - `to` cannot be the zero address.
*
* Emits a {Transfer} event.
*/
function _mint(address to, uint256 tokenId) internal virtual {
require(to != address(0), "ERC721: mint to the zero address");
_beforeTokenTransfer(address(0), to, tokenId);
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(address(0), to, tokenId);
}
/**
* @dev Destroys `tokenId`.
* The approval is cleared when the token is burned.
*
* Requirements:
*
* - `tokenId` must exist.
*
* Emits a {Transfer} event.
*/
function _burn(uint256 tokenId) internal virtual {
address owner = ERC721.ownerOf(tokenId);
_beforeTokenTransfer(owner, address(0), tokenId);
// Clear approvals
_approve(address(0), tokenId);
_balances[owner] -= 1;
delete _owners[tokenId];
emit Transfer(owner, address(0), tokenId);
}
/**
* @dev Transfers `tokenId` from `from` to `to`.
* As opposed to {transferFrom}, this imposes no restrictions on msg.sender.
*
* Requirements:
*
* - `to` cannot be the zero address.
* - `tokenId` token must be owned by `from`.
*
* Emits a {Transfer} event.
*/
function _transfer(
address from,
address to,
uint256 tokenId
) internal virtual {
require(ERC721.ownerOf(tokenId) == from, "ERC721: transfer of token that is not own");
require(to != address(0), "ERC721: transfer to the zero address");
_beforeTokenTransfer(from, to, tokenId);
// Clear approvals from the previous owner
_approve(address(0), tokenId);
_balances[from] -= 1;
_balances[to] += 1;
_owners[tokenId] = to;
emit Transfer(from, to, tokenId);
}
/**
* @dev Approve `to` to operate on `tokenId`
*
* Emits a {Approval} event.
*/
function _approve(address to, uint256 tokenId) internal virtual {
_tokenApprovals[tokenId] = to;
emit Approval(ERC721.ownerOf(tokenId), to, tokenId);
}
/**
* @dev Approve `operator` to operate on all of `owner` tokens
*
* Emits a {ApprovalForAll} event.
*/
function _setApprovalForAll(
address owner,
address operator,
bool approved
) internal virtual {
require(owner != operator, "ERC721: approve to caller");
_operatorApprovals[owner][operator] = approved;
emit ApprovalForAll(owner, operator, approved);
}
/**
* @dev Internal function to invoke {IERC721Receiver-onERC721Received} on a target address.
* The call is not executed if the target address is not a contract.
*
* @param from address representing the previous owner of the given token ID
* @param to target address that will receive the tokens
* @param tokenId uint256 ID of the token to be transferred
* @param _data bytes optional data to send along with the call
* @return bool whether the call correctly returned the expected magic value
*/
function _checkOnERC721Received(
address from,
address to,
uint256 tokenId,
bytes memory _data
) private returns (bool) {
if (to.isContract()) {
try IERC721Receiver(to).onERC721Received(_msgSender(), from, tokenId, _data) returns (bytes4 retval) {
return retval == IERC721Receiver.onERC721Received.selector;
} catch (bytes memory reason) {
if (reason.length == 0) {
revert("ERC721: transfer to non ERC721Receiver implementer");
} else {
assembly {
revert(add(32, reason), mload(reason))
}
}
}
} else {
return true;
}
}
/**
* @dev Hook that is called before any token transfer. This includes minting
* and burning.
*
* Calling conditions:
*
* - When `from` and `to` are both non-zero, ``from``'s `tokenId` will be
* transferred to `to`.
* - When `from` is zero, `tokenId` will be minted for `to`.
* - When `to` is zero, ``from``'s `tokenId` will be burned.
* - `from` and `to` are never both zero.
*
* To learn more about hooks, head to xref:ROOT:extending-contracts.adoc#using-hooks[Using Hooks].
*/
function _beforeTokenTransfer(
address from,
address to,
uint256 tokenId
) internal virtual {}
}
// File: contracts/NonblockingReceiver.sol
pragma solidity ^0.8.6;
abstract contract NonblockingReceiver is Ownable, ILayerZeroReceiver {
ILayerZeroEndpoint internal endpoint;
struct FailedMessages {
uint payloadLength;
bytes32 payloadHash;
}
mapping(uint16 => mapping(bytes => mapping(uint => FailedMessages))) public failedMessages;
mapping(uint16 => bytes) public trustedRemoteLookup;
event MessageFailed(uint16 _srcChainId, bytes _srcAddress, uint64 _nonce, bytes _payload);
function lzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) external override {
require(msg.sender == address(endpoint)); // boilerplate! lzReceive must be called by the endpoint for security
require(_srcAddress.length == trustedRemoteLookup[_srcChainId].length && keccak256(_srcAddress) == keccak256(trustedRemoteLookup[_srcChainId]),
"NonblockingReceiver: invalid source sending contract");
// try-catch all errors/exceptions
// having failed messages does not block messages passing
try this.onLzReceive(_srcChainId, _srcAddress, _nonce, _payload) {
// do nothing
} catch {
// error / exception
failedMessages[_srcChainId][_srcAddress][_nonce] = FailedMessages(_payload.length, keccak256(_payload));
emit MessageFailed(_srcChainId, _srcAddress, _nonce, _payload);
}
}
function onLzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) public {
// only internal transaction
require(msg.sender == address(this), "NonblockingReceiver: caller must be Bridge.");
// handle incoming message
_LzReceive( _srcChainId, _srcAddress, _nonce, _payload);
}
// abstract function
function _LzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) virtual internal;
function _lzSend(uint16 _dstChainId, bytes memory _payload, address payable _refundAddress, address _zroPaymentAddress, bytes memory _txParam) internal {
endpoint.send{value: msg.value}(_dstChainId, trustedRemoteLookup[_dstChainId], _payload, _refundAddress, _zroPaymentAddress, _txParam);
}
function retryMessage(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes calldata _payload) external payable {
// assert there is message to retry
FailedMessages storage failedMsg = failedMessages[_srcChainId][_srcAddress][_nonce];
require(failedMsg.payloadHash != bytes32(0), "NonblockingReceiver: no stored message");
require(_payload.length == failedMsg.payloadLength && keccak256(_payload) == failedMsg.payloadHash, "LayerZero: invalid payload");
// clear the stored message
failedMsg.payloadLength = 0;
failedMsg.payloadHash = bytes32(0);
// execute the message. revert if it fails again
this.onLzReceive(_srcChainId, _srcAddress, _nonce, _payload);
}
function setTrustedRemote(uint16 _chainId, bytes calldata _trustedRemote) external onlyOwner {
trustedRemoteLookup[_chainId] = _trustedRemote;
}
}
// File: contracts/GhostlyOmnichainKeys.sol
pragma solidity ^0.8.7;
contract GhostlyOmnichainKeys is Ownable, ERC721, NonblockingReceiver {
address public _owner;
string private baseURI;
uint256 nextTokenId = 0;
uint256 MAX_MINT_ETHEREUM = 5555;
uint256 PRICE = 0.009 ether;
uint gasForDestinationLzReceive = 350000;
constructor(string memory baseURI_, address _layerZeroEndpoint) ERC721("Ghostly Omnichain Keys", "GOK") {
_owner = msg.sender;
endpoint = ILayerZeroEndpoint(_layerZeroEndpoint);
baseURI = baseURI_;
}
// mint function
function mint(uint8 numTokens) external payable {
require((PRICE * numTokens) <= msg.value, "Not enough amount sent.");
require(nextTokenId + numTokens <= MAX_MINT_ETHEREUM, "GOK: Mint exceeds supply");
for (uint256 i = 0; i < numTokens; i++) {
_safeMint(msg.sender, ++nextTokenId);
}
}
// This function transfers the nft from your address on the
// source chain to the same address on the destination chain
function traverseChains(uint16 _chainId, uint tokenId) public payable {
require(msg.sender == ownerOf(tokenId), "You must own the token to traverse");
require(trustedRemoteLookup[_chainId].length > 0, "This chain is currently unavailable for travel");
// burn NFT, eliminating it from circulation on src chain
_burn(tokenId);
// abi.encode() the payload with the values to send
bytes memory payload = abi.encode(msg.sender, tokenId);
// encode adapterParams to specify more gas for the destination
uint16 version = 1;
bytes memory adapterParams = abi.encodePacked(version, gasForDestinationLzReceive);
// get the fees we need to pay to LayerZero + Relayer to cover message delivery
// you will be refunded for extra gas paid
(uint messageFee, ) = endpoint.estimateFees(_chainId, address(this), payload, false, adapterParams);
require(msg.value >= messageFee, "GOK: msg.value not enough to cover messageFee. Send gas for message fees");
endpoint.send{value: msg.value}(
_chainId, // destination chainId
trustedRemoteLookup[_chainId], // destination address of nft contract
payload, // abi.encoded()'ed bytes
payable(msg.sender), // refund address
address(0x0), // 'zroPaymentAddress' unused for this
adapterParams // txParameters
);
}
function setBaseURI(string memory URI) external onlyOwner {
baseURI = URI;
}
function donate() external payable {
// thank you
}
// This allows the devs to receive kind donations
function withdraw(uint amt) external onlyOwner {
(bool sent, ) = payable(_owner).call{value: amt}("");
require(sent, "GOK: Failed to withdraw Ether");
}
// just in case this fixed variable limits us from future integrations
function setGasForDestinationLzReceive(uint newVal) external onlyOwner {
gasForDestinationLzReceive = newVal;
}
// ------------------
// Internal Functions
// ------------------
function _LzReceive(uint16 _srcChainId, bytes memory _srcAddress, uint64 _nonce, bytes memory _payload) override internal {
// decode
(address toAddr, uint tokenId) = abi.decode(_payload, (address, uint));
// mint the tokens back into existence on destination chain
_safeMint(toAddr, tokenId);
}
function _baseURI() override internal view returns (string memory) {
return baseURI;
}
}
Read Contract
_owner 0xb2bdfa7b → address
balanceOf 0x70a08231 → uint256
failedMessages 0x8ee74912 → uint256, bytes32
getApproved 0x081812fc → address
isApprovedForAll 0xe985e9c5 → bool
name 0x06fdde03 → string
owner 0x8da5cb5b → address
ownerOf 0x6352211e → address
supportsInterface 0x01ffc9a7 → bool
symbol 0x95d89b41 → string
tokenURI 0xc87b56dd → string
trustedRemoteLookup 0x7533d788 → bytes
Write Contract 17 functions
These functions modify contract state and require a wallet transaction to execute.
approve 0x095ea7b3
address to
uint256 tokenId
donate 0xed88c68e
No parameters
lzReceive 0x001d3567
uint16 _srcChainId
bytes _srcAddress
uint64 _nonce
bytes _payload
mint 0x6ecd2306
uint8 numTokens
onLzReceive 0x1c37a822
uint16 _srcChainId
bytes _srcAddress
uint64 _nonce
bytes _payload
renounceOwnership 0x715018a6
No parameters
retryMessage 0xd1deba1f
uint16 _srcChainId
bytes _srcAddress
uint64 _nonce
bytes _payload
safeTransferFrom 0x42842e0e
address from
address to
uint256 tokenId
safeTransferFrom 0xb88d4fde
address from
address to
uint256 tokenId
bytes _data
setApprovalForAll 0xa22cb465
address operator
bool approved
setBaseURI 0x55f804b3
string URI
setGasForDestinationLzReceive 0x943fb872
uint256 newVal
setTrustedRemote 0xeb8d72b7
uint16 _chainId
bytes _trustedRemote
transferFrom 0x23b872dd
address from
address to
uint256 tokenId
transferOwnership 0xf2fde38b
address newOwner
traverseChains 0xcf89fa03
uint16 _chainId
uint256 tokenId
withdraw 0x2e1a7d4d
uint256 amt
Recent Transactions
No transactions found for this address