Address Contract Partially Verified
Address
0xe61dd9cA7364225aFBFB79e15AD33864424e6aE4
Balance
2026.17 ETH
Nonce
1
Code Size
17980 bytes
Creator
0x0948c528...2BD9 at tx 0x2af6b3a7...7c1a93
Indexed Transactions
0
Contract Bytecode
17980 bytes
0x60806040526004361061019b5760003560e01c80638609d28c116100ec578063ceb35b0f1161008a578063e6a81ec411610064578063e6a81ec414610d10578063e9e211bd14610d25578063f46901ed14610dd8578063f60c757f14610e0b5761019b565b8063ceb35b0f14610a4e578063d5b99d3c14610b0a578063dd9b86c114610bd25761019b565b8063b07ed3a9116100c6578063b07ed3a9146107c1578063c8e369bf146107d6578063c8fd90f9146108d7578063cb08e3ca1461099a5761019b565b80638609d28c146105c757806391c40bf7146106f0578063abd108ba146107ac5761019b565b806334e199071161015957806354cf2aeb1161013357806354cf2aeb1461055e5780635c975abb1461057357806364908649146105885780638456cb59146105b25761019b565b806334e19907146104f55780633f4ba83a1461051f578063521cb590146105345761019b565b8062674f63146101a0578063017e7e581461026557806302c1927c1461029657806306fdde031461037d5780631d75807c146104075780632c2df7421461042e575b600080fd5b3480156101ac57600080fd5b50610263600480360360608110156101c357600080fd5b6001600160a01b038235169190810190604081016020820135600160201b8111156101ed57600080fd5b8201836020820111156101ff57600080fd5b803590602001918460018302840111600160201b8311171561022057600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050503515159050610e3e565b005b34801561027157600080fd5b5061027a610f04565b604080516001600160a01b039092168252519081900360200190f35b3480156102a257600080fd5b50610369600480360360a08110156102b957600080fd5b6001600160a01b03823581169260208101359091169160408201359190810190608081016060820135600160201b8111156102f357600080fd5b82018360208201111561030557600080fd5b803590602001918460018302840111600160201b8311171561032657600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250610f13915050565b604080519115158252519081900360200190f35b34801561038957600080fd5b50610392611612565b6040805160208082528351818301528351919283929083019185019080838360005b838110156103cc5781810151838201526020016103b4565b50505050905090810190601f1680156103f95780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b34801561041357600080fd5b5061041c611634565b60408051918252519081900360200190f35b34801561043a57600080fd5b506102636004803603606081101561045157600080fd5b810190602081018135600160201b81111561046b57600080fd5b82018360208201111561047d57600080fd5b803590602001918460018302840111600160201b8311171561049e57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550506001600160a01b03833581169450602090930135909216915061163a9050565b34801561050157600080fd5b506102636004803603602081101561051857600080fd5b5035611860565b34801561052b57600080fd5b506102636118e7565b34801561054057600080fd5b506103696004803603602081101561055757600080fd5b5035611962565b34801561056a57600080fd5b5061041c6119fc565b34801561057f57600080fd5b50610369611a02565b34801561059457600080fd5b50610369600480360360208110156105ab57600080fd5b5035611a0b565b3480156105be57600080fd5b50610263611a20565b610263600480360360408110156105dd57600080fd5b810190602081018135600160201b8111156105f757600080fd5b82018360208201111561060957600080fd5b803590602001918460018302840111600160201b8311171561062a57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b81111561067c57600080fd5b82018360208201111561068e57600080fd5b803590602001918460018302840111600160201b831117156106af57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550611a99945050505050565b3480156106fc57600080fd5b506103696004803603604081101561071357600080fd5b810190602081018135600160201b81111561072d57600080fd5b82018360208201111561073f57600080fd5b803590602001918460018302840111600160201b8311171561076057600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550505090356001600160a01b03169150611c5a9050565b3480156107b857600080fd5b5061027a611fbe565b3480156107cd57600080fd5b5061027a611fd2565b3480156107e257600080fd5b50610887600480360360208110156107f957600080fd5b810190602081018135600160201b81111561081357600080fd5b82018360208201111561082557600080fd5b803590602001918460018302840111600160201b8311171561084657600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612053945050505050565b60408051602080825283518183015283519192839290830191858101910280838360005b838110156108c35781810151838201526020016108ab565b505050509050019250505060405180910390f35b3480156108e357600080fd5b50610263600480360360608110156108fa57600080fd5b6001600160a01b038235169190810190604081016020820135600160201b81111561092457600080fd5b82018360208201111561093657600080fd5b803590602001918460018302840111600160201b8311171561095757600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505050503515159050612072565b3480156109a657600080fd5b506109cd600480360360208110156109bd57600080fd5b50356001600160a01b0316612117565b60405180806020018315158152602001828103825284818151815260200191508051906020019080838360005b83811015610a125781810151838201526020016109fa565b50505050905090810190601f168015610a3f5780820380516001836020036101000a031916815260200191505b50935050505060405180910390f35b348015610a5a57600080fd5b5061036960048036036040811015610a7157600080fd5b810190602081018135600160201b811115610a8b57600080fd5b820183602082011115610a9d57600080fd5b803590602001918460018302840111600160201b83111715610abe57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550505090356001600160a01b031691506121c19050565b348015610b1657600080fd5b5061036960048036036080811015610b2d57600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b811115610b5c57600080fd5b820183602082011115610b6e57600080fd5b803590602001918460018302840111600160201b83111715610b8f57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250612421915050565b61036960048036036080811015610be857600080fd5b6001600160a01b0382351691602081013591810190606081016040820135600160201b811115610c1757600080fd5b820183602082011115610c2957600080fd5b803590602001918460018302840111600160201b83111715610c4a57600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295949360208101935035915050600160201b811115610c9c57600080fd5b820183602082011115610cae57600080fd5b803590602001918460018302840111600160201b83111715610ccf57600080fd5b91908080601f016020809104026020016040519081016040528093929190818152602001838380828437600092019190915250929550612b73945050505050565b348015610d1c57600080fd5b5061041c612d4f565b348015610d3157600080fd5b5061036960048036036040811015610d4857600080fd5b810190602081018135600160201b811115610d6257600080fd5b820183602082011115610d7457600080fd5b803590602001918460018302840111600160201b83111715610d9557600080fd5b91908080601f0160208091040260200160405190810160405280939291908181526020018383808284376000920191909152509295505091359250612d55915050565b348015610de457600080fd5b5061026360048036036020811015610dfb57600080fd5b50356001600160a01b0316613096565b348015610e1757600080fd5b506109cd60048036036020811015610e2e57600080fd5b50356001600160a01b0316613145565b610e56600080516020614583833981519152336131b1565b610e9f576040805162461bcd60e51b8152602060048201526015602482015274213934b233b29d3bb937b7339037b832b930ba37b960591b604482015290519081900360640190fd5b6040805180820182528381528215156020808301919091526001600160a01b038616600090815260088252929092208151805192939192610ee39284920190614485565b50602091909101516001909101805460ff1916911515919091179055505050565b6007546001600160a01b031681565b6000610f2d600080516020614583833981519152336131b1565b610f76576040805162461bcd60e51b8152602060048201526015602482015274213934b233b29d3bb937b7339037b832b930ba37b960591b604482015290519081900360640190fd5b610f7e611a02565b15610fc3576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b8360008111611011576040805162461bcd60e51b815260206004820152601560248201527404272696467653a76616c7565206e656564203e203605c1b604482015290519081900360640190fd5b85858560405160200180846001600160a01b031660601b815260140183815260200182805190602001908083835b6020831061105e5780518252601f19909201916020918201910161103f565b6001836020036101000a03801982511681845116808217855250505050505090500193505050506040516020818303038152906040528051906020012083146110e9576040805162461bcd60e51b81526020600482015260186024820152774272696467653a7461736b486173682069732077726f6e6760401b604482015290519081900360640190fd5b6000838152600a602052604090205460ff1615611148576040805162461bcd60e51b81526020600482015260186024820152774272696467653a74782066696c6c656420616c726561647960401b604482015290519081900360640190fd5b600554604080516323c29c0160e11b8152905160009261010090046001600160a01b03169163ae0fd47f9183916347853802916004808301926020929190829003018186803b15801561119a57600080fd5b505afa1580156111ae573d6000803e3d6000fd5b505050506040513d60208110156111c457600080fd5b505160048054604080516001600160e01b031960e087901b16815292830193909352602482018990523360448301526064820152905160848083019260209291908290030181600087803b15801561121b57600080fd5b505af115801561122f573d6000803e3d6000fd5b505050506040513d602081101561124557600080fd5b5051600554604080516357ea327960e11b815290519293506101009091046001600160a01b03169163afd464f291600480820192602092909190829003018186803b15801561129357600080fd5b505afa1580156112a7573d6000803e3d6000fd5b505050506040513d60208110156112bd57600080fd5b505181141561138057876001600160a01b0316876001600160a01b03167f91b4005f248ece53c5402f0c547c6a472d18676fbb0e2e15029d4869140cbe2088886040518083815260200180602001828103825283818151815260200191508051906020019080838360005b83811015611340578181015183820152602001611328565b50505050905090810190601f16801561136d5780820380516001836020036101000a031916815260200191505b50935050505060405180910390a3611602565b600560019054906101000a90046001600160a01b03166001600160a01b03166310224a986040518163ffffffff1660e01b815260040160206040518083038186803b1580156113ce57600080fd5b505afa1580156113e2573d6000803e3d6000fd5b505050506040513d60208110156113f857600080fd5b505181141561160257600061140e89898961322e565b9050886001600160a01b0316886001600160a01b03167f91b4005f248ece53c5402f0c547c6a472d18676fbb0e2e15029d4869140cbe2089896040518083815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561148a578181015183820152602001611472565b50505050905090810190601f1680156114b75780820380516001836020036101000a031916815260200191505b50935050505060405180910390a3886001600160a01b0316886001600160a01b03167f044513e921a12ac6560730ac3063f7946fdcb715deb39bc6f84c38be8083648a89896040518083815260200180602001828103825283818151815260200191508051906020019080838360005b8381101561153f578181015183820152602001611527565b50505050905090810190601f16801561156c5780820380516001836020036101000a031916815260200191505b50935050505060405180910390a36000858152600a60205260408082208054600160ff19909116179055600554815163281adb1160e11b81526004810189905291516101009091046001600160a01b031692635035b622926024808201939182900301818387803b1580156115e057600080fd5b505af11580156115f4573d6000803e3d6000fd5b505050508093505050611608565b60019250505b5095945050505050565b6040518060400160405280600681526020016542726964676560d01b81525081565b60045490565b611642611a02565b61168a576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6001600160a01b0381166116dc576040805162461bcd60e51b81526020600482015260146024820152734272696467653a77726f6e67206164647265737360601b604482015290519081900360640190fd5b60006116e9848484613750565b9050801561185a576000846040516020018082805190602001908083835b602083106117265780518252601f199092019160209182019101611707565b6001836020036101000a0380198251168184511680821785525050505050509050019150506040516020818303038152906040528051906020012090507f397bc5b97f629151e68146caedba62f10b47e426b38db589771a288c0861f18260001b8114156117b35760058054610100600160a81b0319166101006001600160a01b03861602179055611858565b7fe41d88711b08bdcd7556c5d2d24e0da6fa1f614cf2055f4d7e10206017cd168081141561185857600560019054906101000a90046001600160a01b03166001600160a01b031663b0d80346846040518263ffffffff1660e01b815260040180826001600160a01b03168152602001915050600060405180830381600087803b15801561183f57600080fd5b505af1158015611853573d6000803e3d6000fd5b505050505b505b50505050565b6118786000805160206145a3833981519152336131b1565b6118b35760405162461bcd60e51b81526004018080602001828103825260228152602001806145e56022913960400191505060405180910390fd5b6006546040518291907fad321f810529281bbb90384fd6fecbdda41509a5ccd7bd5aed986ed827f6a02690600090a3600655565b6119117f0cc58340b26c619cd4edc70f833d3f4d9d26f3ae7d5ef2965f81fe5495049a4f336131b1565b611958576040805162461bcd60e51b8152602060048201526013602482015272213934b233b29d3bb937b733903830bab9b2b960691b604482015290519081900360640190fd5b61196061398e565b565b600061197c6000805160206145a3833981519152336131b1565b6119b75760405162461bcd60e51b81526004018080602001828103825260228152602001806145e56022913960400191505060405180910390fd5b6119c082613a2e565b6040805183815290517f468b360fa155a4c5fdf0cb38ce238407e41508a56023e7536088c21b2cd641399181900360200190a15060015b919050565b60065481565b60055460ff1690565b600a6020526000908152604090205460ff1681565b611a4a7f0cc58340b26c619cd4edc70f833d3f4d9d26f3ae7d5ef2965f81fe5495049a4f336131b1565b611a91576040805162461bcd60e51b8152602060048201526013602482015272213934b233b29d3bb937b733903830bab9b2b960691b604482015290519081900360640190fd5b611960613a5a565b600654341015611af0576040805162461bcd60e51b815260206004820152601c60248201527f4272696467653a696e73756666696369656e7420737761702066656500000000604482015290519081900360640190fd5b60065415611b36576007546006546040516001600160a01b039092169181156108fc0291906000818181858888f19350505050158015611b34573d6000803e3d6000fd5b505b336001600160a01b03167f0f0febc7655213f7f4ed640f722413acbfa5bab0fac4cd58ae8792c618e2ab3760065434038484600654604051808581526020018060200180602001848152602001838103835286818151815260200191508051906020019080838360005b83811015611bb8578181015183820152602001611ba0565b50505050905090810190601f168015611be55780820380516001836020036101000a031916815260200191505b50838103825285518152855160209182019187019080838360005b83811015611c18578181015183820152602001611c00565b50505050905090810190601f168015611c455780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a25050565b6000611c746000805160206145a3833981519152336131b1565b611caf5760405162461bcd60e51b81526004018080602001828103825260228152602001806145e56022913960400191505060405180910390fd5b6000611cba84613add565b90507fe41d88711b08bdcd7556c5d2d24e0da6fa1f614cf2055f4d7e10206017cd16808114801590611d0c57507f397bc5b97f629151e68146caedba62f10b47e426b38db589771a288c0861f1828114155b611d57576040805162461bcd60e51b815260206004820152601760248201527642726964676541646d696e3a77726f6e6720636c61737360481b604482015290519081900360640190fd5b611d6181846131b1565b611d9c5760405162461bcd60e51b81526004018080602001828103825260228152602001806145c36022913960400191505060405180910390fd5b6000805160206145a3833981519152811415611dfa57600354611dbe82613baa565b11611dfa5760405162461bcd60e51b81526004018080602001828103825260238152602001806145606023913960400191505060405180910390fd5b6000848460405160200180806a64726f704164647265737360a81b815250600b0183805190602001908083835b60208310611e465780518252601f199092019160209182019101611e27565b6001836020036101000a038019825116818451168082178552505050505050905001826001600160a01b031660601b815260140192505050604051602081830303815290604052805190602001209050611ea08133613bbf565b600354611eac82613baa565b10611fb157611ebb8285613cc3565b7fb02ddf2800cd4468f7eb14268a7c9f1b6e816aa425ed542d13d8d3a96fa44566858586604051808060200180602001856001600160a01b03168152602001846001600160a01b031681526020018381038352600b8152602001806a64726f704164647265737360a81b815250602001838103825286818151815260200191508051906020019080838360005b83811015611f60578181015183820152602001611f48565b50505050905090810190601f168015611f8d5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1611fa681613a2e565b600192505050611fb8565b6000925050505b92915050565b60055461010090046001600160a01b031690565b6000600560019054906101000a90046001600160a01b03166001600160a01b031663b07ed3a96040518163ffffffff1660e01b815260040160206040518083038186803b15801561202257600080fd5b505afa158015612036573d6000803e3d6000fd5b505050506040513d602081101561204c57600080fd5b5051905090565b6060600061206083613add565b905061206b81613df3565b9392505050565b61208a600080516020614583833981519152336131b1565b6120d3576040805162461bcd60e51b8152602060048201526015602482015274213934b233b29d3bb937b7339037b832b930ba37b960591b604482015290519081900360640190fd5b6040805180820182528381528215156020808301919091526001600160a01b038616600090815260098252929092208151805192939192610ee39284920190614485565b60096020908152600091825260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529092918391908301828280156121ae5780601f10612183576101008083540402835291602001916121ae565b820191906000526020600020905b81548152906001019060200180831161219157829003601f168201915b5050506001909301549192505060ff1682565b60006121db6000805160206145a3833981519152336131b1565b6122165760405162461bcd60e51b81526004018080602001828103825260228152602001806145e56022913960400191505060405180910390fd5b600061222184613add565b90507fe41d88711b08bdcd7556c5d2d24e0da6fa1f614cf2055f4d7e10206017cd1680811480159061227357507f397bc5b97f629151e68146caedba62f10b47e426b38db589771a288c0861f1828114155b6122be576040805162461bcd60e51b815260206004820152601760248201527642726964676541646d696e3a77726f6e6720636c61737360481b604482015290519081900360640190fd5b600084846040516020018080696164644164647265737360b01b815250600a0183805190602001908083835b602083106123095780518252601f1990920191602091820191016122ea565b6001836020036101000a038019825116818451168082178552505050505050905001826001600160a01b031660601b8152601401925050506040516020818303038152906040528051906020012090506123638133613bbf565b60035461236f82613baa565b10611fb15761237e8285613bbf565b7fb02ddf2800cd4468f7eb14268a7c9f1b6e816aa425ed542d13d8d3a96fa44566858586604051808060200180602001856001600160a01b03168152602001846001600160a01b031681526020018381038352600a815260200180696164644164647265737360b01b8152506020018381038252868181518152602001915080519060200190808383600083811015611f60578181015183820152602001611f48565b600061243b600080516020614583833981519152336131b1565b612484576040805162461bcd60e51b8152602060048201526015602482015274213934b233b29d3bb937b7339037b832b930ba37b960591b604482015290519081900360640190fd5b61248c611a02565b156124d1576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b836000811161251f576040805162461bcd60e51b815260206004820152601560248201527404272696467653a76616c7565206e656564203e203605c1b604482015290519081900360640190fd5b84471015612574576040805162461bcd60e51b815260206004820152601e60248201527f4272696467653a6e6f7420656e6f756768206e617469766520746f6b656e0000604482015290519081900360640190fd5b85858560405160200180846001600160a01b031660601b815260140183815260200182805190602001908083835b602083106125c15780518252601f1990920191602091820191016125a2565b6001836020036101000a038019825116818451168082178552505050505050905001935050505060405160208183030381529060405280519060200120831461264c576040805162461bcd60e51b81526020600482015260186024820152774272696467653a7461736b486173682069732077726f6e6760401b604482015290519081900360640190fd5b6000838152600a602052604090205460ff16156126ab576040805162461bcd60e51b81526020600482015260186024820152774272696467653a74782066696c6c656420616c726561647960401b604482015290519081900360640190fd5b600554604080516323c29c0160e11b8152905160009261010090046001600160a01b03169163ae0fd47f9183916347853802916004808301926020929190829003018186803b1580156126fd57600080fd5b505afa158015612711573d6000803e3d6000fd5b505050506040513d602081101561272757600080fd5b505160048054604080516001600160e01b031960e087901b16815292830193909352602482018990523360448301526064820152905160848083019260209291908290030181600087803b15801561277e57600080fd5b505af1158015612792573d6000803e3d6000fd5b505050506040513d60208110156127a857600080fd5b5051600554604080516357ea327960e11b815290519293506101009091046001600160a01b03169163afd464f291600480820192602092909190829003018186803b1580156127f657600080fd5b505afa15801561280a573d6000803e3d6000fd5b505050506040513d602081101561282057600080fd5b50518114156128d957866001600160a01b03167f85c53e7e269cd44a12210170eb2636cdc0d111b93e101a211305e0144733995587876040518083815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612899578181015183820152602001612881565b50505050905090810190601f1680156128c65780820380516001836020036101000a031916815260200191505b50935050505060405180910390a2612b66565b600560019054906101000a90046001600160a01b03166001600160a01b03166310224a986040518163ffffffff1660e01b815260040160206040518083038186803b15801561292757600080fd5b505afa15801561293b573d6000803e3d6000fd5b505050506040513d602081101561295157600080fd5b5051811415612b6657866001600160a01b03167f85c53e7e269cd44a12210170eb2636cdc0d111b93e101a211305e0144733995587876040518083815260200180602001828103825283818151815260200191508051906020019080838360005b838110156129ca5781810151838201526020016129b2565b50505050905090810190601f1680156129f75780820380516001836020036101000a031916815260200191505b50935050505060405180910390a2866001600160a01b03167fd8ff38332185c42ca14ded5671b8eb2842095abf024f6900cb42760ccb438f3387876040518083815260200180602001828103825283818151815260200191508051906020019080838360005b83811015612a75578181015183820152602001612a5d565b50505050905090810190601f168015612aa25780820380516001836020036101000a031916815260200191505b50935050505060405180910390a26040516001600160a01b0388169087156108fc029088906000818181858888f19350505050158015612ae6573d6000803e3d6000fd5b506000848152600a60205260408082208054600160ff19909116179055600554815163281adb1160e11b81526004810188905291516101009091046001600160a01b031692635035b622926024808201939182900301818387803b158015612b4d57600080fd5b505af1158015612b61573d6000803e3d6000fd5b505050505b5060019695505050505050565b60006006543414612bcb576040805162461bcd60e51b815260206004820152601960248201527f4272696467653a7377617020666565206e6f7420657175616c00000000000000604482015290519081900360640190fd5b60065415612c11576007546006546040516001600160a01b039092169181156108fc0291906000818181858888f19350505050158015612c0f573d6000803e3d6000fd5b505b6000612c1e863387613e62565b9050856001600160a01b0316336001600160a01b03167f63333d9ba80d323ed3a2c486809215e8f1fb8c645691606b862787fad572c1c7878787600654604051808581526020018060200180602001848152602001838103835286818151815260200191508051906020019080838360005b83811015612ca8578181015183820152602001612c90565b50505050905090810190601f168015612cd55780820380516001836020036101000a031916815260200191505b50838103825285518152855160209182019187019080838360005b83811015612d08578181015183820152602001612cf0565b50505050905090810190601f168015612d355780820380516001836020036101000a031916815260200191505b50965050505050505060405180910390a395945050505050565b60035490565b6000612d6f6000805160206145a3833981519152336131b1565b612daa5760405162461bcd60e51b81526004018080602001828103825260228152602001806145e56022913960400191505060405180910390fd5b6000612db584613add565b9050600080516020614583833981519152811480612de057506000805160206145a383398151915281145b612e2b576040805162461bcd60e51b815260206004820152601760248201527642726964676541646d696e3a77726f6e6720636c61737360481b604482015290519081900360640190fd5b6000848460405160200180806f726573657452657175697265644e756d60801b81525060100183805190602001908083835b60208310612e7c5780518252601f199092019160209182019101612e5d565b51815160209384036101000a6000190180199092169116179052920193845250604080518085038152938201905282519201919091209250612ec2915082905033613bbf565b600354612ece82613baa565b1061308b57612edc81613a2e565b60006000805160206145a3833981519152831415612f495784612efe84613baa565b1015612f3b5760405162461bcd60e51b81526004018080602001828103825260238152602001806145606023913960400191505060405180910390fd5b506003805490859055612fb4565b600080516020614583833981519152831415612f6d57506004805490859055612fb4565b6040805162461bcd60e51b815260206004820152601760248201527642726964676541646d696e3a77726f6e6720636c61737360481b604482015290519081900360640190fd5b7fce49fc04234925e87b95750e0e50cac6d4ffcf8a696e3316b3e13bedc84ee7a8868287604051808060200180602001858152602001848152602001838103835260108152602001806f726573657452657175697265644e756d60801b815250602001838103825286818151815260200191508051906020019080838360005b8381101561304c578181015183820152602001613034565b50505050905090810190601f1680156130795780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a1505b506001949350505050565b6130ae6000805160206145a3833981519152336131b1565b6130e95760405162461bcd60e51b81526004018080602001828103825260228152602001806145e56022913960400191505060405180910390fd5b6007546040516001600160a01b038084169216907f941bed5eb8a4f7abb41f1a8547c6b5fded98a6fbe47dbd60aee080690de5f0d590600090a3600780546001600160a01b0319166001600160a01b0392909216919091179055565b60086020908152600091825260409182902080548351601f600260001961010060018616150201909316929092049182018490048402810184019094528084529092918391908301828280156121ae5780601f10612183576101008083540402835291602001916121ae565b6000805b60008481526001602052604090206002015481101561322457600084815260016020526040902060020180546001600160a01b0385169190839081106131f757fe5b6000918252602090912001546001600160a01b0316141561321c576001915050611fb8565b6001016131b5565b5060009392505050565b6001600160a01b03831660009081526009602052604081205481906060906002600019610100600184161502019091160461334c57604080516001600160a01b038781166024830152604480830188905283518084039091018152606490920183526020820180516001600160e01b031663a9059cbb60e01b17815292518251918a169390918291908083835b602083106132da5780518252601f1990920191602091820191016132bb565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d806000811461333c576040519150601f19603f3d011682016040523d82523d6000602084013e613341565b606091505b5090925090506136d1565b613354614511565b6001600160a01b0387166000908152600960209081526040918290208251815460026001821615610100026000190190911604601f81018490049093028101606090810185529381018381529093919284928491908401828280156133fa5780601f106133cf576101008083540402835291602001916133fa565b820191906000526020600020905b8154815290600101906020018083116133dd57829003601f168201915b50505091835250506001919091015460ff1615156020918201528101519091501561357957866001600160a01b03168160000151868860405160240180838152602001826001600160a01b0316815260200192505050604051602081830303815290604052906040518082805190602001908083835b6020831061348f5780518252601f199092019160209182019101613470565b51815160001960209485036101000a01908116901991909116179052604080519490920184900390932092860180516001600160e01b03166001600160e01b031990941693909317835251855190945084935090508083835b602083106135075780518252601f1990920191602091820191016134e8565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613569576040519150601f19603f3d011682016040523d82523d6000602084013e61356e565b606091505b5090935091506136cf565b866001600160a01b03168160000151878760405160240180836001600160a01b0316815260200182815260200192505050604051602081830303815290604052906040518082805190602001908083835b602083106135e95780518252601f1990920191602091820191016135ca565b51815160001960209485036101000a01908116901991909116179052604080519490920184900390932092860180516001600160e01b03166001600160e01b031990941693909317835251855190945084935090508083835b602083106136615780518252601f199092019160209182019101613642565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146136c3576040519150601f19603f3d011682016040523d82523d6000602084013e6136c8565b606091505b5090935091505b505b8180156136fa5750805115806136fa57508080602001905160208110156136f757600080fd5b50515b613744576040805162461bcd60e51b8152602060048201526016602482015275109c9a5919d94e9dda5d1a191c985dc819985a5b195960521b604482015290519081900360640190fd5b50600195945050505050565b600061376a6000805160206145a3833981519152336131b1565b6137a55760405162461bcd60e51b81526004018080602001828103825260228152602001806145e56022913960400191505060405180910390fd5b60006137b085613add565b9050600085858560405160200180806c6d6f646966794164647265737360981b815250600d0184805190602001908083835b602083106138015780518252601f1990920191602091820191016137e2565b6001836020036101000a038019825116818451168082178552505050505050905001836001600160a01b031660601b8152601401826001600160a01b031660601b8152601401935050505060405160208183030381529060405280519060200120905061386e8133613bbf565b60035461387a82613baa565b106139825761388a82868661437d565b7fb02ddf2800cd4468f7eb14268a7c9f1b6e816aa425ed542d13d8d3a96fa44566868686604051808060200180602001856001600160a01b03168152602001846001600160a01b031681526020018381038352600d8152602001806c6d6f646966794164647265737360981b815250602001838103825286818151815260200191508051906020019080838360005b83811015613931578181015183820152602001613919565b50505050905090810190601f16801561395e5780820380516001836020036101000a031916815260200191505b509550505050505060405180910390a161397781613a2e565b60019250505061206b565b50600095945050505050565b613996611a02565b6139de576040805162461bcd60e51b815260206004820152601460248201527314185d5cd8589b194e881b9bdd081c185d5cd95960621b604482015290519081900360640190fd5b6005805460ff191690557f5db9ee0a495bf2e6ff9c91a7834c1ba4fdd244a5e8aa4e537bd38aeae4b073aa613a11614439565b604080516001600160a01b039092168252519081900360200190a1565b6000818152600160208190526040822082815590810182905590613a556002830182614529565b505050565b613a62611a02565b15613aa7576040805162461bcd60e51b815260206004820152601060248201526f14185d5cd8589b194e881c185d5cd95960821b604482015290519081900360640190fd5b6005805460ff191660011790557f62e78cea01bee320cd4e420270b5ea74000d11b0c9f74754ebdbfc544b05a258613a11614439565b600080826040516020018082805190602001908083835b60208310613b135780518252601f199092019160209182019101613af4565b6001836020036101000a038019825116818451168082178552505050505050905001915050604051602081830303815290604052805190602001209050613b598161443d565b611fb8576040805162461bcd60e51b815260206004820152601960248201527f42726964676541646d696e3a696e76616c696420636c61737300000000000000604482015290519081900360640190fd5b60009081526001602052604090206002015490565b613bc982826131b1565b15613c1b576040805162461bcd60e51b815260206004820152601b60248201527f436f6e7461696e65723a64757020616464726573732061646465640000000000604482015290519081900360640190fd5b60008054838252600160205260409091206002015410613c82576040805162461bcd60e51b815260206004820152601c60248201527f436f6e7461696e65723a746f6f206d616e792061646472657373657300000000604482015290519081900360640190fd5b6000918252600160208181526040842060020180549283018155845290922090910180546001600160a01b0319166001600160a01b03909216919091179055565b60005b600083815260016020526040902060020154811015613a5557600083815260016020526040902060020180546001600160a01b038416919083908110613d0857fe5b6000918252602090912001546001600160a01b03161415613de757600083815260016020526040902060020180546000198101908110613d4457fe5b60009182526020808320909101548583526001909152604090912060020180546001600160a01b039092169183908110613d7a57fe5b600091825260208083209190910180546001600160a01b0319166001600160a01b039490941693909317909255848152600190915260409020600201805480613dbf57fe5b600082815260209020810160001990810180546001600160a01b031916905501905550613def565b600101613cc6565b5050565b600081815260016020908152604091829020600201805483518184028101840190945280845260609392830182828015613e5657602002820191906000526020600020905b81546001600160a01b03168152600190910190602001808311613e38575b50505050509050919050565b6001600160a01b038316600090815260086020526040812054819060609060026000196101006001841615020190911604613f8657604080516001600160a01b038781166024830152306044830152606480830188905283518084039091018152608490920183526020820180516001600160e01b03166323b872dd60e01b17815292518251918a169390918291908083835b60208310613f145780518252601f199092019160209182019101613ef5565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613f76576040519150601f19603f3d011682016040523d82523d6000602084013e613f7b565b606091505b50909250905061430b565b613f8e614511565b6001600160a01b0387166000908152600860209081526040918290208251815460026001821615610100026000190190911604601f81018490049093028101606090810185529381018381529093919284928491908401828280156140345780601f1061400957610100808354040283529160200191614034565b820191906000526020600020905b81548152906001019060200180831161401757829003601f168201915b50505091835250506001919091015460ff161515602091820152810151909150156141b357866001600160a01b03168160000151868860405160240180838152602001826001600160a01b0316815260200192505050604051602081830303815290604052906040518082805190602001908083835b602083106140c95780518252601f1990920191602091820191016140aa565b51815160001960209485036101000a01908116901991909116179052604080519490920184900390932092860180516001600160e01b03166001600160e01b031990941693909317835251855190945084935090508083835b602083106141415780518252601f199092019160209182019101614122565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146141a3576040519150601f19603f3d011682016040523d82523d6000602084013e6141a8565b606091505b509093509150614309565b866001600160a01b03168160000151878760405160240180836001600160a01b0316815260200182815260200192505050604051602081830303815290604052906040518082805190602001908083835b602083106142235780518252601f199092019160209182019101614204565b51815160001960209485036101000a01908116901991909116179052604080519490920184900390932092860180516001600160e01b03166001600160e01b031990941693909317835251855190945084935090508083835b6020831061429b5780518252601f19909201916020918201910161427c565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d80600081146142fd576040519150601f19603f3d011682016040523d82523d6000602084013e614302565b606091505b5090935091505b505b818015614334575080511580614334575080806020019051602081101561433157600080fd5b50515b613744576040805162461bcd60e51b8152602060048201526015602482015274109c9a5919d94e99195c1bdcda5d0819985a5b1959605a1b604482015290519081900360640190fd5b60005b60008481526001602052604090206002015481101561185a57600084815260016020526040902060020180546001600160a01b0385169190839081106143c257fe5b6000918252602090912001546001600160a01b031614156144315760008481526001602052604090206002018054839190839081106143fd57fe5b9060005260206000200160006101000a8154816001600160a01b0302191690836001600160a01b0316021790555050613a55565b600101614380565b3390565b6000805b60025481101561447c57826002828154811061445957fe5b906000526020600020015414156144745760019150506119f7565b600101614441565b50600092915050565b828054600181600116156101000203166002900490600052602060002090601f0160209004810192826144bb5760008555614501565b82601f106144d457805160ff1916838001178555614501565b82800160010185558215614501579182015b828111156145015782518255916020019190600101906144e6565b5061450d92915061454a565b5090565b60408051808201909152606081526000602082015290565b5080546000825590600052602060002090810190614547919061454a565b50565b5b8082111561450d576000815560010161454b56fe42726964676541646d696e3a696e73756666696369656e63792061646472657373657346a52cf33029de9f84853745a87af28464c80bf0346df1b32e205fc73319f62202016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c042726964676541646d696e3a6e6f207375636820616464726573732065786973747342726964676541646d696e3a6f6e6c7920757365206f776e657220746f2063616c6ca26469706673582212204cc2b3fe807b742ed23bfa25d80efe6c88d9e53210798af5defd60e46614d1cd64736f6c63430007040033
Verified Source Code Partial Match
Compiler: v0.7.4+commit.3f05b770
EVM: istanbul
Optimization: Yes (200 runs)
Bridge.sol 896 lines
// File: @openzeppelin/contracts/utils/Context.sol
// 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;
}
}
// File: @openzeppelin/contracts/utils/Pausable.sol
pragma solidity ^0.7.0;
/**
* @dev Contract module which allows children to implement an emergency stop
* mechanism that can be triggered by an authorized account.
*
* This module is used through inheritance. It will make available the
* modifiers `whenNotPaused` and `whenPaused`, which can be applied to
* the functions of your contract. Note that they will not be pausable by
* simply including this module, only once the modifiers are put in place.
*/
abstract contract Pausable is Context {
/**
* @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 () {
_paused = false;
}
/**
* @dev Returns true if the contract is paused, and false otherwise.
*/
function paused() public view virtual 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() {
require(!paused(), "Pausable: paused");
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*
* Requirements:
*
* - The contract must be paused.
*/
modifier whenPaused() {
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(_msgSender());
}
/**
* @dev Returns to normal state.
*
* Requirements:
*
* - The contract must be paused.
*/
function _unpause() internal virtual whenPaused {
_paused = false;
emit Unpaused(_msgSender());
}
}
// File: contracts/Container.sol
pragma solidity ^0.7.0;
contract Container {
struct Item {
uint256 itemType;
uint256 status;
address[] addresses;
}
uint256 MaxItemAddressNum = 255;
mapping(bytes32 => Item) private container;
function itemAddressExists(bytes32 _id, address _oneAddress) internal view returns (bool) {
for (uint256 i = 0; i < container[_id].addresses.length; i++) {
if (container[_id].addresses[i] == _oneAddress)
return true;
}
return false;
}
function getItemAddresses(bytes32 _id) internal view returns (address[] memory) {
return container[_id].addresses;
}
function getItemInfo(bytes32 _id) internal view returns (uint256, uint256, uint256) {
return (container[_id].itemType, container[_id].status, container[_id].addresses.length);
}
function getItemAddressCount(bytes32 _id) internal view returns (uint256) {
return container[_id].addresses.length;
}
function setItemInfo(bytes32 _id, uint256 _itemType, uint256 _status) internal {
container[_id].itemType = _itemType;
container[_id].status = _status;
}
function addItemAddress(bytes32 _id, address _oneAddress) internal {
require(!itemAddressExists(_id, _oneAddress), "Container:dup address added");
require(container[_id].addresses.length < MaxItemAddressNum, "Container:too many addresses");
container[_id].addresses.push(_oneAddress);
}
function removeItemAddresses(bytes32 _id) internal {
delete container[_id].addresses;
}
function removeOneItemAddress(bytes32 _id, address _oneAddress) internal {
for (uint256 i = 0; i < container[_id].addresses.length; i++) {
if (container[_id].addresses[i] == _oneAddress) {
container[_id].addresses[i] = container[_id].addresses[container[_id].addresses.length - 1];
container[_id].addresses.pop();
return;
}
}
}
function removeItem(bytes32 _id) internal {
delete container[_id];
}
function replaceItemAddress(bytes32 _id, address _oneAddress, address _anotherAddress) internal {
for (uint256 i = 0; i < container[_id].addresses.length; i++) {
if (container[_id].addresses[i] == _oneAddress) {
container[_id].addresses[i] = _anotherAddress;
return;
}
}
}
}
// File: contracts/BridgeAdmin.sol
pragma solidity ^0.7.0;
contract BridgeAdmin is Container {
bytes32 internal constant OWNERHASH = 0x02016836a56b71f0d02689e69e326f4f4c1b9057164ef592671cf0d37c8040c0;
bytes32 internal constant OPERATORHASH = 0x46a52cf33029de9f84853745a87af28464c80bf0346df1b32e205fc73319f622;
bytes32 internal constant PAUSERHASH = 0x0cc58340b26c619cd4edc70f833d3f4d9d26f3ae7d5ef2965f81fe5495049a4f;
bytes32 internal constant STOREHASH = 0xe41d88711b08bdcd7556c5d2d24e0da6fa1f614cf2055f4d7e10206017cd1680;
bytes32 internal constant LOGICHASH = 0x397bc5b97f629151e68146caedba62f10b47e426b38db589771a288c0861f182;
uint256 internal constant MAXUSERNUM = 255;
bytes32[] private classHashArray;
uint256 internal ownerRequireNum;
uint256 internal operatorRequireNum;
event AdminChanged(string TaskType, string class, address oldAddress, address newAddress);
event AdminRequiredNumChanged(string TaskType, string class, uint256 previousNum, uint256 requiredNum);
event AdminTaskDropped(bytes32 taskHash);
modifier validRequirement(uint ownerCount, uint _required) {
require(ownerCount <= MaxItemAddressNum && _required <= ownerCount && _required > 0 && ownerCount > 0);
_;
}
modifier onlyOwner() {
require(itemAddressExists(OWNERHASH, msg.sender), "BridgeAdmin:only use owner to call");
_;
}
function initAdmin(address[] memory _owners, uint _ownerRequired) internal validRequirement(_owners.length, _ownerRequired) {
for (uint i = 0; i < _owners.length; i++) {
addItemAddress(OWNERHASH, _owners[i]);
}
addItemAddress(PAUSERHASH, _owners[0]);
// we need an init pauser
addItemAddress(LOGICHASH, address(0x0));
addItemAddress(STOREHASH, address(0x1));
classHashArray.push(OWNERHASH);
classHashArray.push(OPERATORHASH);
classHashArray.push(PAUSERHASH);
classHashArray.push(STOREHASH);
classHashArray.push(LOGICHASH);
ownerRequireNum = _ownerRequired;
operatorRequireNum = 2;
}
function classHashExist(bytes32 aHash) private view returns (bool) {
for (uint256 i = 0; i < classHashArray.length; i++)
if (classHashArray[i] == aHash) return true;
return false;
}
function getAdminAddresses(string memory class) public view returns (address[] memory) {
bytes32 classHash = getClassHash(class);
return getItemAddresses(classHash);
}
function getOwnerRequireNum() public view returns (uint256) {
return ownerRequireNum;
}
function getOperatorRequireNum() public view returns (uint256) {
return operatorRequireNum;
}
function resetRequiredNum(string memory class, uint256 requiredNum) public onlyOwner returns (bool) {
bytes32 classHash = getClassHash(class);
require((classHash == OPERATORHASH) || (classHash == OWNERHASH), "BridgeAdmin:wrong class");
bytes32 taskHash = keccak256(abi.encodePacked("resetRequiredNum", class, requiredNum));
addItemAddress(taskHash, msg.sender);
if (getItemAddressCount(taskHash) >= ownerRequireNum) {
removeItem(taskHash);
uint256 previousNum = 0;
if (classHash == OWNERHASH) {
require(getItemAddressCount(classHash) >= requiredNum, "BridgeAdmin:insufficiency addresses");
previousNum = ownerRequireNum;
ownerRequireNum = requiredNum;
}
else if (classHash == OPERATORHASH) {
previousNum = operatorRequireNum;
operatorRequireNum = requiredNum;
} else {
revert("BridgeAdmin:wrong class");
}
emit AdminRequiredNumChanged("resetRequiredNum", class, previousNum, requiredNum);
}
return true;
}
function modifyAddress(string memory class, address oldAddress, address newAddress) internal onlyOwner returns (bool) {
bytes32 classHash = getClassHash(class);
bytes32 taskHash = keccak256(abi.encodePacked("modifyAddress", class, oldAddress, newAddress));
addItemAddress(taskHash, msg.sender);
if (getItemAddressCount(taskHash) >= ownerRequireNum) {
replaceItemAddress(classHash, oldAddress, newAddress);
emit AdminChanged("modifyAddress", class, oldAddress, newAddress);
removeItem(taskHash);
return true;
}
return false;
}
function getClassHash(string memory class) private view returns (bytes32) {
bytes32 classHash = keccak256(abi.encodePacked(class));
require(classHashExist(classHash), "BridgeAdmin:invalid class");
return classHash;
}
function dropAddress(string memory class, address oneAddress) public onlyOwner returns (bool) {
bytes32 classHash = getClassHash(class);
require(classHash != STOREHASH && classHash != LOGICHASH, "BridgeAdmin:wrong class");
require(itemAddressExists(classHash, oneAddress), "BridgeAdmin:no such address exists");
if (classHash == OWNERHASH)
require(getItemAddressCount(classHash) > ownerRequireNum, "BridgeAdmin:insufficiency addresses");
bytes32 taskHash = keccak256(abi.encodePacked("dropAddress", class, oneAddress));
addItemAddress(taskHash, msg.sender);
if (getItemAddressCount(taskHash) >= ownerRequireNum) {
removeOneItemAddress(classHash, oneAddress);
emit AdminChanged("dropAddress", class, oneAddress, oneAddress);
removeItem(taskHash);
return true;
}
return false;
}
function addAddress(string memory class, address oneAddress) public onlyOwner returns (bool) {
bytes32 classHash = getClassHash(class);
require(classHash != STOREHASH && classHash != LOGICHASH, "BridgeAdmin:wrong class");
bytes32 taskHash = keccak256(abi.encodePacked("addAddress", class, oneAddress));
addItemAddress(taskHash, msg.sender);
if (getItemAddressCount(taskHash) >= ownerRequireNum) {
addItemAddress(classHash, oneAddress);
emit AdminChanged("addAddress", class, oneAddress, oneAddress);
removeItem(taskHash);
return true;
}
return false;
}
function dropTask(bytes32 taskHash) public onlyOwner returns (bool) {
removeItem(taskHash);
emit AdminTaskDropped(taskHash);
return true;
}
}
// File: @openzeppelin/contracts/math/SafeMath.sol
pragma solidity ^0.7.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;
}
}
// File: contracts/BridgeStorage.sol
pragma solidity ^0.7.0;
contract BridgeStorage is Container {
string public constant name = "BridgeStorage";
address private caller;
constructor(address aCaller) {
caller = aCaller;
}
modifier onlyCaller() {
require(msg.sender == caller, "BridgeStorage:only use main contract to call");
_;
}
function supporterExists(bytes32 taskHash, address user) public view returns (bool) {
return itemAddressExists(taskHash, user);
}
function setTaskInfo(bytes32 taskHash, uint256 taskType, uint256 status) external onlyCaller {
setItemInfo(taskHash, taskType, status);
}
function getTaskInfo(bytes32 taskHash) public view returns (uint256, uint256, uint256) {
return getItemInfo(taskHash);
}
function addSupporter(bytes32 taskHash, address oneAddress) external onlyCaller {
addItemAddress(taskHash, oneAddress);
}
function removeAllSupporter(bytes32 taskHash) external onlyCaller {
removeItemAddresses(taskHash);
}
function removeTask(bytes32 taskHash) external onlyCaller {
removeItem(taskHash);
}
}
// File: contracts/BridgeLogic.sol
pragma solidity ^0.7.0;
contract BridgeLogic {
using SafeMath for uint256;
string public constant name = "BridgeLogic";
bytes32 internal constant OPERATORHASH = 0x46a52cf33029de9f84853745a87af28464c80bf0346df1b32e205fc73319f622;
uint256 public constant TASKINIT = 0;
uint256 public constant TASKPROCESSING = 1;
uint256 public constant TASKCANCELLED = 2;
uint256 public constant TASKDONE = 3;
uint256 public constant WITHDRAWTASK = 1;
address private caller;
BridgeStorage private store;
constructor(address aCaller) {
caller = aCaller;
}
modifier onlyCaller() {
require(msg.sender == caller, "BridgeLogic:only use main contract to call");
_;
}
modifier operatorExists(address operator) {
require(store.supporterExists(OPERATORHASH, operator), "BridgeLogic:wrong operator");
_;
}
function resetStoreLogic(address storeAddress) external onlyCaller {
store = BridgeStorage(storeAddress);
}
function getStoreAddress() public view returns (address) {
return address(store);
}
function supportTask(uint256 taskType, bytes32 taskHash, address oneAddress, uint256 requireNum) external onlyCaller returns (uint256) {
require(!store.supporterExists(taskHash, oneAddress), "BridgeLogic:supporter already exists");
(uint256 theTaskType,uint256 theTaskStatus,uint256 theSupporterNum) = store.getTaskInfo(taskHash);
require(theTaskStatus < TASKDONE, "BridgeLogic:wrong status");
if (theTaskStatus != TASKINIT)
require(theTaskType == taskType, "BridgeLogic:task type not match");
store.addSupporter(taskHash, oneAddress);
theSupporterNum++;
if (theSupporterNum >= requireNum)
theTaskStatus = TASKDONE;
else
theTaskStatus = TASKPROCESSING;
store.setTaskInfo(taskHash, taskType, theTaskStatus);
return theTaskStatus;
}
function cancelTask(bytes32 taskHash) external onlyCaller returns (uint256) {
(uint256 theTaskType,uint256 theTaskStatus,uint256 theSupporterNum) = store.getTaskInfo(taskHash);
require(theTaskStatus == TASKPROCESSING, "BridgeLogic:wrong status");
if (theSupporterNum > 0) store.removeAllSupporter(taskHash);
theTaskStatus = TASKCANCELLED;
store.setTaskInfo(taskHash, theTaskType, theTaskStatus);
return theTaskStatus;
}
function removeTask(bytes32 taskHash) external onlyCaller {
store.removeTask(taskHash);
}
}
// File: contracts/Bridge.sol
pragma solidity ^0.7.0;
contract Bridge is BridgeAdmin, Pausable {
using SafeMath for uint256;
string public constant name = "Bridge";
BridgeLogic private logic;
uint256 public swapFee;
address public feeTo;
struct assetSelector {
string selector;
bool isValueFirst;
}
mapping(address => assetSelector) public depositSelector;
mapping(address => assetSelector) public withdrawSelector;
mapping(bytes32 => bool) public filledTx;
event FeeToTransferred(address indexed previousFeeTo, address indexed newFeeTo);
event SwapFeeChanged(uint256 indexed previousSwapFee, uint256 indexed newSwapFee);
event DepositNative(address indexed from, uint256 value, string targetAddress, string chain, uint256 feeValue);
event DepositToken(address indexed from, uint256 value, address indexed token, string targetAddress, string chain, uint256 feeValue);
event WithdrawingNative(address indexed to, uint256 value, string proof);
event WithdrawingToken(address indexed to, address indexed token, uint256 value, string proof);
event WithdrawDoneNative(address indexed to, uint256 value, string proof);
event WithdrawDoneToken(address indexed to, address indexed token, uint256 value, string proof);
modifier onlyOperator() {
require(itemAddressExists(OPERATORHASH, msg.sender), "Bridge:wrong operator");
_;
}
modifier onlyPauser() {
require(itemAddressExists(PAUSERHASH, msg.sender), "Bridge:wrong pauser");
_;
}
modifier positiveValue(uint _value) {
require(_value > 0, "Bridge:value need > 0");
_;
}
constructor(address[] memory _owners, uint _ownerRequired) {
initAdmin(_owners, _ownerRequired);
}
function depositNative(string memory _targetAddress, string memory chain) public payable {
require(msg.value >= swapFee, "Bridge:insufficient swap fee");
if (swapFee != 0) {
payable(feeTo).transfer(swapFee);
}
emit DepositNative(msg.sender, msg.value - swapFee, _targetAddress, chain, swapFee);
}
function depositToken(address _token, uint value, string memory _targetAddress, string memory chain) public payable returns (bool) {
require(msg.value == swapFee, "Bridge:swap fee not equal");
if (swapFee != 0) {
payable(feeTo).transfer(swapFee);
}
bool res = depositTokenLogic(_token, msg.sender, value);
emit DepositToken(msg.sender, value, _token, _targetAddress, chain, swapFee);
return res;
}
function withdrawNative(address payable to, uint value, string memory proof, bytes32 taskHash) public
onlyOperator
whenNotPaused
positiveValue(value)
returns (bool)
{
require(address(this).balance >= value, "Bridge:not enough native token");
require(taskHash == keccak256((abi.encodePacked(to, value, proof))), "Bridge:taskHash is wrong");
require(!filledTx[taskHash], "Bridge:tx filled already");
uint256 status = logic.supportTask(logic.WITHDRAWTASK(), taskHash, msg.sender, operatorRequireNum);
if (status == logic.TASKPROCESSING()) {
emit WithdrawingNative(to, value, proof);
} else if (status == logic.TASKDONE()) {
emit WithdrawingNative(to, value, proof);
emit WithdrawDoneNative(to, value, proof);
to.transfer(value);
filledTx[taskHash] = true;
logic.removeTask(taskHash);
}
return true;
}
function withdrawToken(address _token, address to, uint value, string memory proof, bytes32 taskHash) public
onlyOperator
whenNotPaused
positiveValue(value)
returns (bool)
{
require(taskHash == keccak256((abi.encodePacked(to, value, proof))), "Bridge:taskHash is wrong");
require(!filledTx[taskHash], "Bridge:tx filled already");
uint256 status = logic.supportTask(logic.WITHDRAWTASK(), taskHash, msg.sender, operatorRequireNum);
if (status == logic.TASKPROCESSING()) {
emit WithdrawingToken(to, _token, value, proof);
} else if (status == logic.TASKDONE()) {
bool res = withdrawTokenLogic(_token, to, value);
emit WithdrawingToken(to, _token, value, proof);
emit WithdrawDoneToken(to, _token, value, proof);
filledTx[taskHash] = true;
logic.removeTask(taskHash);
return res;
}
return true;
}
function modifyAdminAddress(string memory class, address oldAddress, address newAddress) public whenPaused {
require(newAddress != address(0x0), "Bridge:wrong address");
bool flag = modifyAddress(class, oldAddress, newAddress);
if (flag) {
bytes32 classHash = keccak256(abi.encodePacked(class));
if (classHash == LOGICHASH) {
logic = BridgeLogic(newAddress);
} else if (classHash == STOREHASH) {
logic.resetStoreLogic(newAddress);
}
}
}
function getLogicAddress() public view returns (address) {
return address(logic);
}
function getStoreAddress() public view returns (address) {
return logic.getStoreAddress();
}
function pause() public onlyPauser {
_pause();
}
function unpause() public onlyPauser {
_unpause();
}
function setDepositSelector(address token, string memory method, bool _isValueFirst) onlyOperator external {
depositSelector[token] = assetSelector(method, _isValueFirst);
}
function setWithdrawSelector(address token, string memory method, bool _isValueFirst) onlyOperator external {
withdrawSelector[token] = assetSelector(method, _isValueFirst);
}
function setSwapFee(uint256 _swapFee) onlyOwner external {
emit SwapFeeChanged(swapFee, _swapFee);
swapFee = _swapFee;
}
function setFeeTo(address _feeTo) onlyOwner external {
emit FeeToTransferred(feeTo, _feeTo);
feeTo = _feeTo;
}
function depositTokenLogic(address token, address _from, uint256 _value) internal returns (bool) {
bool status = false;
bytes memory returnedData;
if (bytes(depositSelector[token].selector).length == 0) {
(status, returnedData) = token.call(abi.encodeWithSignature("transferFrom(address,address,uint256)", _from, this, _value));
}
else {
assetSelector memory aselector = depositSelector[token];
if (aselector.isValueFirst) {
(status, returnedData) = token.call(abi.encodeWithSignature(aselector.selector, _value, _from));
}
else {
(status, returnedData) = token.call(abi.encodeWithSignature(aselector.selector, _from, _value));
}
}
require(status && (returnedData.length == 0 || abi.decode(returnedData, (bool))), 'Bridge:deposit failed');
return true;
}
function withdrawTokenLogic(address token, address _to, uint256 _value) internal returns (bool) {
bool status = false;
bytes memory returnedData;
if (bytes(withdrawSelector[token].selector).length == 0) {
(status, returnedData) = token.call(abi.encodeWithSignature("transfer(address,uint256)", _to, _value));
}
else {
assetSelector memory aselector = withdrawSelector[token];
if (aselector.isValueFirst) {
(status, returnedData) = token.call(abi.encodeWithSignature(aselector.selector, _value, _to));
}
else {
(status, returnedData) = token.call(abi.encodeWithSignature(aselector.selector, _to, _value));
}
}
require(status && (returnedData.length == 0 || abi.decode(returnedData, (bool))), 'Bridge:withdraw failed');
return true;
}
}
Read Contract
depositSelector 0xf60c757f → string, bool
feeTo 0x017e7e58 → address
filledTx 0x64908649 → bool
getAdminAddresses 0xc8e369bf → address[]
getLogicAddress 0xabd108ba → address
getOperatorRequireNum 0x1d75807c → uint256
getOwnerRequireNum 0xe6a81ec4 → uint256
getStoreAddress 0xb07ed3a9 → address
name 0x06fdde03 → string
paused 0x5c975abb → bool
swapFee 0x54cf2aeb → uint256
withdrawSelector 0xcb08e3ca → string, bool
Write Contract 15 functions
These functions modify contract state and require a wallet transaction to execute.
addAddress 0xceb35b0f
string class
address oneAddress
returns: bool
depositNative 0x8609d28c
string _targetAddress
string chain
depositToken 0xdd9b86c1
address _token
uint256 value
string _targetAddress
string chain
returns: bool
dropAddress 0x91c40bf7
string class
address oneAddress
returns: bool
dropTask 0x521cb590
bytes32 taskHash
returns: bool
modifyAdminAddress 0x2c2df742
string class
address oldAddress
address newAddress
pause 0x8456cb59
No parameters
resetRequiredNum 0xe9e211bd
string class
uint256 requiredNum
returns: bool
setDepositSelector 0x00674f63
address token
string method
bool _isValueFirst
setFeeTo 0xf46901ed
address _feeTo
setSwapFee 0x34e19907
uint256 _swapFee
setWithdrawSelector 0xc8fd90f9
address token
string method
bool _isValueFirst
unpause 0x3f4ba83a
No parameters
withdrawNative 0xd5b99d3c
address to
uint256 value
string proof
bytes32 taskHash
returns: bool
withdrawToken 0x02c1927c
address _token
address to
uint256 value
string proof
bytes32 taskHash
returns: bool
Token Balances (7)
View Transfers →Recent Transactions
No transactions found for this address