Address Contract Partially Verified
Address
0x7D0e63736aEb136aCd44C70D6e1A0f27fb897679
Balance
0 ETH
Nonce
1
Code Size
17808 bytes
Creator
0x6F2296C6...0ea4 at tx 0x538d49af...cb2c9a
Indexed Transactions
0
Contract Bytecode
17808 bytes
0x608060405234801561001057600080fd5b50600436106102485760003560e01c806384db809f1161013b578063beab7131116100b8578063cdb0f73a1161007c578063cdb0f73a14610712578063d547741f1461072e578063d7a9cd791461074a578063e8437ee714610768578063ffaac0eb1461078457610248565b8063beab71311461066c578063c5b37c221461068a578063c5ec8970146106a8578063ca15c873146106c6578063cb10f215146106f657610248565b8063926d7d7f116100ff578063926d7d7f146105c65780639d5773e0146105e45780639d82dd6314610602578063a217fddf1461061e578063a9cf69fa1461063c57610248565b806384db809f146104fe5780638c0c26311461052e5780639010d07c1461054a57806391c404ac1461057a57806391d148541461059657610248565b80634e056005116101c95780635e1fab0f1161018d5780635e1fab0f1461046e578063780cf0041461048a5780637febe63f146104a6578063802aabe8146104d657806380ae1c28146104f457610248565b80634e056005146103a157806350598719146103bd578063541d5548146103f0578063572b6c05146104205780635c975abb1461045057610248565b806336568abe1161021057806336568abe146102ed5780633ee7094a146103095780634454b20d146103395780634603ae38146103555780634b0b919d1461037157610248565b806305e2ca171461024d57806317f03ce5146102695780631ff013f114610285578063248a9ca3146102a15780632f2ff15d146102d1575b600080fd5b61026760048036038101906102629190613222565b61078e565b005b610283600480360381019061027e919061328e565b6107eb565b005b61029f600480360381019061029a91906132dd565b610998565b005b6102bb60048036038101906102b69190613068565b611154565b6040516102c89190613d78565b60405180910390f35b6102eb60048036038101906102e69190613091565b611174565b005b61030760048036038101906103029190613091565b6111e1565b005b610323600480360381019061031e9190613132565b61125d565b6040516103309190613ef9565b60405180910390f35b610353600480360381019061034e9190613340565b61131a565b005b61036f600480360381019061036a9190612ff3565b611381565b005b61038b600480360381019061038691906131f9565b611424565b6040516103989190614258565b60405180910390f35b6103bb60048036038101906103b69190613109565b61144b565b005b6103d760048036038101906103d2919061316e565b61148a565b6040516103e79493929190613e2a565b60405180910390f35b61040a60048036038101906104059190612e3c565b6114d4565b6040516104179190613d5d565b60405180910390f35b61043a60048036038101906104359190612e3c565b611507565b6040516104479190613d5d565b60405180910390f35b61045861155f565b6040516104659190613d5d565b60405180910390f35b61048860048036038101906104839190612e3c565b611575565b005b6104a4600480360381019061049f9190612eca565b6115a1565b005b6104c060048036038101906104bb91906131aa565b611624565b6040516104cd9190613d5d565b60405180910390f35b6104de611660565b6040516104eb919061423d565b60405180910390f35b6104fc611666565b005b61051860048036038101906105139190613068565b611678565b6040516105259190613cf0565b60405180910390f35b61054860048036038101906105439190612e8e565b6116ab565b005b610564600480360381019061055f91906130cd565b611728565b6040516105719190613cf0565b60405180910390f35b610594600480360381019061058f9190613109565b61175a565b005b6105b060048036038101906105ab9190613091565b6117b1565b6040516105bd9190613d5d565b60405180910390f35b6105ce6117e3565b6040516105db9190613d78565b60405180910390f35b6105ec611807565b6040516105f9919061423d565b60405180910390f35b61061c60048036038101906106179190612e3c565b61180d565b005b610626611901565b6040516106339190613d78565b60405180910390f35b6106566004803603810190610651919061328e565b611908565b604051610663919061421b565b60405180910390f35b610674611ae9565b6040516106819190614273565b60405180910390f35b610692611afc565b60405161069f919061423d565b60405180910390f35b6106b0611b02565b6040516106bd919061423d565b60405180910390f35b6106e060048036038101906106db9190613068565b611b08565b6040516106ed919061423d565b60405180910390f35b610710600480360381019061070b9190612f2d565b611b2f565b005b61072c60048036038101906107279190612e3c565b611c01565b005b61074860048036038101906107439190613091565b611cf5565b005b610752611d62565b60405161075f919061423d565b60405180910390f35b610782600480360381019061077d9190612f7c565b611d68565b005b61078c611e40565b005b610796611eb2565b6107e5848484848080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050611f02565b50505050565b6107f3612168565b60008360ff1660088467ffffffffffffffff1668ffffffffffffffffff16901b1790506000600b60008368ffffffffffffffffff1668ffffffffffffffffff1681526020019081526020016000206000848152602001908152602001600020905060048081111561086057fe5b8160040160009054906101000a900460ff16600481111561087d57fe5b14156108be576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016108b59061405b565b60405180910390fd5b6007546108cf4383600501546121f5565b1161090f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610906906140db565b60405180910390fd5b60048160040160006101000a81548160ff0219169083600481111561093057fe5b021790555060048081111561094157fe5b8467ffffffffffffffff168660ff167f803c5a12f6bde629cea32e63d4b92d1b560816a6fb72e939d3c89e1cab65041784600001548560010154604051610989929190613e01565b60405180910390a45050505050565b6109a0612209565b6109a8611eb2565b60008460ff1660088567ffffffffffffffff1668ffffffffffffffffff16901b1790506000600b60008368ffffffffffffffffff1668ffffffffffffffffff168152602001908152602001600020600084815260200190815260200160002090506000610a1361227b565b9050600073ffffffffffffffffffffffffffffffffffffffff166009600087815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415610ab8576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610aaf906141db565b60405180910390fd5b60018260040160009054906101000a900460ff166004811115610ad757fe5b1115610b18576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610b0f9061413b565b60405180910390fd5b600c60008468ffffffffffffffffff1668ffffffffffffffffff168152602001908152602001600020600085815260200190815260200160002060008273ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060009054906101000a900460ff1615610bdd576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610bd490613fbb565b60405180910390fd5b60008260040160009054906101000a900460ff166004811115610bfc57fe5b1415610e4a57600560008154600101919050819055506040518060c00160405280868152602001858152602001600167ffffffffffffffff81118015610c4157600080fd5b50604051908082528060200260200182016040528015610c705781602001602082028036833780820191505090505b508152602001600067ffffffffffffffff81118015610c8e57600080fd5b50604051908082528060200260200182016040528015610cbd5781602001602082028036833780820191505090505b50815260200160016004811115610cd057fe5b815260200143815250600b60008568ffffffffffffffffff1668ffffffffffffffffff168152602001908152602001600020600086815260200190815260200160002060008201518160000155602082015181600101556040820151816002019080519060200190610d43929190612b0d565b506060820151816003019080519060200190610d60929190612b0d565b5060808201518160040160006101000a81548160ff02191690836004811115610d8557fe5b021790555060a082015181600501559050508082600201600081548110610da857fe5b9060005260206000200160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060016004811115610dfd57fe5b8667ffffffffffffffff168860ff167f803c5a12f6bde629cea32e63d4b92d1b560816a6fb72e939d3c89e1cab6504178888604051610e3d929190613e01565b60405180910390a4610f8d565b600754610e5b4384600501546121f5565b1115610ee05760048260040160006101000a81548160ff02191690836004811115610e8257fe5b0217905550600480811115610e9357fe5b8667ffffffffffffffff168860ff167f803c5a12f6bde629cea32e63d4b92d1b560816a6fb72e939d3c89e1cab6504178888604051610ed3929190613e01565b60405180910390a4610f8c565b81600101548414610f26576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401610f1d906141bb565b60405180910390fd5b81600201819080600181540180825580915050600190039060005260206000200160009091909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff1602179055505b5b600480811115610f9957fe5b8260040160009054906101000a900460ff166004811115610fb657fe5b1461114b576001600c60008568ffffffffffffffffff1668ffffffffffffffffff168152602001908152602001600020600086815260200190815260200160002060008373ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190815260200160002060006101000a81548160ff0219169083151502179055508160040160009054906101000a900460ff16600481111561106857fe5b8667ffffffffffffffff168860ff167f25f8daaa4635a7729927ba3f5b3d59cc3320aca7c32c9db4e7ca7b9574343640886040516110a69190613d78565b60405180910390a460016003541115806110c95750600354826002018054905010155b1561114a5760028260040160006101000a81548160ff021916908360048111156110ef57fe5b02179055506002600481111561110157fe5b8667ffffffffffffffff168860ff167f803c5a12f6bde629cea32e63d4b92d1b560816a6fb72e939d3c89e1cab6504178888604051611141929190613e01565b60405180910390a45b5b50505050505050565b600060016000838152602001908152602001600020600201549050919050565b6111946001600084815260200190815260200160002060020154336117b1565b6111d3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016111ca90613f9b565b60405180910390fd5b6111dd82826122ad565b5050565b3373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161461124f576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611246906141fb565b60405180910390fd5b611259828261233a565b5050565b600a602052816000526040600020602052806000526040600020600091509150508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156113125780601f106112e757610100808354040283529160200191611312565b820191906000526020600020905b8154815290600101906020018083116112f557829003601f168201915b505050505081565b611322612209565b61132a611eb2565b61137a858585858080601f016020809104026020016040519081016040528093929190818152602001838380828437600081840152601f19601f82011690508083019250505050505050846123c7565b5050505050565b611389612703565b60005b8484905081101561141d578484828181106113a357fe5b90506020020160208101906113b89190612e65565b73ffffffffffffffffffffffffffffffffffffffff166108fc8484848181106113dd57fe5b905060200201359081150290604051600060405180830381858888f1935050505015801561140f573d6000803e3d6000fd5b50808060010191505061138c565b5050505050565b60086020528060005260406000206000915054906101000a900467ffffffffffffffff1681565b611453612703565b80600381905550807fa20d6b84cd798a24038be305eff8a45ca82ef54a2aa2082005d8e14c0a4746c860405160405180910390a250565b600b602052816000526040600020602052806000526040600020600091509150508060000154908060010154908060040160009054906101000a900460ff16908060050154905084565b60006115007fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc4836117b1565b9050919050565b60007f000000000000000000000000000000000000000000000000000000000000000073ffffffffffffffffffffffffffffffffffffffff168273ffffffffffffffffffffffffffffffffffffffff16149050919050565b60008060009054906101000a900460ff16905090565b61157d612703565b61158a6000801b82611174565b61159e6000801b61159961227b565b6111e1565b50565b6115a9612703565b60008490508073ffffffffffffffffffffffffffffffffffffffff1663d9caed128585856040518463ffffffff1660e01b81526004016115eb93929190613d26565b600060405180830381600087803b15801561160557600080fd5b505af1158015611619573d6000803e3d6000fd5b505050505050505050565b600c602052826000526040600020602052816000526040600020602052806000526040600020600092509250509054906101000a900460ff1681565b60045481565b61166e612703565b611676612758565b565b60096020528060005260406000206000915054906101000a900473ffffffffffffffffffffffffffffffffffffffff1681565b6116b3612703565b60008290508073ffffffffffffffffffffffffffffffffffffffff166307b7ed99836040518263ffffffff1660e01b81526004016116f19190613cf0565b600060405180830381600087803b15801561170b57600080fd5b505af115801561171f573d6000803e3d6000fd5b50505050505050565b600061175282600160008681526020019081526020016000206000016127b390919063ffffffff16565b905092915050565b611762612703565b8060065414156117a7576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161179e9061419b565b60405180910390fd5b8060068190555050565b60006117db8260016000868152602001908152602001600020600001611e8290919063ffffffff16565b905092915050565b7fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc481565b60055481565b611815612703565b61183f7fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc4826117b1565b61187e576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161187590613ffb565b60405180910390fd5b6118a87fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc482611cf5565b8073ffffffffffffffffffffffffffffffffffffffff167f10e1f7ce9fd7d1b90a66d13a2ab3cb8dd7f29f3f8d520b143b063ccfbab6906b60405160405180910390a26004600081548092919060019003919050555050565b6000801b81565b611910612b97565b60008460ff1660088567ffffffffffffffff1668ffffffffffffffffff16901b179050600b60008268ffffffffffffffffff1668ffffffffffffffffff16815260200190815260200160002060008481526020019081526020016000206040518060c0016040529081600082015481526020016001820154815260200160028201805480602002602001604051908101604052809291908181526020018280548015611a1157602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116119c7575b5050505050815260200160038201805480602002602001604051908101604052809291908181526020018280548015611a9f57602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1681526020019060010190808311611a55575b505050505081526020016004820160009054906101000a900460ff166004811115611ac657fe5b6004811115611ad157fe5b81526020016005820154815250509150509392505050565b600260009054906101000a900460ff1681565b60065481565b60075481565b6000611b28600160008481526020019081526020016000206000016127cd565b9050919050565b611b37612703565b826009600084815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008390508073ffffffffffffffffffffffffffffffffffffffff1663b8fa373684846040518363ffffffff1660e01b8152600401611bc9929190613d93565b600060405180830381600087803b158015611be357600080fd5b505af1158015611bf7573d6000803e3d6000fd5b5050505050505050565b611c09612703565b611c337fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc4826117b1565b15611c73576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611c6a9061411b565b60405180910390fd5b611c9d7fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc482611174565b8073ffffffffffffffffffffffffffffffffffffffff167f03580ee9f53a62b7cb409a2cb56f9be87747dd15017afc5cef6eef321e4fb2c560405160405180910390a260046000815480929190600101919050555050565b611d156001600084815260200190815260200160002060020154336117b1565b611d54576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611d4b906140bb565b60405180910390fd5b611d5e828261233a565b5050565b60035481565b611d70612703565b846009600086815260200190815260200160002060006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555060008590508073ffffffffffffffffffffffffffffffffffffffff1663bba8185a868686866040518563ffffffff1660e01b8152600401611e069493929190613dbc565b600060405180830381600087803b158015611e2057600080fd5b505af1158015611e34573d6000803e3d6000fd5b50505050505050505050565b611e48612703565b611e506127e2565b565b6000611e7a836000018373ffffffffffffffffffffffffffffffffffffffff1660001b61283d565b905092915050565b6000611eaa836000018373ffffffffffffffffffffffffffffffffffffffff1660001b6128ad565b905092915050565b60008054906101000a900460ff1615611f00576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611ef7906140fb565b60405180910390fd5b565b611f0a611eb2565b6006543414611f4e576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611f459061401b565b60405180910390fd5b60006009600084815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050600073ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff161415611ff6576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401611fed9061409b565b60405180910390fd5b6000600860008660ff1660ff168152602001908152602001600020600081819054906101000a900467ffffffffffffffff1660010191906101000a81548167ffffffffffffffff021916908367ffffffffffffffff1602179055905082600a60008367ffffffffffffffff1667ffffffffffffffff16815260200190815260200160002060008760ff1660ff16815260200190815260200160002090805190602001906120a4929190612bde565b5060008290508073ffffffffffffffffffffffffffffffffffffffff166338995da98688856120d161227b565b896040518663ffffffff1660e01b81526004016120f2959493929190613e9f565b600060405180830381600087803b15801561210c57600080fd5b505af1158015612120573d6000803e3d6000fd5b505050508167ffffffffffffffff16858760ff167fdbb69440df8433824a026ef190652f29929eb64b4d1d5d2a69be8afe3e6eaed860405160405180910390a4505050505050565b61217c6000801b61217761227b565b6117b1565b806121b457506121b37fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc46121ae61227b565b6117b1565b5b6121f3576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016121ea90613f7b565b60405180910390fd5b565b600061220183836128d0565b905092915050565b61223a7fe2b7fb3b832174769106daebcfd6d1970523240dda11281102db9363b83b0dc461223561227b565b6117b1565b612279576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016122709061415b565b60405180910390fd5b565b600061228633611507565b1561229a57601436033560601c90506122a9565b6122a2612920565b90506122aa565b5b90565b6122d58160016000858152602001908152602001600020600001611e5290919063ffffffff16565b15612336573373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45b5050565b612362816001600085815260200190815260200160002060000161292890919063ffffffff16565b156123c3573373ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45b5050565b6123cf612209565b6123d7611eb2565b60006009600083815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16905060008560ff1660088667ffffffffffffffff1668ffffffffffffffffff16901b17905060008285604051602001612447929190613cc8565b6040516020818303038152906040528051906020012090506000600b60008468ffffffffffffffffff1668ffffffffffffffffff16815260200190815260200160002060008381526020019081526020016000209050600060048111156124aa57fe5b8160040160009054906101000a900460ff1660048111156124c757fe5b1415612508576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016124ff90613f3b565b60405180910390fd5b6002600481111561251557fe5b8160040160009054906101000a900460ff16600481111561253257fe5b14612572576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161256990613f1b565b60405180910390fd5b806001015482146125b8576040517f08c379a00000000000000000000000000000000000000000000000000000000081526004016125af9061403b565b60405180910390fd5b60038160040160006101000a81548160ff021916908360048111156125d957fe5b02179055506000600960008360000154815260200190815260200160002060009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1690508073ffffffffffffffffffffffffffffffffffffffff1663e248cff28360000154896040518363ffffffff1660e01b8152600401612659929190613e6f565b600060405180830381600087803b15801561267357600080fd5b505af1158015612687573d6000803e3d6000fd5b505050508160040160009054906101000a900460ff1660048111156126a857fe5b8867ffffffffffffffff168a60ff167f803c5a12f6bde629cea32e63d4b92d1b560816a6fb72e939d3c89e1cab650417856000015486600101546040516126f0929190613e01565b60405180910390a4505050505050505050565b6127176000801b61271261227b565b6117b1565b612756576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161274d9061417b565b60405180910390fd5b565b612760611eb2565b60016000806101000a81548160ff0219169083151502179055507f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258336040516127a99190613d0b565b60405180910390a1565b60006127c28360000183612958565b60001c905092915050565b60006127db826000016129c5565b9050919050565b6127ea6129d6565b60008060006101000a81548160ff0219169083151502179055507f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa336040516128339190613d0b565b60405180910390a1565b600061284983836128ad565b6128a25782600001829080600181540180825580915050600190039060005260206000200160009091909190915055826000018054905083600101600084815260200190815260200160002081905550600190506128a7565b600090505b92915050565b600080836001016000848152602001908152602001600020541415905092915050565b600082821115612915576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161290c9061407b565b60405180910390fd5b818303905092915050565b600033905090565b6000612950836000018373ffffffffffffffffffffffffffffffffffffffff1660001b612a25565b905092915050565b6000818360000180549050116129a3576040517f08c379a000000000000000000000000000000000000000000000000000000000815260040161299a90613f5b565b60405180910390fd5b8260000182815481106129b257fe5b9060005260206000200154905092915050565b600081600001805490509050919050565b60008054906101000a900460ff16612a23576040517f08c379a0000000000000000000000000000000000000000000000000000000008152600401612a1a90613fdb565b60405180910390fd5b565b60008083600101600084815260200190815260200160002054905060008114612b015760006001820390506000600186600001805490500390506000866000018281548110612a7057fe5b9060005260206000200154905080876000018481548110612a8d57fe5b9060005260206000200181905550600183018760010160008381526020019081526020016000208190555086600001805480612ac557fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050612b07565b60009150505b92915050565b828054828255906000526020600020908101928215612b86579160200282015b82811115612b855782518260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffffffffffff16021790555091602001919060010190612b2d565b5b509050612b939190612c5e565b5090565b6040518060c001604052806000801916815260200160008019168152602001606081526020016060815260200160006004811115612bd157fe5b8152602001600081525090565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f10612c1f57805160ff1916838001178555612c4d565b82800160010185558215612c4d579182015b82811115612c4c578251825591602001919060010190612c31565b5b509050612c5a9190612c99565b5090565b5b80821115612c9557600081816101000a81549073ffffffffffffffffffffffffffffffffffffffff021916905550600101612c5f565b5090565b5b80821115612cb2576000816000905550600101612c9a565b5090565b600081359050612cc5816144a2565b92915050565b600081359050612cda816144b9565b92915050565b60008083601f840112612cf257600080fd5b8235905067ffffffffffffffff811115612d0b57600080fd5b602083019150836020820283011115612d2357600080fd5b9250929050565b60008083601f840112612d3c57600080fd5b8235905067ffffffffffffffff811115612d5557600080fd5b602083019150836020820283011115612d6d57600080fd5b9250929050565b600081359050612d83816144d0565b92915050565b600081359050612d98816144e7565b92915050565b60008083601f840112612db057600080fd5b8235905067ffffffffffffffff811115612dc957600080fd5b602083019150836001820283011115612de157600080fd5b9250929050565b600081359050612df7816144fe565b92915050565b600081359050612e0c81614515565b92915050565b600081359050612e218161452c565b92915050565b600081359050612e3681614543565b92915050565b600060208284031215612e4e57600080fd5b6000612e5c84828501612cb6565b91505092915050565b600060208284031215612e7757600080fd5b6000612e8584828501612ccb565b91505092915050565b60008060408385031215612ea157600080fd5b6000612eaf85828601612cb6565b9250506020612ec085828601612cb6565b9150509250929050565b60008060008060808587031215612ee057600080fd5b6000612eee87828801612cb6565b9450506020612eff87828801612cb6565b9350506040612f1087828801612cb6565b9250506060612f2187828801612de8565b91505092959194509250565b600080600060608486031215612f4257600080fd5b6000612f5086828701612cb6565b9350506020612f6186828701612d74565b9250506040612f7286828701612cb6565b9150509250925092565b600080600080600060a08688031215612f9457600080fd5b6000612fa288828901612cb6565b9550506020612fb388828901612d74565b9450506040612fc488828901612cb6565b9350506060612fd588828901612d89565b9250506080612fe688828901612d89565b9150509295509295909350565b6000806000806040858703121561300957600080fd5b600085013567ffffffffffffffff81111561302357600080fd5b61302f87828801612ce0565b9450945050602085013567ffffffffffffffff81111561304e57600080fd5b61305a87828801612d2a565b925092505092959194509250565b60006020828403121561307a57600080fd5b600061308884828501612d74565b91505092915050565b600080604083850312156130a457600080fd5b60006130b285828601612d74565b92505060206130c385828601612cb6565b9150509250929050565b600080604083850312156130e057600080fd5b60006130ee85828601612d74565b92505060206130ff85828601612de8565b9150509250929050565b60006020828403121561311b57600080fd5b600061312984828501612de8565b91505092915050565b6000806040838503121561314557600080fd5b600061315385828601612dfd565b925050602061316485828601612e27565b9150509250929050565b6000806040838503121561318157600080fd5b600061318f85828601612e12565b92505060206131a085828601612d74565b9150509250929050565b6000806000606084860312156131bf57600080fd5b60006131cd86828701612e12565b93505060206131de86828701612d74565b92505060406131ef86828701612cb6565b9150509250925092565b60006020828403121561320b57600080fd5b600061321984828501612e27565b91505092915050565b6000806000806060858703121561323857600080fd5b600061324687828801612e27565b945050602061325787828801612d74565b935050604085013567ffffffffffffffff81111561327457600080fd5b61328087828801612d9e565b925092505092959194509250565b6000806000606084860312156132a357600080fd5b60006132b186828701612e27565b93505060206132c286828701612dfd565b92505060406132d386828701612d74565b9150509250925092565b600080600080608085870312156132f357600080fd5b600061330187828801612e27565b945050602061331287828801612dfd565b935050604061332387828801612d74565b925050606061333487828801612d74565b91505092959194509250565b60008060008060006080868803121561335857600080fd5b600061336688828901612e27565b955050602061337788828901612dfd565b945050604086013567ffffffffffffffff81111561339457600080fd5b6133a088828901612d9e565b935093505060606133b388828901612d74565b9150509295509295909350565b60006133cc83836133e7565b60208301905092915050565b6133e1816143d8565b82525050565b6133f0816142ff565b82525050565b6133ff816142ff565b82525050565b613416613411826142ff565b614453565b82525050565b60006134278261429e565b61343181856142c1565b935061343c8361428e565b8060005b8381101561346d57815161345488826133c0565b975061345f836142b4565b925050600181019050613440565b5085935050505092915050565b61348381614323565b82525050565b6134928161432f565b82525050565b6134a18161432f565b82525050565b6134b081614339565b82525050565b60006134c1826142a9565b6134cb81856142d2565b93506134db818560208601614420565b6134e481614477565b840191505092915050565b60006134fa826142a9565b61350481856142e3565b9350613514818560208601614420565b80840191505092915050565b613529816143ea565b82525050565b613538816143ea565b82525050565b600061354b601c836142ee565b91507f70726f706f73616c20616c7265616479207472616e73666572726564000000006000830152602082019050919050565b600061358b6016836142ee565b91507f70726f706f73616c206973206e6f7420616374697665000000000000000000006000830152602082019050919050565b60006135cb6022836142ee565b91507f456e756d657261626c655365743a20696e646578206f7574206f6620626f756e60008301527f64730000000000000000000000000000000000000000000000000000000000006020830152604082019050919050565b6000613631601e836142ee565b91507f73656e646572206973206e6f742072656c61796572206f722061646d696e00006000830152602082019050919050565b6000613671602f836142ee565b91507f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60008301527f2061646d696e20746f206772616e7400000000000000000000000000000000006020830152604082019050919050565b60006136d76015836142ee565b91507f72656c6179657220616c726561647920766f74656400000000000000000000006000830152602082019050919050565b60006137176014836142ee565b91507f5061757361626c653a206e6f74207061757365640000000000000000000000006000830152602082019050919050565b6000613757601f836142ee565b91507f6164647220646f65736e277420686176652072656c6179657220726f6c6521006000830152602082019050919050565b60006137976016836142ee565b91507f496e636f72726563742066656520737570706c696564000000000000000000006000830152602082019050919050565b60006137d7601b836142ee565b91507f6461746120646f65736e2774206d6174636820646174616861736800000000006000830152602082019050919050565b6000613817601a836142ee565b91507f50726f706f73616c20616c72656164792063616e63656c6c65640000000000006000830152602082019050919050565b6000613857601e836142ee565b91507f536166654d6174683a207375627472616374696f6e206f766572666c6f7700006000830152602082019050919050565b60006138976020836142ee565b91507f7265736f757263654944206e6f74206d617070656420746f2068616e646c65726000830152602082019050919050565b60006138d76030836142ee565b91507f416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e60008301527f2061646d696e20746f207265766f6b65000000000000000000000000000000006020830152604082019050919050565b600061393d6020836142ee565b91507f50726f706f73616c206e6f7420617420657870697279207468726573686f6c646000830152602082019050919050565b600061397d6010836142ee565b91507f5061757361626c653a20706175736564000000000000000000000000000000006000830152602082019050919050565b60006139bd601e836142ee565b91507f6164647220616c7265616479206861732072656c6179657220726f6c652100006000830152602082019050919050565b60006139fd602a836142ee565b91507f70726f706f73616c20616c7265616479207061737365642f657865637574656460008301527f2f63616e63656c6c6564000000000000000000000000000000000000000000006020830152604082019050919050565b6000613a636020836142ee565b91507f73656e64657220646f65736e277420686176652072656c6179657220726f6c656000830152602082019050919050565b6000613aa3601e836142ee565b91507f73656e64657220646f65736e277420686176652061646d696e20726f6c6500006000830152602082019050919050565b6000613ae3601f836142ee565b91507f43757272656e742066656520697320657175616c20746f206e657720666565006000830152602082019050919050565b6000613b236011836142ee565b91507f6461746168617368206d69736d617463680000000000000000000000000000006000830152602082019050919050565b6000613b636019836142ee565b91507f6e6f2068616e646c657220666f72207265736f757263654944000000000000006000830152602082019050919050565b6000613ba3602f836142ee565b91507f416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636560008301527f20726f6c657320666f722073656c6600000000000000000000000000000000006020830152604082019050919050565b600060c083016000830151613c146000860182613489565b506020830151613c276020860182613489565b5060408301518482036040860152613c3f828261341c565b91505060608301518482036060860152613c59828261341c565b9150506080830151613c6e6080860182613520565b5060a0830151613c8160a0860182613c8c565b508091505092915050565b613c9581614398565b82525050565b613ca481614398565b82525050565b613cb3816143a2565b82525050565b613cc2816143cb565b82525050565b6000613cd48285613405565b601482019150613ce482846134ef565b91508190509392505050565b6000602082019050613d0560008301846133f6565b92915050565b6000602082019050613d2060008301846133d8565b92915050565b6000606082019050613d3b60008301866133f6565b613d4860208301856133f6565b613d556040830184613c9b565b949350505050565b6000602082019050613d72600083018461347a565b92915050565b6000602082019050613d8d6000830184613498565b92915050565b6000604082019050613da86000830185613498565b613db560208301846133f6565b9392505050565b6000608082019050613dd16000830187613498565b613dde60208301866133f6565b613deb60408301856134a7565b613df860608301846134a7565b95945050505050565b6000604082019050613e166000830185613498565b613e236020830184613498565b9392505050565b6000608082019050613e3f6000830187613498565b613e4c6020830186613498565b613e59604083018561352f565b613e666060830184613c9b565b95945050505050565b6000604082019050613e846000830185613498565b8181036020830152613e9681846134b6565b90509392505050565b600060a082019050613eb46000830188613498565b613ec16020830187613cb9565b613ece6040830186613caa565b613edb60608301856133d8565b8181036080830152613eed81846134b6565b90509695505050505050565b60006020820190508181036000830152613f1381846134b6565b905092915050565b60006020820190508181036000830152613f348161353e565b9050919050565b60006020820190508181036000830152613f548161357e565b9050919050565b60006020820190508181036000830152613f74816135be565b9050919050565b60006020820190508181036000830152613f9481613624565b9050919050565b60006020820190508181036000830152613fb481613664565b9050919050565b60006020820190508181036000830152613fd4816136ca565b9050919050565b60006020820190508181036000830152613ff48161370a565b9050919050565b600060208201905081810360008301526140148161374a565b9050919050565b600060208201905081810360008301526140348161378a565b9050919050565b60006020820190508181036000830152614054816137ca565b9050919050565b600060208201905081810360008301526140748161380a565b9050919050565b600060208201905081810360008301526140948161384a565b9050919050565b600060208201905081810360008301526140b48161388a565b9050919050565b600060208201905081810360008301526140d4816138ca565b9050919050565b600060208201905081810360008301526140f481613930565b9050919050565b6000602082019050818103600083015261411481613970565b9050919050565b60006020820190508181036000830152614134816139b0565b9050919050565b60006020820190508181036000830152614154816139f0565b9050919050565b6000602082019050818103600083015261417481613a56565b9050919050565b6000602082019050818103600083015261419481613a96565b9050919050565b600060208201905081810360008301526141b481613ad6565b9050919050565b600060208201905081810360008301526141d481613b16565b9050919050565b600060208201905081810360008301526141f481613b56565b9050919050565b6000602082019050818103600083015261421481613b96565b9050919050565b600060208201905081810360008301526142358184613bfc565b905092915050565b60006020820190506142526000830184613c9b565b92915050565b600060208201905061426d6000830184613caa565b92915050565b60006020820190506142886000830184613cb9565b92915050565b6000819050602082019050919050565b600081519050919050565b600081519050919050565b6000602082019050919050565b600082825260208201905092915050565b600082825260208201905092915050565b600081905092915050565b600082825260208201905092915050565b600061430a82614378565b9050919050565b600061431c82614378565b9050919050565b60008115159050919050565b6000819050919050565b60007fffffffff0000000000000000000000000000000000000000000000000000000082169050919050565b600081905061437382614495565b919050565b600073ffffffffffffffffffffffffffffffffffffffff82169050919050565b6000819050919050565b600067ffffffffffffffff82169050919050565b600068ffffffffffffffffff82169050919050565b600060ff82169050919050565b60006143e3826143fc565b9050919050565b60006143f582614365565b9050919050565b60006144078261440e565b9050919050565b600061441982614378565b9050919050565b60005b8381101561443e578082015181840152602081019050614423565b8381111561444d576000848401525b50505050565b600061445e82614465565b9050919050565b600061447082614488565b9050919050565b6000601f19601f8301169050919050565b60008160601b9050919050565b6005811061449f57fe5b50565b6144ab816142ff565b81146144b657600080fd5b50565b6144c281614311565b81146144cd57600080fd5b50565b6144d98161432f565b81146144e457600080fd5b50565b6144f081614339565b81146144fb57600080fd5b50565b61450781614398565b811461451257600080fd5b50565b61451e816143a2565b811461452957600080fd5b50565b614535816143b6565b811461454057600080fd5b50565b61454c816143cb565b811461455757600080fd5b5056fea2646970667358221220b2ee33b54169ab2e626549437bb013b638aa343b10d670dd9c631c4b9555d07664736f6c634300060c0033
Verified Source Code Partial Match
Compiler: v0.6.12+commit.27d51765
EVM: istanbul
Optimization: No
Bridge.sol 446 lines
// This code was taken from the chainbridge-solidity project listed below,
// licensed under GPL v3. We've made slight modifications, branched from
// the v1.0.0 tag.
//
// https://github.com/ChainSafe/chainbridge-solidity.git
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
import "./utils/AccessControl.sol";
import "./utils/SafeMathBase.sol";
import "./utils/Pausable.sol";
import "./utils/ERC2771Context.sol";
import "./interfaces/IDepositExecute.sol";
import "./interfaces/IBridge.sol";
import "./interfaces/IERCHandler.sol";
import "./interfaces/IGenericHandler.sol";
/**
@title Facilitates deposits, creation and votiing of deposit proposals, and deposit executions.
@author ChainSafe Systems.
*/
contract Bridge is Pausable, AccessControl, SafeMathBase, ERC2771Context {
uint8 public _chainID;
uint256 public _relayerThreshold;
uint256 public _totalRelayers;
uint256 public _totalProposals;
uint256 public _fee;
uint256 public _expiry;
enum Vote {No, Yes}
enum ProposalStatus {Inactive, Active, Passed, Executed, Cancelled}
struct Proposal {
bytes32 _resourceID;
bytes32 _dataHash;
address[] _yesVotes;
address[] _noVotes;
ProposalStatus _status;
uint256 _proposedBlock;
}
// destinationChainID => number of deposits
mapping(uint8 => uint64) public _depositCounts;
// resourceID => handler address
mapping(bytes32 => address) public _resourceIDToHandlerAddress;
// depositNonce => destinationChainID => bytes
mapping(uint64 => mapping(uint8 => bytes)) public _depositRecords;
// destinationChainID + depositNonce => dataHash => Proposal
mapping(uint72 => mapping(bytes32 => Proposal)) public _proposals;
// destinationChainID + depositNonce => dataHash => relayerAddress => bool
mapping(uint72 => mapping(bytes32 => mapping(address => bool))) public _hasVotedOnProposal;
event RelayerThresholdChanged(uint indexed newThreshold);
event RelayerAdded(address indexed relayer);
event RelayerRemoved(address indexed relayer);
event Deposit(
uint8 indexed destinationChainID,
bytes32 indexed resourceID,
uint64 indexed depositNonce
);
event ProposalEvent(
uint8 indexed originChainID,
uint64 indexed depositNonce,
ProposalStatus indexed status,
bytes32 resourceID,
bytes32 dataHash
);
event ProposalVote(
uint8 indexed originChainID,
uint64 indexed depositNonce,
ProposalStatus indexed status,
bytes32 resourceID
);
bytes32 public constant RELAYER_ROLE = keccak256("RELAYER_ROLE");
modifier onlyAdmin() {
_onlyAdmin();
_;
}
modifier onlyAdminOrRelayer() {
_onlyAdminOrRelayer();
_;
}
modifier onlyRelayers() {
_onlyRelayers();
_;
}
function _onlyAdminOrRelayer() private {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()) || hasRole(RELAYER_ROLE, _msgSender()),
"sender is not relayer or admin");
}
function _onlyAdmin() private {
require(hasRole(DEFAULT_ADMIN_ROLE, _msgSender()), "sender doesn't have admin role");
}
function _onlyRelayers() private {
require(hasRole(RELAYER_ROLE, _msgSender()), "sender doesn't have relayer role");
}
/**
@notice Initializes Bridge, creates and grants {msg.sender} the admin role,
creates and grants {initialRelayers} the relayer role.
@param chainID ID of chain the Bridge contract exists on.
@param initialRelayers Addresses that should be initially granted the relayer role.
@param initialRelayerThreshold Number of votes needed for a deposit proposal to be considered passed.
*/
constructor (
uint8 chainID,
address[] memory initialRelayers,
uint initialRelayerThreshold,
uint256 fee,
uint256 expiry,
address forwarder
) ERC2771Context(forwarder) public {
_chainID = chainID;
_relayerThreshold = initialRelayerThreshold;
_fee = fee;
_expiry = expiry;
_setupRole(DEFAULT_ADMIN_ROLE, msg.sender);
_setRoleAdmin(RELAYER_ROLE, DEFAULT_ADMIN_ROLE);
for (uint i; i < initialRelayers.length; i++) {
grantRole(RELAYER_ROLE, initialRelayers[i]);
_totalRelayers++;
}
}
/**
@notice Returns true if {relayer} has the relayer role.
@param relayer Address to check.
*/
function isRelayer(address relayer) external view returns (bool) {
return hasRole(RELAYER_ROLE, relayer);
}
/**
@notice Removes admin role from {_msgSender()} and grants it to {newAdmin}.
@notice Only callable by an address that currently has the admin role.
@param newAdmin Address that admin role will be granted to.
*/
function renounceAdmin(address newAdmin) external onlyAdmin {
grantRole(DEFAULT_ADMIN_ROLE, newAdmin);
renounceRole(DEFAULT_ADMIN_ROLE, _msgSender());
}
/**
@notice Pauses deposits, proposal creation and voting, and deposit executions.
@notice Only callable by an address that currently has the admin role.
*/
function adminPauseTransfers() external onlyAdmin {
_pause();
}
/**
@notice Unpauses deposits, proposal creation and voting, and deposit executions.
@notice Only callable by an address that currently has the admin role.
*/
function adminUnpauseTransfers() external onlyAdmin {
_unpause();
}
/**
@notice Modifies the number of votes required for a proposal to be considered passed.
@notice Only callable by an address that currently has the admin role.
@param newThreshold Value {_relayerThreshold} will be changed to.
@notice Emits {RelayerThresholdChanged} event.
*/
function adminChangeRelayerThreshold(uint newThreshold) external onlyAdmin {
_relayerThreshold = newThreshold;
emit RelayerThresholdChanged(newThreshold);
}
/**
@notice Grants {relayerAddress} the relayer role and increases {_totalRelayer} count.
@notice Only callable by an address that currently has the admin role.
@param relayerAddress Address of relayer to be added.
@notice Emits {RelayerAdded} event.
*/
function adminAddRelayer(address relayerAddress) external onlyAdmin {
require(!hasRole(RELAYER_ROLE, relayerAddress), "addr already has relayer role!");
grantRole(RELAYER_ROLE, relayerAddress);
emit RelayerAdded(relayerAddress);
_totalRelayers++;
}
/**
@notice Removes relayer role for {relayerAddress} and decreases {_totalRelayer} count.
@notice Only callable by an address that currently has the admin role.
@param relayerAddress Address of relayer to be removed.
@notice Emits {RelayerRemoved} event.
*/
function adminRemoveRelayer(address relayerAddress) external onlyAdmin {
require(hasRole(RELAYER_ROLE, relayerAddress), "addr doesn't have relayer role!");
revokeRole(RELAYER_ROLE, relayerAddress);
emit RelayerRemoved(relayerAddress);
_totalRelayers--;
}
/**
@notice Sets a new resource for handler contracts that use the IERCHandler interface,
and maps the {handlerAddress} to {resourceID} in {_resourceIDToHandlerAddress}.
@notice Only callable by an address that currently has the admin role.
@param handlerAddress Address of handler resource will be set for.
@param resourceID ResourceID to be used when making deposits.
@param tokenAddress Address of contract to be called when a deposit is made and a deposited is executed.
*/
function adminSetResource(address handlerAddress, bytes32 resourceID, address tokenAddress) external onlyAdmin {
_resourceIDToHandlerAddress[resourceID] = handlerAddress;
IERCHandler handler = IERCHandler(handlerAddress);
handler.setResource(resourceID, tokenAddress);
}
/**
@notice Sets a new resource for handler contracts that use the IGenericHandler interface,
and maps the {handlerAddress} to {resourceID} in {_resourceIDToHandlerAddress}.
@notice Only callable by an address that currently has the admin role.
@param handlerAddress Address of handler resource will be set for.
@param resourceID ResourceID to be used when making deposits.
@param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
*/
function adminSetGenericResource(
address handlerAddress,
bytes32 resourceID,
address contractAddress,
bytes4 depositFunctionSig,
bytes4 executeFunctionSig
) external onlyAdmin {
_resourceIDToHandlerAddress[resourceID] = handlerAddress;
IGenericHandler handler = IGenericHandler(handlerAddress);
handler.setResource(resourceID, contractAddress, depositFunctionSig, executeFunctionSig);
}
/**
@notice Sets a resource as burnable for handler contracts that use the IERCHandler interface.
@notice Only callable by an address that currently has the admin role.
@param handlerAddress Address of handler resource will be set for.
@param tokenAddress Address of contract to be called when a deposit is made and a deposited is executed.
*/
function adminSetBurnable(address handlerAddress, address tokenAddress) external onlyAdmin {
IERCHandler handler = IERCHandler(handlerAddress);
handler.setBurnable(tokenAddress);
}
/**
@notice Returns a proposal.
@param originChainID Chain ID deposit originated from.
@param depositNonce ID of proposal generated by proposal's origin Bridge contract.
@param dataHash Hash of data to be provided when deposit proposal is executed.
@return Proposal which consists of:
- _dataHash Hash of data to be provided when deposit proposal is executed.
- _yesVotes Number of votes in favor of proposal.
- _noVotes Number of votes against proposal.
- _status Current status of proposal.
*/
function getProposal(uint8 originChainID, uint64 depositNonce, bytes32 dataHash) external view returns (Proposal memory) {
uint72 nonceAndID = (uint72(depositNonce) << 8) | uint72(originChainID);
return _proposals[nonceAndID][dataHash];
}
/**
@notice Changes deposit fee.
@notice Only callable by admin.
@param newFee Value {_fee} will be updated to.
*/
function adminChangeFee(uint newFee) external onlyAdmin {
require(_fee != newFee, "Current fee is equal to new fee");
_fee = newFee;
}
/**
@notice Used to manually withdraw funds from ERC safes.
@param handlerAddress Address of handler to withdraw from.
@param tokenAddress Address of token to withdraw.
@param recipient Address to withdraw tokens to.
@param amountOrTokenID Either the amount of ERC20 tokens or the ERC721 token ID to withdraw.
*/
function adminWithdraw(
address handlerAddress,
address tokenAddress,
address recipient,
uint256 amountOrTokenID
) external onlyAdmin {
IERCHandler handler = IERCHandler(handlerAddress);
handler.withdraw(tokenAddress, recipient, amountOrTokenID);
}
/**
@notice Initiates a transfer using a specified handler contract.
@notice Only callable when Bridge is not paused.
@param destinationChainID ID of chain deposit will be bridged to.
@param resourceID ResourceID used to find address of handler to be used for deposit.
@param data Additional data to be passed to specified handler.
@notice Emits {Deposit} event.
*/
function _deposit(uint8 destinationChainID, bytes32 resourceID, bytes memory data) internal whenNotPaused {
require(msg.value == _fee, "Incorrect fee supplied");
address handler = _resourceIDToHandlerAddress[resourceID];
require(handler != address(0), "resourceID not mapped to handler");
uint64 depositNonce = ++_depositCounts[destinationChainID];
_depositRecords[depositNonce][destinationChainID] = data;
IDepositExecute depositHandler = IDepositExecute(handler);
depositHandler.deposit(resourceID, destinationChainID, depositNonce, _msgSender(), data);
emit Deposit(destinationChainID, resourceID, depositNonce);
}
/**
@notice When called, {_msgSender()} will be marked as voting in favor of proposal.
@notice Only callable by relayers when Bridge is not paused.
@param chainID ID of chain deposit originated from.
@param depositNonce ID of deposited generated by origin Bridge contract.
@param dataHash Hash of data provided when deposit was made.
@notice Proposal must not have already been passed or executed.
@notice {_msgSender()} must not have already voted on proposal.
@notice Emits {ProposalEvent} event with status indicating the proposal status.
@notice Emits {ProposalVote} event.
*/
function voteProposal(uint8 chainID, uint64 depositNonce, bytes32 resourceID, bytes32 dataHash) external onlyRelayers whenNotPaused {
uint72 nonceAndID = (uint72(depositNonce) << 8) | uint72(chainID);
Proposal storage proposal = _proposals[nonceAndID][dataHash];
address msgSender = _msgSender();
require(_resourceIDToHandlerAddress[resourceID] != address(0), "no handler for resourceID");
require(uint(proposal._status) <= 1, "proposal already passed/executed/cancelled");
require(!_hasVotedOnProposal[nonceAndID][dataHash][msgSender], "relayer already voted");
if (uint(proposal._status) == 0) {
++_totalProposals;
_proposals[nonceAndID][dataHash] = Proposal({
_resourceID : resourceID,
_dataHash : dataHash,
_yesVotes : new address[](1),
_noVotes : new address[](0),
_status : ProposalStatus.Active,
_proposedBlock : block.number
});
proposal._yesVotes[0] = msgSender;
emit ProposalEvent(chainID, depositNonce, ProposalStatus.Active, resourceID, dataHash);
} else {
if (sub(block.number, proposal._proposedBlock) > _expiry) {
// if the number of blocks that has passed since this proposal was
// submitted exceeds the expiry threshold set, cancel the proposal
proposal._status = ProposalStatus.Cancelled;
emit ProposalEvent(chainID, depositNonce, ProposalStatus.Cancelled, resourceID, dataHash);
} else {
require(dataHash == proposal._dataHash, "datahash mismatch");
proposal._yesVotes.push(msgSender);
}
}
if (proposal._status != ProposalStatus.Cancelled) {
_hasVotedOnProposal[nonceAndID][dataHash][msgSender] = true;
emit ProposalVote(chainID, depositNonce, proposal._status, resourceID);
// If _depositThreshold is set to 1, then auto finalize
// or if _relayerThreshold has been exceeded
if (_relayerThreshold <= 1 || proposal._yesVotes.length >= _relayerThreshold) {
proposal._status = ProposalStatus.Passed;
emit ProposalEvent(chainID, depositNonce, ProposalStatus.Passed, resourceID, dataHash);
}
}
}
/**
@notice Executes a deposit proposal that is considered passed using a specified handler contract.
@notice Only callable by relayers when Bridge is not paused.
@param chainID ID of chain deposit originated from.
@param depositNonce ID of deposited generated by origin Bridge contract.
@param dataHash Hash of data originally provided when deposit was made.
@notice Proposal must be past expiry threshold.
@notice Emits {ProposalEvent} event with status {Cancelled}.
*/
function cancelProposal(uint8 chainID, uint64 depositNonce, bytes32 dataHash) public onlyAdminOrRelayer {
uint72 nonceAndID = (uint72(depositNonce) << 8) | uint72(chainID);
Proposal storage proposal = _proposals[nonceAndID][dataHash];
require(proposal._status != ProposalStatus.Cancelled, "Proposal already cancelled");
require(sub(block.number, proposal._proposedBlock) > _expiry, "Proposal not at expiry threshold");
proposal._status = ProposalStatus.Cancelled;
emit ProposalEvent(chainID, depositNonce, ProposalStatus.Cancelled, proposal._resourceID, proposal._dataHash);
}
/**
@notice Executes a deposit proposal that is considered passed using a specified handler contract.
@notice Only callable by relayers when Bridge is not paused.
@param chainID ID of chain deposit originated from.
@param resourceID ResourceID to be used when making deposits.
@param depositNonce ID of deposited generated by origin Bridge contract.
@param data Data originally provided when deposit was made.
@notice Proposal must have Passed status.
@notice Hash of {data} must equal proposal's {dataHash}.
@notice Emits {ProposalEvent} event with status {Executed}.
*/
function _executeProposal(uint8 chainID, uint64 depositNonce, bytes memory data, bytes32 resourceID) internal onlyRelayers whenNotPaused {
address handler = _resourceIDToHandlerAddress[resourceID];
uint72 nonceAndID = (uint72(depositNonce) << 8) | uint72(chainID);
bytes32 dataHash = keccak256(abi.encodePacked(handler, data));
Proposal storage proposal = _proposals[nonceAndID][dataHash];
require(proposal._status != ProposalStatus.Inactive, "proposal is not active");
require(proposal._status == ProposalStatus.Passed, "proposal already transferred");
require(dataHash == proposal._dataHash, "data doesn't match datahash");
proposal._status = ProposalStatus.Executed;
IDepositExecute depositHandler = IDepositExecute(_resourceIDToHandlerAddress[proposal._resourceID]);
depositHandler.executeProposal(proposal._resourceID, data);
emit ProposalEvent(chainID, depositNonce, proposal._status, proposal._resourceID, proposal._dataHash);
}
/**
@notice Transfers eth in the contract to the specified addresses. The parameters addrs and amounts are mapped 1-1.
This means that the address at index 0 for addrs will receive the amount (in WEI) from amounts at index 0.
@param addrs Array of addresses to transfer {amounts} to.
@param amounts Array of amonuts to transfer to {addrs}.
*/
function transferFunds(address payable[] calldata addrs, uint[] calldata amounts) external onlyAdmin {
for (uint i = 0; i < addrs.length; i++) {
addrs[i].transfer(amounts[i]);
}
}
}
MainnetBridge.sol 21 lines
pragma solidity 0.6.12;
pragma experimental ABIEncoderV2;
import "./Bridge.sol";
contract MainnetBridge is Bridge {
// The mainnet bridge isn't altered at all.
// However we need to call the _deposit and _executeProposal functions
// that have been made internal.
constructor (uint8 chainID, address[] memory initialRelayers, uint initialRelayerThreshold, uint256 fee, uint256 expiry, address forwarder) Bridge(chainID, initialRelayers, initialRelayerThreshold, fee, expiry, forwarder) public {}
function deposit(uint8 destinationChainID, bytes32 resourceID, bytes calldata data) external whenNotPaused {
_deposit(destinationChainID, resourceID, data);
}
function executeProposal(uint8 chainID, uint64 depositNonce, bytes calldata data, bytes32 resourceID) external onlyRelayers whenNotPaused {
_executeProposal(chainID, depositNonce, data, resourceID);
}
}
Pausable.sol 96 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This is a stripped down version of Open zeppelin's Pausable contract.
* https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/EnumerableSet.sol
*
*/
contract Pausable {
/**
* @dev Emitted when the pause is triggered by `account`.
*/
event Paused(address account);
/**
* @dev Emitted when the pause is lifted by `account`.
*/
event Unpaused(address account);
bool private _paused;
/**
* @dev Initializes the contract in unpaused state.
*/
constructor () internal {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view returns (bool) {
return _paused;
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenNotPaused() {
_whenNotPaused();
_;
}
function _whenNotPaused() private view {
require(!_paused, "Pausable: paused");
}
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*
* Requirements:
*
* - The contract must not be paused.
*/
modifier whenPaused() {
_whenPaused();
_;
}
function _whenPaused() private view {
require(_paused, "Pausable: not paused");
}
/**
* @dev Triggers stopped state.
*
* Requirements:
*
* - The contract must not be paused.
*/
function _pause() internal virtual whenNotPaused {
_paused = true;
emit Paused(msg.sender);
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(msg.sender);
}
}
IBridge.sol 19 lines
// This code was taken from the chainbridge-solidity project listed below,
// licensed under GPL v3. We've made slight modifications, branched from
// the v1.0.0 tag.
//
// https://github.com/ChainSafe/chainbridge-solidity.git
pragma solidity ^0.6.0;
/**
@title Interface for Bridge contract.
@author ChainSafe Systems.
*/
interface IBridge {
/**
@notice Exposing getter for {_chainID} instead of forcing the use of call.
@return uint8 The {_chainID} that is currently set for the Bridge contract.
*/
function _chainID() external returns (uint8);
}
SafeMathBase.sol 38 lines
// SPDX-License-Identifier: MIT
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/math/SafeMath.sol";
////
// NOTE: This has been edited to use OZ's SafeMath while
// preserving the ability to inherit from it.
// This is a shim to keep most of Chainbridge's code intact.
////
import "@openzeppelin/contracts/math/SafeMath.sol";
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* note that this is a stripped down version of open zeppelin's safemath
* https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/SafeMath.sol
*/
contract SafeMathBase {
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
return SafeMath.sub(a, b);
}
}
AccessControl.sol 214 lines
// This code was taken from the chainbridge-solidity project listed below,
// licensed under MIT. Branched from the v3.0.1 tag.
// We've replaced use of msgSender with msg.sender everywhere. We need to do this because we use access control in the
// constructor of Bridge.sol but _msgSender() cannot be called from a constructor as it accesses `immutable` vars.
// https://forum.openzeppelin.com/t/erc2771context-typeerror-immutable-variables-cannot-be-read-during-contract-creation-time/8513
// Also removed inheritance of Context.sol since we dont need it now.
// Note that since we've replaced _msgSender with msg.sender in here care should
// be take when using a Forwarder contract to call functions in this method. In this
// case the msg.sender will be the Forwarder contract instead of the admin.
//
// https://github.com/OpenZeppelin/openzeppelin-contracts/
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/utils/EnumerableSet.sol";
import "@openzeppelin/contracts/utils/Address.sol";
/**
* @dev Contract module that allows children to implement role-based access
* control mechanisms.
*
* 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 {
using EnumerableSet for EnumerableSet.AddressSet;
using Address for address;
struct RoleData {
EnumerableSet.AddressSet members;
bytes32 adminRole;
}
mapping (bytes32 => RoleData) private _roles;
bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;
/**
* @dev Emitted when `account` is granted `role`.
*
* `sender` is the account that originated the contract call, an admin role
* bearer except when using {_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) public view returns (bool) {
return _roles[role].members.contains(account);
}
/**
* @dev Returns the number of accounts that have `role`. Can be used
* together with {getRoleMember} to enumerate all bearers of a role.
*/
function getRoleMemberCount(bytes32 role) public view returns (uint256) {
return _roles[role].members.length();
}
/**
* @dev Returns one of the accounts that have `role`. `index` must be a
* value between 0 and {getRoleMemberCount}, non-inclusive.
*
* Role bearers are not sorted in any particular way, and their ordering may
* change at any point.
*
* WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
* you perform all queries on the same block. See the following
* https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
* for more information.
*/
function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
return _roles[role].members.at(index);
}
/**
* @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 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 {
require(hasRole(_roles[role].adminRole, msg.sender), "AccessControl: sender must be an admin to grant");
_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 {
require(hasRole(_roles[role].adminRole, msg.sender), "AccessControl: sender must be an admin to revoke");
_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 granted `role`, emits a {RoleRevoked}
* event.
*
* Requirements:
*
* - the caller must be `account`.
*/
function renounceRole(bytes32 role, address account) public virtual {
require(account == msg.sender, "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}.
* ====
*/
function _setupRole(bytes32 role, address account) internal virtual {
_grantRole(role, account);
}
/**
* @dev Sets `adminRole` as ``role``'s admin role.
*/
function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
_roles[role].adminRole = adminRole;
}
function _grantRole(bytes32 role, address account) private {
if (_roles[role].members.add(account)) {
emit RoleGranted(role, account, msg.sender);
}
}
function _revokeRole(bytes32 role, address account) private {
if (_roles[role].members.remove(account)) {
emit RoleRevoked(role, account, msg.sender);
}
}
}
ERC2771Context.sol 41 lines
// This code was taken from the chainbridge-solidity project listed below,
// licensed under MIT. Slight modifications (downgraded to 0.6.0), branched from
// the v4.0.1 tag.
//
// https://github.com/OpenZeppelin/openzeppelin-contracts/
pragma solidity ^0.6.0;
import "@openzeppelin/contracts/utils/Context.sol";
/*
* @dev Context variant with ERC2771 support.
*/
contract ERC2771Context is Context {
address immutable _trustedForwarder;
constructor(address trustedForwarder) internal {
_trustedForwarder = trustedForwarder;
}
function isTrustedForwarder(address forwarder) public view virtual returns(bool) {
return forwarder == _trustedForwarder;
}
function _msgSender() internal view virtual override(Context) returns (address payable sender) {
if (isTrustedForwarder(msg.sender)) {
// The assembly code is more direct than the Solidity version using `abi.decode`.
assembly { sender := shr(96, calldataload(sub(calldatasize(), 20))) }
} else {
return super._msgSender();
}
}
function _msgData() internal view virtual override(Context) returns (bytes memory) {
if (isTrustedForwarder(msg.sender)) {
return bytes(msg.data[:msg.data.length-20]);
} else {
return super._msgData();
}
}
}
IERCHandler.sol 32 lines
// This code was taken from the chainbridge-solidity project listed below,
// licensed under GPL v3. We've made slight modifications, branched from
// the v1.0.0 tag.
//
// https://github.com/ChainSafe/chainbridge-solidity.git
pragma solidity ^0.6.0;
/**
@title Interface to be used with handlers that support ERC20s and ERC721s.
@author ChainSafe Systems.
*/
interface IERCHandler {
/**
@notice Correlates {resourceID} with {contractAddress}.
@param resourceID ResourceID to be used when making deposits.
@param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
*/
function setResource(bytes32 resourceID, address contractAddress) external;
/**
@notice Marks {contractAddress} as mintable/burnable.
@param contractAddress Address of contract to be used when making or executing deposits.
*/
function setBurnable(address contractAddress) external;
/**
@notice Used to manually release funds from ERC safes.
@param tokenAddress Address of token contract to release.
@param recipient Address to release tokens to.
@param amountOrTokenID Either the amount of ERC20 tokens or the ERC721 token ID to release.
*/
function withdraw(address tokenAddress, address recipient, uint256 amountOrTokenID) external;
}
IDepositExecute.sol 28 lines
// This code was taken from the chainbridge-solidity project listed below,
// licensed under GPL v3. We've made slight modifications, branched from
// the v1.0.0 tag.
//
// https://github.com/ChainSafe/chainbridge-solidity.git
pragma solidity ^0.6.0;
/**
@title Interface for handler contracts that support deposits and deposit executions.
@author ChainSafe Systems.
*/
interface IDepositExecute {
/**
@notice It is intended that deposit are made using the Bridge contract.
@param destinationChainID Chain ID deposit is expected to be bridged to.
@param depositNonce This value is generated as an ID by the Bridge contract.
@param depositer Address of account making the deposit in the Bridge contract.
@param data Consists of additional data needed for a specific deposit.
*/
function deposit(bytes32 resourceID, uint8 destinationChainID, uint64 depositNonce, address depositer, bytes calldata data) external;
/**
@notice It is intended that proposals are executed by the Bridge contract.
@param data Consists of additional data needed for a specific deposit execution.
*/
function executeProposal(bytes32 resourceID, bytes calldata data) external;
}
IGenericHandler.sol 22 lines
// This code was taken from the chainbridge-solidity project listed below,
// licensed under GPL v3. We've made slight modifications, branched from
// the v1.0.0 tag.
//
// https://github.com/ChainSafe/chainbridge-solidity.git
pragma solidity ^0.6.0;
/**
@title Interface for handler that handles generic deposits and deposit executions.
@author ChainSafe Systems.
*/
interface IGenericHandler {
/**
@notice Correlates {resourceID} with {contractAddress}, {depositFunctionSig}, and {executeFunctionSig}.
@param resourceID ResourceID to be used when making deposits.
@param contractAddress Address of contract to be called when a deposit is made and a deposited is executed.
@param depositFunctionSig Function signature of method to be called in {contractAddress} when a deposit is made.
@param executeFunctionSig Function signature of method to be called in {contractAddress} when a deposit is executed.
*/
function setResource(bytes32 resourceID, address contractAddress, bytes4 depositFunctionSig, bytes4 executeFunctionSig) external;
}
SafeMath.sol 214 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Wrappers over Solidity's arithmetic operations with added overflow
* checks.
*
* Arithmetic operations in Solidity wrap on overflow. This can easily result
* in bugs, because programmers usually assume that an overflow raises an
* error, which is the standard behavior in high level programming languages.
* `SafeMath` restores this intuition by reverting the transaction when an
* operation overflows.
*
* Using this library instead of the unchecked operations eliminates an entire
* class of bugs, so it's recommended to use it always.
*/
library SafeMath {
/**
* @dev Returns the addition of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryAdd(uint256 a, uint256 b) internal pure returns (bool, uint256) {
uint256 c = a + b;
if (c < a) return (false, 0);
return (true, c);
}
/**
* @dev Returns the substraction of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function trySub(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b > a) return (false, 0);
return (true, a - b);
}
/**
* @dev Returns the multiplication of two unsigned integers, with an overflow flag.
*
* _Available since v3.4._
*/
function tryMul(uint256 a, uint256 b) internal pure returns (bool, uint256) {
// Gas optimization: this is cheaper than requiring 'a' not being zero, but the
// benefit is lost if 'b' is also tested.
// See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
if (a == 0) return (true, 0);
uint256 c = a * b;
if (c / a != b) return (false, 0);
return (true, c);
}
/**
* @dev Returns the division of two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryDiv(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a / b);
}
/**
* @dev Returns the remainder of dividing two unsigned integers, with a division by zero flag.
*
* _Available since v3.4._
*/
function tryMod(uint256 a, uint256 b) internal pure returns (bool, uint256) {
if (b == 0) return (false, 0);
return (true, a % b);
}
/**
* @dev Returns the addition of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `+` operator.
*
* Requirements:
*
* - Addition cannot overflow.
*/
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a, "SafeMath: addition overflow");
return c;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting on
* overflow (when the result is negative).
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a, "SafeMath: subtraction overflow");
return a - b;
}
/**
* @dev Returns the multiplication of two unsigned integers, reverting on
* overflow.
*
* Counterpart to Solidity's `*` operator.
*
* Requirements:
*
* - Multiplication cannot overflow.
*/
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) return 0;
uint256 c = a * b;
require(c / a == b, "SafeMath: multiplication overflow");
return c;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting on
* division by zero. The result is rounded towards zero.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: division by zero");
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting when dividing by zero.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0, "SafeMath: modulo by zero");
return a % b;
}
/**
* @dev Returns the subtraction of two unsigned integers, reverting with custom message on
* overflow (when the result is negative).
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {trySub}.
*
* Counterpart to Solidity's `-` operator.
*
* Requirements:
*
* - Subtraction cannot overflow.
*/
function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b <= a, errorMessage);
return a - b;
}
/**
* @dev Returns the integer division of two unsigned integers, reverting with custom message on
* division by zero. The result is rounded towards zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryDiv}.
*
* Counterpart to Solidity's `/` operator. Note: this function uses a
* `revert` opcode (which leaves remaining gas untouched) while Solidity
* uses an invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a / b;
}
/**
* @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
* reverting with custom message when dividing by zero.
*
* CAUTION: This function is deprecated because it requires allocating memory for the error
* message unnecessarily. For custom revert reasons use {tryMod}.
*
* Counterpart to Solidity's `%` operator. This function uses a `revert`
* opcode (which leaves remaining gas untouched) while Solidity uses an
* invalid opcode to revert (consuming all remaining gas).
*
* Requirements:
*
* - The divisor cannot be zero.
*/
function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
require(b > 0, errorMessage);
return a % b;
}
}
Address.sol 189 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.2 <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;
// solhint-disable-next-line no-inline-assembly
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");
// solhint-disable-next-line avoid-low-level-calls, avoid-call-value
(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");
// solhint-disable-next-line avoid-low-level-calls
(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");
// solhint-disable-next-line avoid-low-level-calls
(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");
// solhint-disable-next-line avoid-low-level-calls
(bool success, bytes memory returndata) = target.delegatecall(data);
return _verifyCallResult(success, returndata, errorMessage);
}
function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private 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
// solhint-disable-next-line no-inline-assembly
assembly {
let returndata_size := mload(returndata)
revert(add(32, returndata), returndata_size)
}
} else {
revert(errorMessage);
}
}
}
}
Context.sol 24 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <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 GSN 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 payable) {
return msg.sender;
}
function _msgData() internal view virtual returns (bytes memory) {
this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
return msg.data;
}
}
EnumerableSet.sol 297 lines
// SPDX-License-Identifier: MIT
pragma solidity >=0.6.0 <0.8.0;
/**
* @dev Library for managing
* https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
* types.
*
* Sets have the following properties:
*
* - Elements are added, removed, and checked for existence in constant time
* (O(1)).
* - Elements are enumerated in O(n). No guarantees are made on the ordering.
*
* ```
* contract Example {
* // Add the library methods
* using EnumerableSet for EnumerableSet.AddressSet;
*
* // Declare a set state variable
* EnumerableSet.AddressSet private mySet;
* }
* ```
*
* As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
* and `uint256` (`UintSet`) are supported.
*/
library EnumerableSet {
// To implement this library for multiple types with as little code
// repetition as possible, we write it in terms of a generic Set type with
// bytes32 values.
// The Set implementation uses private functions, and user-facing
// implementations (such as AddressSet) are just wrappers around the
// underlying Set.
// This means that we can only create new EnumerableSets for types that fit
// in bytes32.
struct Set {
// Storage of set values
bytes32[] _values;
// Position of the value in the `values` array, plus 1 because index 0
// means a value is not in the set.
mapping (bytes32 => uint256) _indexes;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function _add(Set storage set, bytes32 value) private returns (bool) {
if (!_contains(set, value)) {
set._values.push(value);
// The value is stored at length-1, but we add 1 to all indexes
// and use 0 as a sentinel value
set._indexes[value] = set._values.length;
return true;
} else {
return false;
}
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function _remove(Set storage set, bytes32 value) private returns (bool) {
// We read and store the value's index to prevent multiple reads from the same storage slot
uint256 valueIndex = set._indexes[value];
if (valueIndex != 0) { // Equivalent to contains(set, value)
// To delete an element from the _values array in O(1), we swap the element to delete with the last one in
// the array, and then remove the last element (sometimes called as 'swap and pop').
// This modifies the order of the array, as noted in {at}.
uint256 toDeleteIndex = valueIndex - 1;
uint256 lastIndex = set._values.length - 1;
// When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
// so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.
bytes32 lastvalue = set._values[lastIndex];
// Move the last value to the index where the value to delete is
set._values[toDeleteIndex] = lastvalue;
// Update the index for the moved value
set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based
// Delete the slot where the moved value was stored
set._values.pop();
// Delete the index for the deleted slot
delete set._indexes[value];
return true;
} else {
return false;
}
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function _contains(Set storage set, bytes32 value) private view returns (bool) {
return set._indexes[value] != 0;
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function _length(Set storage set) private view returns (uint256) {
return set._values.length;
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function _at(Set storage set, uint256 index) private view returns (bytes32) {
require(set._values.length > index, "EnumerableSet: index out of bounds");
return set._values[index];
}
// Bytes32Set
struct Bytes32Set {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _add(set._inner, value);
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
return _remove(set._inner, value);
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
return _contains(set._inner, value);
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(Bytes32Set storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
return _at(set._inner, index);
}
// AddressSet
struct AddressSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(AddressSet storage set, address value) internal returns (bool) {
return _add(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(AddressSet storage set, address value) internal returns (bool) {
return _remove(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(AddressSet storage set, address value) internal view returns (bool) {
return _contains(set._inner, bytes32(uint256(uint160(value))));
}
/**
* @dev Returns the number of values in the set. O(1).
*/
function length(AddressSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(AddressSet storage set, uint256 index) internal view returns (address) {
return address(uint160(uint256(_at(set._inner, index))));
}
// UintSet
struct UintSet {
Set _inner;
}
/**
* @dev Add a value to a set. O(1).
*
* Returns true if the value was added to the set, that is if it was not
* already present.
*/
function add(UintSet storage set, uint256 value) internal returns (bool) {
return _add(set._inner, bytes32(value));
}
/**
* @dev Removes a value from a set. O(1).
*
* Returns true if the value was removed from the set, that is if it was
* present.
*/
function remove(UintSet storage set, uint256 value) internal returns (bool) {
return _remove(set._inner, bytes32(value));
}
/**
* @dev Returns true if the value is in the set. O(1).
*/
function contains(UintSet storage set, uint256 value) internal view returns (bool) {
return _contains(set._inner, bytes32(value));
}
/**
* @dev Returns the number of values on the set. O(1).
*/
function length(UintSet storage set) internal view returns (uint256) {
return _length(set._inner);
}
/**
* @dev Returns the value stored at position `index` in the set. O(1).
*
* Note that there are no guarantees on the ordering of values inside the
* array, and it may change when more values are added or removed.
*
* Requirements:
*
* - `index` must be strictly less than {length}.
*/
function at(UintSet storage set, uint256 index) internal view returns (uint256) {
return uint256(_at(set._inner, index));
}
}
Read Contract
DEFAULT_ADMIN_ROLE 0xa217fddf → bytes32
RELAYER_ROLE 0x926d7d7f → bytes32
_chainID 0xbeab7131 → uint8
_depositCounts 0x4b0b919d → uint64
_depositRecords 0x3ee7094a → bytes
_expiry 0xc5ec8970 → uint256
_fee 0xc5b37c22 → uint256
_hasVotedOnProposal 0x7febe63f → bool
_proposals 0x50598719 → bytes32, bytes32, uint8, uint256
_relayerThreshold 0xd7a9cd79 → uint256
_resourceIDToHandlerAddress 0x84db809f → address
_totalProposals 0x9d5773e0 → uint256
_totalRelayers 0x802aabe8 → uint256
getProposal 0xa9cf69fa → tuple
getRoleAdmin 0x248a9ca3 → bytes32
getRoleMember 0x9010d07c → address
getRoleMemberCount 0xca15c873 → uint256
hasRole 0x91d14854 → bool
isRelayer 0x541d5548 → bool
isTrustedForwarder 0x572b6c05 → bool
paused 0x5c975abb → bool
Write Contract 19 functions
These functions modify contract state and require a wallet transaction to execute.
adminAddRelayer 0xcdb0f73a
address relayerAddress
adminChangeFee 0x91c404ac
uint256 newFee
adminChangeRelayerThreshold 0x4e056005
uint256 newThreshold
adminPauseTransfers 0x80ae1c28
No parameters
adminRemoveRelayer 0x9d82dd63
address relayerAddress
adminSetBurnable 0x8c0c2631
address handlerAddress
address tokenAddress
adminSetGenericResource 0xe8437ee7
address handlerAddress
bytes32 resourceID
address contractAddress
bytes4 depositFunctionSig
bytes4 executeFunctionSig
adminSetResource 0xcb10f215
address handlerAddress
bytes32 resourceID
address tokenAddress
adminUnpauseTransfers 0xffaac0eb
No parameters
adminWithdraw 0x780cf004
address handlerAddress
address tokenAddress
address recipient
uint256 amountOrTokenID
cancelProposal 0x17f03ce5
uint8 chainID
uint64 depositNonce
bytes32 dataHash
deposit 0x05e2ca17
uint8 destinationChainID
bytes32 resourceID
bytes data
executeProposal 0x4454b20d
uint8 chainID
uint64 depositNonce
bytes data
bytes32 resourceID
grantRole 0x2f2ff15d
bytes32 role
address account
renounceAdmin 0x5e1fab0f
address newAdmin
renounceRole 0x36568abe
bytes32 role
address account
revokeRole 0xd547741f
bytes32 role
address account
transferFunds 0x4603ae38
address[] addrs
uint256[] amounts
voteProposal 0x1ff013f1
uint8 chainID
uint64 depositNonce
bytes32 resourceID
bytes32 dataHash
Token Balances (1)
View Transfers →Recent Transactions
No transactions found for this address