Address Contract Verified
Address
0x72c218d92fb6C7Fb6AE43739DFba0cC8ce62BEae
Balance
0 ETH
Nonce
1
Code Size
10545 bytes
Creator
0x17AeBA15...e75C at tx 0x33cdd013...0e1312
Indexed Transactions
0
Contract Bytecode
10545 bytes
0x6080604052600436106100f75760003560e01c806391d148541161008a578063d364461f11610059578063d364461f14610381578063d547741f146103be578063ecd0c0c3146103e7578063eeca266714610412576100fe565b806391d14854146102b157806395440919146102ee578063a217fddf1461032b578063b5bfddea14610356576100fe565b80632f2ff15d116100c65780632f2ff15d146101e557806336568abe1461020e57806351cff8d91461023757806359e8e64614610274576100fe565b806301ffc9a71461010357806312c8fedd1461014057806321df0da71461017d578063248a9ca3146101a8576100fe565b366100fe57005b600080fd5b34801561010f57600080fd5b5061012a60048036038101906101259190611a6a565b610442565b6040516101379190611fd8565b60405180910390f35b34801561014c57600080fd5b5061016760048036038101906101629190611b84565b6104bc565b6040516101749190611fd8565b60405180910390f35b34801561018957600080fd5b5061019261060d565b60405161019f9190612037565b60405180910390f35b3480156101b457600080fd5b506101cf60048036038101906101ca9190611a05565b610635565b6040516101dc9190611ff3565b60405180910390f35b3480156101f157600080fd5b5061020c60048036038101906102079190611a2e565b610654565b005b34801561021a57600080fd5b5061023560048036038101906102309190611a2e565b610675565b005b34801561024357600080fd5b5061025e60048036038101906102599190611a93565b6106f8565b60405161026b9190611fd8565b60405180910390f35b34801561028057600080fd5b5061029b60048036038101906102969190611ae5565b61088a565b6040516102a89190611fd8565b60405180910390f35b3480156102bd57600080fd5b506102d860048036038101906102d39190611a2e565b6108d2565b6040516102e59190611fd8565b60405180910390f35b3480156102fa57600080fd5b5061031560048036038101906103109190611ae5565b61093c565b6040516103229190611fd8565b60405180910390f35b34801561033757600080fd5b5061034061096b565b60405161034d9190611ff3565b60405180910390f35b34801561036257600080fd5b5061036b610972565b6040516103789190611ff3565b60405180910390f35b34801561038d57600080fd5b506103a860048036038101906103a39190611b21565b610996565b6040516103b59190611fd8565b60405180910390f35b3480156103ca57600080fd5b506103e560048036038101906103e09190611a2e565b610edb565b005b3480156103f357600080fd5b506103fc610efc565b6040516104099190612037565b60405180910390f35b61042c60048036038101906104279190611ae5565b610f20565b6040516104399190611fd8565b60405180910390f35b60007f7965db0b000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff191614806104b557506104b482611053565b5b9050919050565b60007f00000000000000000000000080c62fe4487e1351b47ba49809ebd60ed085bf5273ffffffffffffffffffffffffffffffffffffffff166323b872dd3330856040518463ffffffff1660e01b815260040161051b93929190611f78565b602060405180830381600087803b15801561053557600080fd5b505af1158015610549573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061056d91906119dc565b6105ac576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016105a390612154565b60405180910390fd5b823373ffffffffffffffffffffffffffffffffffffffff168563ffffffff167f772704eafe292d3424c0e0933166809882c3177a2df9cf45d32f6d1bb568b22e856040516105fa9190612254565b60405180910390a4600190509392505050565b60007f00000000000000000000000080c62fe4487e1351b47ba49809ebd60ed085bf52905090565b6000806000838152602001908152602001600020600101549050919050565b61065d82610635565b610666816110bd565b61067083836110d1565b505050565b61067d6111b1565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16146106ea576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016106e190612234565b60405180910390fd5b6106f482826111b9565b5050565b600061070e6000801b6107096111b1565b6108d2565b61074d576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161074490612174565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff161461083957610834338373ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016107be9190611f5d565b60206040518083038186803b1580156107d657600080fd5b505afa1580156107ea573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061080e9190611abc565b8473ffffffffffffffffffffffffffffffffffffffff1661129a9092919063ffffffff16565b610881565b3373ffffffffffffffffffffffffffffffffffffffff166108fc479081150290604051600060405180830381858888f1935050505015801561087f573d6000803e3d6000fd5b505b60019050919050565b6000600160008463ffffffff1663ffffffff168152602001908152602001600020600083815260200190815260200160002060009054906101000a900460ff16905092915050565b600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff16905092915050565b60016020528160005260406000206020528060005260406000206000915091509054906101000a900460ff1681565b6000801b81565b7f52ba824bfabc2bcfcdf7f0edbb486ebb05e1836c90e78047efeb949990f72e5f81565b60006109c97f52ba824bfabc2bcfcdf7f0edbb486ebb05e1836c90e78047efeb949990f72e5f6109c46111b1565b6108d2565b610a08576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016109ff906121f4565b60405180910390fd5b600073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610a78576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610a6f90612114565b60405180910390fd5b3073ffffffffffffffffffffffffffffffffffffffff168373ffffffffffffffffffffffffffffffffffffffff161415610ae7576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ade906120d4565b60405180910390fd5b60008073ffffffffffffffffffffffffffffffffffffffff167f00000000000000000000000080c62fe4487e1351b47ba49809ebd60ed085bf5273ffffffffffffffffffffffffffffffffffffffff1614905080610c2f57827f00000000000000000000000080c62fe4487e1351b47ba49809ebd60ed085bf5273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b8152600401610b999190611f5d565b60206040518083038186803b158015610bb157600080fd5b505afa158015610bc5573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610be99190611abc565b1015610c2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c2190612094565b60405180910390fd5b610c73565b82471015610c72576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610c6990612094565b60405180910390fd5b5b600160008763ffffffff1663ffffffff168152602001908152602001600020600086815260200190815260200160002060009054906101000a900460ff1615610cf1576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610ce890612134565b60405180910390fd5b60018060008863ffffffff1663ffffffff168152602001908152602001600020600087815260200190815260200160002060006101000a81548160ff02191690831515021790555080610e2f577f00000000000000000000000080c62fe4487e1351b47ba49809ebd60ed085bf5273ffffffffffffffffffffffffffffffffffffffff1663a9059cbb85856040518363ffffffff1660e01b8152600401610d99929190611faf565b602060405180830381600087803b158015610db357600080fd5b505af1158015610dc7573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610deb91906119dc565b610e2a576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610e2190612214565b60405180910390fd5b610e77565b8373ffffffffffffffffffffffffffffffffffffffff166108fc849081150290604051600060405180830381858888f19350505050158015610e75573d6000803e3d6000fd5b505b8373ffffffffffffffffffffffffffffffffffffffff168663ffffffff167f915db48d8fb487d7270d03883272f79acecb5ffdf96da8a9df141de5a45a4ffc8786604051610ec692919061200e565b60405180910390a36001915050949350505050565b610ee482610635565b610eed816110bd565b610ef783836111b9565b505050565b7f00000000000000000000000080c62fe4487e1351b47ba49809ebd60ed085bf5281565b60008073ffffffffffffffffffffffffffffffffffffffff167f00000000000000000000000080c62fe4487e1351b47ba49809ebd60ed085bf5273ffffffffffffffffffffffffffffffffffffffff1614610fb0576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fa790612194565b60405180910390fd5b60003411610ff3576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610fea906120b4565b60405180910390fd5b813373ffffffffffffffffffffffffffffffffffffffff168463ffffffff167f772704eafe292d3424c0e0933166809882c3177a2df9cf45d32f6d1bb568b22e346040516110419190612254565b60405180910390a46001905092915050565b60007f01ffc9a7000000000000000000000000000000000000000000000000000000007bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916827bffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916149050919050565b6110ce816110c96111b1565b611320565b50565b6110db82826108d2565b6111ad57600160008084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055506111526111b1565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b600033905090565b6111c382826108d2565b1561129657600080600084815260200190815260200160002060000160008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff02191690831515021790555061123b6111b1565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b61131b8363a9059cbb60e01b84846040516024016112b9929190611faf565b604051602081830303815290604052907bffffffffffffffffffffffffffffffffffffffffffffffffffffffff19166020820180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff83818316178352505050506113bd565b505050565b61132a82826108d2565b6113b95761134f8173ffffffffffffffffffffffffffffffffffffffff166014611484565b61135d8360001c6020611484565b60405160200161136e929190611f23565b6040516020818303038152906040526040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016113b09190612052565b60405180910390fd5b5050565b600061141f826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661177e9092919063ffffffff16565b905060008151111561147f578080602001905181019061143f91906119dc565b61147e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611475906121d4565b60405180910390fd5b5b505050565b6060600060028360026114979190612302565b6114a191906122ac565b67ffffffffffffffff8111156114e0577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b6040519080825280601f01601f1916602001820160405280156115125781602001600182028036833780820191505090505b5090507f300000000000000000000000000000000000000000000000000000000000000081600081518110611570577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053507f7800000000000000000000000000000000000000000000000000000000000000816001815181106115fa577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a9053506000600184600261163a9190612302565b61164491906122ac565b90505b6001811115611730577f3031323334353637383961626364656600000000000000000000000000000000600f8616601081106116ac577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b1a60f81b8282815181106116e9577f4e487b7100000000000000000000000000000000000000000000000000000000600052603260045260246000fd5b60200101907effffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff1916908160001a905350600485901c94508061172990612453565b9050611647565b5060008414611774576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161176b90612074565b60405180910390fd5b8091505092915050565b606061178d8484600085611796565b90509392505050565b6060824710156117db576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016117d2906120f4565b60405180910390fd5b6117e4856118aa565b611823576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161181a906121b4565b60405180910390fd5b6000808673ffffffffffffffffffffffffffffffffffffffff16858760405161184c9190611f0c565b60006040518083038185875af1925050503d8060008114611889576040519150601f19603f3d011682016040523d82523d6000602084013e61188e565b606091505b509150915061189e8282866118cd565b92505050949350505050565b6000808273ffffffffffffffffffffffffffffffffffffffff163b119050919050565b606083156118dd5782905061192d565b6000835111156118f05782518084602001fd5b816040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016119249190612052565b60405180910390fd5b9392505050565b6000813590506119438161285a565b92915050565b60008151905061195881612871565b92915050565b60008135905061196d81612888565b92915050565b6000813590506119828161289f565b92915050565b600081359050611997816128b6565b92915050565b6000813590506119ac816128cd565b92915050565b6000815190506119c1816128cd565b92915050565b6000813590506119d6816128e4565b92915050565b6000602082840312156119ee57600080fd5b60006119fc84828501611949565b91505092915050565b600060208284031215611a1757600080fd5b6000611a258482850161195e565b91505092915050565b60008060408385031215611a4157600080fd5b6000611a4f8582860161195e565b9250506020611a6085828601611934565b9150509250929050565b600060208284031215611a7c57600080fd5b6000611a8a84828501611973565b91505092915050565b600060208284031215611aa557600080fd5b6000611ab384828501611988565b91505092915050565b600060208284031215611ace57600080fd5b6000611adc848285016119b2565b91505092915050565b60008060408385031215611af857600080fd5b6000611b06858286016119c7565b9250506020611b178582860161195e565b9150509250929050565b60008060008060808587031215611b3757600080fd5b6000611b45878288016119c7565b9450506020611b568782880161195e565b9350506040611b6787828801611934565b9250506060611b788782880161199d565b91505092959194509250565b600080600060608486031215611b9957600080fd5b6000611ba7868287016119c7565b9350506020611bb88682870161195e565b9250506040611bc98682870161199d565b9150509250925092565b611bdc8161235c565b82525050565b611beb8161236e565b82525050565b611bfa8161237a565b82525050565b6000611c0b8261226f565b611c158185612285565b9350611c25818560208601612420565b80840191505092915050565b611c3a816123fc565b82525050565b6000611c4b8261227a565b611c558185612290565b9350611c65818560208601612420565b611c6e816124ac565b840191505092915050565b6000611c848261227a565b611c8e81856122a1565b9350611c9e818560208601612420565b80840191505092915050565b6000611cb7602083612290565b9150611cc2826124bd565b602082019050919050565b6000611cda602283612290565b9150611ce5826124e6565b604082019050919050565b6000611cfd601c83612290565b9150611d0882612535565b602082019050919050565b6000611d20601a83612290565b9150611d2b8261255e565b602082019050919050565b6000611d43602683612290565b9150611d4e82612587565b604082019050919050565b6000611d66601d83612290565b9150611d71826125d6565b602082019050919050565b6000611d89602083612290565b9150611d94826125ff565b602082019050919050565b6000611dac601d83612290565b9150611db782612628565b602082019050919050565b6000611dcf602283612290565b9150611dda82612651565b604082019050919050565b6000611df2602383612290565b9150611dfd826126a0565b604082019050919050565b6000611e15601d83612290565b9150611e20826126ef565b602082019050919050565b6000611e386017836122a1565b9150611e4382612718565b601782019050919050565b6000611e5b602a83612290565b9150611e6682612741565b604082019050919050565b6000611e7e601983612290565b9150611e8982612790565b602082019050919050565b6000611ea1601e83612290565b9150611eac826127b9565b602082019050919050565b6000611ec46011836122a1565b9150611ecf826127e2565b601182019050919050565b6000611ee7602f83612290565b9150611ef28261280b565b604082019050919050565b611f06816123e2565b82525050565b6000611f188284611c00565b915081905092915050565b6000611f2e82611e2b565b9150611f3a8285611c79565b9150611f4582611eb7565b9150611f518284611c79565b91508190509392505050565b6000602082019050611f726000830184611bd3565b92915050565b6000606082019050611f8d6000830186611bd3565b611f9a6020830185611bd3565b611fa76040830184611efd565b949350505050565b6000604082019050611fc46000830185611bd3565b611fd16020830184611efd565b9392505050565b6000602082019050611fed6000830184611be2565b92915050565b60006020820190506120086000830184611bf1565b92915050565b60006040820190506120236000830185611bf1565b6120306020830184611efd565b9392505050565b600060208201905061204c6000830184611c31565b92915050565b6000602082019050818103600083015261206c8184611c40565b905092915050565b6000602082019050818103600083015261208d81611caa565b9050919050565b600060208201905081810360008301526120ad81611ccd565b9050919050565b600060208201905081810360008301526120cd81611cf0565b9050919050565b600060208201905081810360008301526120ed81611d13565b9050919050565b6000602082019050818103600083015261210d81611d36565b9050919050565b6000602082019050818103600083015261212d81611d59565b9050919050565b6000602082019050818103600083015261214d81611d7c565b9050919050565b6000602082019050818103600083015261216d81611d9f565b9050919050565b6000602082019050818103600083015261218d81611dc2565b9050919050565b600060208201905081810360008301526121ad81611de5565b9050919050565b600060208201905081810360008301526121cd81611e08565b9050919050565b600060208201905081810360008301526121ed81611e4e565b9050919050565b6000602082019050818103600083015261220d81611e71565b9050919050565b6000602082019050818103600083015261222d81611e94565b9050919050565b6000602082019050818103600083015261224d81611eda565b9050919050565b60006020820190506122696000830184611efd565b92915050565b600081519050919050565b600081519050919050565b600081905092915050565b600082825260208201905092915050565b600081905092915050565b60006122b7826123e2565b91506122c2836123e2565b9250827fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff038211156122f7576122f661247d565b5b828201905092915050565b600061230d826123e2565b9150612318836123e2565b9250817fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff04831182151516156123515761235061247d565b5b828202905092915050565b6000612367826123c2565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b60006123bb8261235c565b9050919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600063ffffffff82169050919050565b60006124078261240e565b9050919050565b6000612419826123c2565b9050919050565b60005b8381101561243e578082015181840152602081019050612423565b8381111561244d576000848401525b50505050565b600061245e826123e2565b915060008214156124725761247161247d565b5b600182039050919050565b7f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b6000601f19601f8301169050919050565b7f537472696e67733a20686578206c656e67746820696e73756666696369656e74600082015250565b7f436c6f7665724272696467653a2062616c616e636520696e737566666963696560008201527f6e74000000000000000000000000000000000000000000000000000000000000602082015250565b7f436c6f7665724272696467653a2076616c756520726571756972656400000000600082015250565b7f436c6f7665724272696467653a20696e76616c69642064657374000000000000600082015250565b7f416464726573733a20696e73756666696369656e742062616c616e636520666f60008201527f722063616c6c0000000000000000000000000000000000000000000000000000602082015250565b7f436c6f7665724272696467653a20696e76616c69642061646472657373000000600082015250565b7f436c6f7665724272696467653a20747820616c7265616479206d696e74656421600082015250565b7f436c6f7665724272696467653a207472616e73666572206661696c6564000000600082015250565b7f436c6f7665724272696467653a206d75737420686176652061646d696e20726f60008201527f6c65000000000000000000000000000000000000000000000000000000000000602082015250565b7f436c6f7665724272696467653a20696e76616c696420627269646765206d657460008201527f686f640000000000000000000000000000000000000000000000000000000000602082015250565b7f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000600082015250565b7f416363657373436f6e74726f6c3a206163636f756e7420000000000000000000600082015250565b7f5361666545524332303a204552433230206f7065726174696f6e20646964206e60008201527f6f74207375636365656400000000000000000000000000000000000000000000602082015250565b7f436c6f7665724272696467653a2062726964676520726f6c6500000000000000600082015250565b7f436c6f7665724272696467653a207472616e73666572206661696c6564210000600082015250565b7f206973206d697373696e6720726f6c6520000000000000000000000000000000600082015250565b7f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008201527f20726f6c657320666f722073656c660000000000000000000000000000000000602082015250565b6128638161235c565b811461286e57600080fd5b50565b61287a8161236e565b811461288557600080fd5b50565b6128918161237a565b811461289c57600080fd5b50565b6128a881612384565b81146128b357600080fd5b50565b6128bf816123b0565b81146128ca57600080fd5b50565b6128d6816123e2565b81146128e157600080fd5b50565b6128ed816123ec565b81146128f857600080fd5b5056fea2646970667358221220645f0ba3a3443a9191f54a2f07541bd291e246293055a8008801bbd3d0022d6264736f6c63430008040033
Verified Source Code Full Match
Compiler: v0.8.4+commit.c7e474f2
EVM: istanbul
Optimization: No
CloverBridge.sol 104 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "@openzeppelin/contracts/access/AccessControl.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
// Clover ERC20 token contract
contract CloverBridge is AccessControl {
using SafeERC20 for IERC20;
// bridge role which could mint bridge transactions
bytes32 public constant BRIDGE_ROLE = keccak256("BRIDGE_ROLE");
event CrossTransfered(uint32 indexed chainId, address indexed from, bytes32 indexed dest, uint256 amount);
event TransactionMinted(uint32 indexed chainId, bytes32 txHash, address indexed dest, uint256 amount);
IERC20 public immutable _token;
// chainId => minted transactions
mapping(uint32 => mapping(bytes32 => bool)) public _mintedTransactions;
constructor(IERC20 token) {
_setupRole(DEFAULT_ADMIN_ROLE, _msgSender());
_setupRole(BRIDGE_ROLE, _msgSender());
_token = token;
}
// return the token info
function getToken() public view returns (IERC20) {
return _token;
}
function crossTransfer(
uint32 chainId,
bytes32 dest,
uint256 amount
) external returns (bool) {
require(_token.transferFrom(msg.sender, address(this), amount), "CloverBridge: transfer failed");
emit CrossTransfered(chainId, msg.sender, dest, amount);
return true;
}
function crossTransferNative(uint32 chainId, bytes32 dest) external payable returns (bool) {
require(address(_token) == address(0), "CloverBridge: invalid bridge method");
require(msg.value > 0, "CloverBridge: value required");
emit CrossTransfered(chainId, msg.sender, dest, msg.value);
return true;
}
// mint a tx from outside to current chain(e.g. ethereum)
// note here we use bytes32 to represent an unique transaction on the source chain
// the txHash conventation should be identical between the bridge minters
function mintTransaction(
uint32 chainId,
bytes32 txHash,
address dest,
uint256 amount
) external returns (bool) {
require(hasRole(BRIDGE_ROLE, _msgSender()), "CloverBridge: bridge role");
require(dest != address(0), "CloverBridge: invalid address");
require(dest != address(this), "CloverBridge: invalid dest");
bool isNative = address(_token) == address(0);
if (!isNative) {
require(_token.balanceOf(address(this)) >= amount, "CloverBridge: balance insufficient");
} else {
require(address(this).balance >= amount, "CloverBridge: balance insufficient");
}
require(!_mintedTransactions[chainId][txHash], "CloverBridge: tx already minted!");
_mintedTransactions[chainId][txHash] = true;
if (!isNative) {
require(_token.transfer(dest, amount), "CloverBridge: transfer failed!");
} else {
payable(dest).transfer(amount);
}
emit TransactionMinted(chainId, txHash, dest, amount);
return true;
}
function isMinted(uint32 chainId, bytes32 txHash) public view returns (bool) {
return _mintedTransactions[chainId][txHash];
}
receive() external payable {
// deposit function
}
// helper method to withdraw tokens to the admin account
function withdraw(IERC20 token) external returns (bool) {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "CloverBridge: must have admin role");
if (address(token) != address(0)) {
token.safeTransfer(msg.sender, token.balanceOf(address(this)));
} else {
payable(msg.sender).transfer(address(this).balance);
}
return true;
}
}
Address.sol 222 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)
pragma solidity ^0.8.1;
/**
* @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
* ====
*
* [IMPORTANT]
* ====
* You shouldn't rely on `isContract` to protect against flash loan attacks!
*
* Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets
* like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract
* constructor.
* ====
*/
function isContract(address account) internal view returns (bool) {
// This method relies on extcodesize/address.code.length, which returns 0
// for contracts in construction, since the code is only stored at the end
// of the constructor execution.
return account.code.length > 0;
}
/**
* @dev Replacement for Solidity's `transfer`: sends `amount` wei to
* `recipient`, forwarding all available gas and reverting on errors.
*
* https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
* of certain opcodes, possibly making contracts go over the 2300 gas limit
* imposed by `transfer`, making them unable to receive funds via
* `transfer`. {sendValue} removes this limitation.
*
* https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
*
* IMPORTANT: because control is transferred to `recipient`, care must be
* taken to not create reentrancy vulnerabilities. Consider using
* {ReentrancyGuard} or the
* https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
*/
function sendValue(address payable recipient, uint256 amount) internal {
require(address(this).balance >= amount, "Address: insufficient balance");
(bool success, ) = recipient.call{value: amount}("");
require(success, "Address: unable to send value, recipient may have reverted");
}
/**
* @dev Performs a Solidity function call using a low level `call`. A
* plain `call` is an unsafe replacement for a function call: use this
* function instead.
*
* If `target` reverts with a revert reason, it is bubbled up by this
* function (like regular Solidity function calls).
*
* Returns the raw returned data. To convert to the expected return value,
* use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].
*
* Requirements:
*
* - `target` must be a contract.
* - calling `target` with `data` must not revert.
*
* _Available since v3.1._
*/
function functionCall(address target, bytes memory data) internal returns (bytes memory) {
return functionCall(target, data, "Address: low-level call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with
* `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
return functionCallWithValue(target, data, 0, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but also transferring `value` wei to `target`.
*
* Requirements:
*
* - the calling contract must have an ETH balance of at least `value`.
* - the called Solidity function must be `payable`.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value
) internal returns (bytes memory) {
return functionCallWithValue(target, data, value, "Address: low-level call with value failed");
}
/**
* @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but
* with `errorMessage` as a fallback revert reason when `target` reverts.
*
* _Available since v3.1._
*/
function functionCallWithValue(
address target,
bytes memory data,
uint256 value,
string memory errorMessage
) internal returns (bytes memory) {
require(address(this).balance >= value, "Address: insufficient balance for call");
require(isContract(target), "Address: call to non-contract");
(bool success, bytes memory returndata) = target.call{value: value}(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {
return functionStaticCall(target, data, "Address: low-level static call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a static call.
*
* _Available since v3.3._
*/
function functionStaticCall(
address target,
bytes memory data,
string memory errorMessage
) internal view returns (bytes memory) {
require(isContract(target), "Address: static call to non-contract");
(bool success, bytes memory returndata) = target.staticcall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {
return functionDelegateCall(target, data, "Address: low-level delegate call failed");
}
/**
* @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
* but performing a delegate call.
*
* _Available since v3.4._
*/
function functionDelegateCall(
address target,
bytes memory data,
string memory errorMessage
) internal returns (bytes memory) {
require(isContract(target), "Address: delegate call to non-contract");
(bool success, bytes memory returndata) = target.delegatecall(data);
return verifyCallResult(success, returndata, errorMessage);
}
/**
* @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the
* revert reason using the provided one.
*
* _Available since v4.3._
*/
function verifyCallResult(
bool success,
bytes memory returndata,
string memory errorMessage
) internal pure returns (bytes memory) {
if (success) {
return returndata;
} else {
// Look for revert reason and bubble it up if present
if (returndata.length > 0) {
// The easiest way to bubble the revert reason is using memory via assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)
pragma solidity ^0.8.0;
/**
* @dev Provides information about the current execution context, including the
* sender of the transaction and its data. While these are generally available
* via msg.sender and msg.data, they should not be accessed in such a direct
* manner, since when dealing with meta-transactions the account sending and
* paying for execution may not be the actual sender (as far as an application
* is concerned).
*
* This contract is only required for intermediate, library-like contracts.
*/
abstract contract Context {
function _msgSender() internal view virtual returns (address) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes calldata) {
return msg.data;
}
}
Strings.sol 67 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/Strings.sol)
pragma solidity ^0.8.0;
/**
* @dev String operations.
*/
library Strings {
bytes16 private constant _HEX_SYMBOLS = "0123456789abcdef";
/**
* @dev Converts a `uint256` to its ASCII `string` decimal representation.
*/
function toString(uint256 value) internal pure returns (string memory) {
// Inspired by OraclizeAPI's implementation - MIT licence
// https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
if (value == 0) {
return "0";
}
uint256 temp = value;
uint256 digits;
while (temp != 0) {
digits++;
temp /= 10;
}
bytes memory buffer = new bytes(digits);
while (value != 0) {
digits -= 1;
buffer[digits] = bytes1(uint8(48 + uint256(value % 10)));
value /= 10;
}
return string(buffer);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation.
*/
function toHexString(uint256 value) internal pure returns (string memory) {
if (value == 0) {
return "0x00";
}
uint256 temp = value;
uint256 length = 0;
while (temp != 0) {
length++;
temp >>= 8;
}
return toHexString(value, length);
}
/**
* @dev Converts a `uint256` to its ASCII `string` hexadecimal representation with fixed length.
*/
function toHexString(uint256 value, uint256 length) internal pure returns (string memory) {
bytes memory buffer = new bytes(2 * length + 2);
buffer[0] = "0";
buffer[1] = "x";
for (uint256 i = 2 * length + 1; i > 1; --i) {
buffer[i] = _HEX_SYMBOLS[value & 0xf];
value >>= 4;
}
require(value == 0, "Strings: hex length insufficient");
return string(buffer);
}
}
IERC20.sol 82 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (token/ERC20/IERC20.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC20 standard as defined in the EIP.
*/
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 amount of tokens in existence.
*/
function totalSupply() external view returns (uint256);
/**
* @dev Returns the amount of tokens owned by `account`.
*/
function balanceOf(address account) external view returns (uint256);
/**
* @dev Moves `amount` tokens from the caller's account to `to`.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transfer(address to, uint256 amount) external returns (bool);
/**
* @dev Returns the remaining number of tokens that `spender` will be
* allowed to spend on behalf of `owner` through {transferFrom}. This is
* zero by default.
*
* This value changes when {approve} or {transferFrom} are called.
*/
function allowance(address owner, address spender) external view returns (uint256);
/**
* @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* IMPORTANT: Beware that changing an allowance with this method brings the risk
* that someone may use both the old and the new allowance by unfortunate
* transaction ordering. One possible solution to mitigate this race
* condition is to first reduce the spender's allowance to 0 and set the
* desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
*
* Emits an {Approval} event.
*/
function approve(address spender, uint256 amount) external returns (bool);
/**
* @dev Moves `amount` tokens from `from` to `to` using the
* allowance mechanism. `amount` is then deducted from the caller's
* allowance.
*
* Returns a boolean value indicating whether the operation succeeded.
*
* Emits a {Transfer} event.
*/
function transferFrom(
address from,
address to,
uint256 amount
) external returns (bool);
}
AccessControl.sol 235 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts (last updated v4.6.0) (access/AccessControl.sol)
pragma solidity ^0.8.0;
import "./IAccessControl.sol";
import "../utils/Context.sol";
import "../utils/Strings.sol";
import "../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:
*
* ```
* 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}:
*
* ```
* 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.
*/
abstract contract AccessControl is Context, IAccessControl, ERC165 {
struct RoleData {
mapping(address => bool) members;
bytes32 adminRole;
}
mapping(bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Modifier that checks that an account has a specific role. Reverts
* with a standardized message including the required role.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*
* _Available since v4.1._
*/
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 override returns (bool) {
return _roles[role].members[account];
}
/**
* @dev Revert with a standard message if `_msgSender()` is missing `role`.
* Overriding this function changes the behavior of the {onlyRole} modifier.
*
* Format of the revert message is described in {_checkRole}.
*
* _Available since v4.6._
*/
function _checkRole(bytes32 role) internal view virtual {
_checkRole(role, _msgSender());
}
/**
* @dev Revert with a standard message if `account` is missing `role`.
*
* The format of the revert reason is given by the following regular expression:
*
* /^AccessControl: account (0x[0-9a-f]{40}) is missing role (0x[0-9a-f]{64})$/
*/
function _checkRole(bytes32 role, address account) internal view virtual {
if (!hasRole(role, account)) {
revert(
string(
abi.encodePacked(
"AccessControl: account ",
Strings.toHexString(uint160(account), 20),
" is missing role ",
Strings.toHexString(uint256(role), 32)
)
)
);
}
}
/**
* @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 override 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.
*/
function grantRole(bytes32 role, address account) public virtual override 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.
*/
function revokeRole(bytes32 role, address account) public virtual override 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 `account`.
*/
function renounceRole(bytes32 role, address account) public virtual override {
require(account == _msgSender(), "AccessControl: can only renounce roles for self");
_revokeRole(role, account);
}
/**
* @dev Grants `role` to `account`.
*
* If `account` had not been already granted `role`, emits a {RoleGranted}
* event. Note that unlike {grantRole}, this function doesn't perform any
* checks on the calling account.
*
* [WARNING]
* ====
* This function should only be called from the constructor when setting
* up the initial roles for the system.
*
* Using this function in any other way is effectively circumventing the admin
* system imposed by {AccessControl}.
* ====
*
* NOTE: This function is deprecated in favor of {_grantRole}.
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @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 Grants `role` to `account`.
*
* Internal function without access restriction.
*/
function _grantRole(bytes32 role, address account) internal virtual {
if (!hasRole(role, account)) {
_roles[role].members[account] = true;
emit RoleGranted(role, account, _msgSender());
}
}
/**
* @dev Revokes `role` from `account`.
*
* Internal function without access restriction.
*/
function _revokeRole(bytes32 role, address account) internal virtual {
if (hasRole(role, account)) {
_roles[role].members[account] = false;
emit RoleRevoked(role, account, _msgSender());
}
}
}
IAccessControl.sol 88 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (access/IAccessControl.sol)
pragma solidity ^0.8.0;
/**
* @dev External interface of AccessControl declared to support ERC165 detection.
*/
interface IAccessControl {
/**
* @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.
*
* _Available since v3.1._
*/
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, an admin role
* bearer except when using {AccessControl-_setupRole}.
*/
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 `account`.
*/
function renounceRole(bytes32 role, address account) external;
}
ERC165.sol 29 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/ERC165.sol)
pragma solidity ^0.8.0;
import "./IERC165.sol";
/**
* @dev Implementation of the {IERC165} interface.
*
* Contracts that want to implement ERC165 should inherit from this contract and override {supportsInterface} to check
* for the additional interface id that will be supported. For example:
*
* ```solidity
* function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
* return interfaceId == type(MyInterface).interfaceId || super.supportsInterface(interfaceId);
* }
* ```
*
* Alternatively, {ERC165Storage} provides an easier to use but more expensive implementation.
*/
abstract contract ERC165 is IERC165 {
/**
* @dev See {IERC165-supportsInterface}.
*/
function supportsInterface(bytes4 interfaceId) public view virtual override returns (bool) {
return interfaceId == type(IERC165).interfaceId;
}
}
SafeERC20.sol 99 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)
pragma solidity ^0.8.0;
import "../IERC20.sol";
import "../../../utils/Address.sol";
/**
* @title SafeERC20
* @dev Wrappers around ERC20 operations that throw on failure (when the token
* contract returns false). Tokens that return no value (and instead revert or
* throw on failure) are also supported, non-reverting calls are assumed to be
* successful.
* To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
* which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
*/
library SafeERC20 {
using Address for address;
function safeTransfer(
IERC20 token,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
}
function safeTransferFrom(
IERC20 token,
address from,
address to,
uint256 value
) internal {
_callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
}
/**
* @dev Deprecated. This function has issues similar to the ones found in
* {IERC20-approve}, and its usage is discouraged.
*
* Whenever possible, use {safeIncreaseAllowance} and
* {safeDecreaseAllowance} instead.
*/
function safeApprove(
IERC20 token,
address spender,
uint256 value
) internal {
// safeApprove should only be called when setting an initial allowance,
// or when resetting it to zero. To increase and decrease it, use
// 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
require(
(value == 0) || (token.allowance(address(this), spender) == 0),
"SafeERC20: approve from non-zero to non-zero allowance"
);
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
}
function safeIncreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
uint256 newAllowance = token.allowance(address(this), spender) + value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
function safeDecreaseAllowance(
IERC20 token,
address spender,
uint256 value
) internal {
unchecked {
uint256 oldAllowance = token.allowance(address(this), spender);
require(oldAllowance >= value, "SafeERC20: decreased allowance below zero");
uint256 newAllowance = oldAllowance - value;
_callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
}
}
/**
* @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
* on the return value: the return value is optional (but if data is returned, it must not be false).
* @param token The token targeted by the call.
* @param data The call data (encoded using abi.encode or one of its variants).
*/
function _callOptionalReturn(IERC20 token, bytes memory data) private {
// We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
// we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that
// the target address contains contract code and also asserts for success in the low-level call.
bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
if (returndata.length > 0) {
// Return data is optional
require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
}
}
}
IERC165.sol 25 lines
// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.4.1 (utils/introspection/IERC165.sol)
pragma solidity ^0.8.0;
/**
* @dev Interface of the ERC165 standard, as defined in the
* https://eips.ethereum.org/EIPS/eip-165[EIP].
*
* Implementers can declare support of contract interfaces, which can then be
* queried by others ({ERC165Checker}).
*
* For an implementation, see {ERC165}.
*/
interface IERC165 {
/**
* @dev Returns true if this contract implements the interface defined by
* `interfaceId`. See the corresponding
* https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
* to learn more about how these ids are created.
*
* This function call must use less than 30 000 gas.
*/
function supportsInterface(bytes4 interfaceId) external view returns (bool);
}
Read Contract
BRIDGE_ROLE 0xb5bfddea → bytes32
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
_mintedTransactions 0x95440919 → bool
_token 0xecd0c0c3 → address
getRoleAdmin 0x248a9ca3 → bytes32
getToken 0x21df0da7 → address
hasRole 0x91d14854 → bool
isMinted 0x59e8e646 → bool
supportsInterface 0x01ffc9a7 → bool
Write Contract 7 functions
These functions modify contract state and require a wallet transaction to execute.
crossTransfer 0x12c8fedd
uint32 chainId
bytes32 dest
uint256 amount
returns: bool
crossTransferNative 0xeeca2667
uint32 chainId
bytes32 dest
returns: bool
grantRole 0x2f2ff15d
bytes32 role
address account
mintTransaction 0xd364461f
uint32 chainId
bytes32 txHash
address dest
uint256 amount
returns: bool
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
withdraw 0x51cff8d9
address token
returns: bool
Recent Transactions
No transactions found for this address