Address Details
contract

0x6A92e97A568f5F58590E8b1f56484e6268CdDC51

Erc20ToNativeBridgeHelper Last Balance Update: Block #18273048
Created by 0xe4c282–640c33 at 0xa734cb–1849ea

Balance

0 xDAI

(@ /xDAI)

Fetching tokens...

Contract name:
Erc20ToNativeBridgeHelper




Optimization enabled
true
Compiler version
v0.6.12+commit.27d51765




Optimization runs
200
EVM Version
default




Verified at
2020-10-07 20:13:25.835426Z

Constructor Arguments

0000000000000000000000007301cfa0e1756b71869e93d4e4dca5c7d0eb0aa60000000000000000000000004aa42145aa6ebf72e164c9bbc74fbd3788045016

Arg [0] (address) : 0x7301cfa0e1756b71869e93d4e4dca5c7d0eb0aa6
Arg [1] (address) : 0x4aa42145aa6ebf72e164c9bbc74fbd3788045016

              

Contract source code

pragma solidity 0.6.12;
abstract contract IHomeErc20ToNativeBridge {
function numMessagesSigned(bytes32 _message) public view virtual returns (uint256);
function isAlreadyProcessed(uint256 _number) public pure virtual returns (bool);
function message(bytes32 _hash) external view virtual returns (bytes memory);
function signature(bytes32 _hash, uint256 _index) external view virtual returns (bytes memory);
}
contract Helper {
function unpackSignature(bytes memory _signature) internal pure returns (bytes32, bytes32, bytes1)
{
require(_signature.length == 65);
bytes32 r;
bytes32 s;
bytes1 v;
assembly {
r := mload(add(_signature, 0x20))
s := mload(add(_signature, 0x40))
v := mload(add(_signature, 0x60))
}
return (r, s, v);
}
}
contract Erc20ToNativeBridgeHelper is Helper {
address payable owner;
IHomeErc20ToNativeBridge public bridge;
address foreignBridge;
constructor (address _homeBridge, address _foreignBridge) public {
owner = msg.sender;
bridge = IHomeErc20ToNativeBridge(_homeBridge);
foreignBridge = _foreignBridge;
}
function getMessage(bytes32 _msgHash) public view returns(bytes memory result) {
result = bridge.message(_msgHash);
}
function getMessageHash(address _recipient, uint256 _value, bytes32 _origTxHash) public view returns(bytes32) {
bytes32 result = keccak256(abi.encodePacked(_recipient, _value, _origTxHash, foreignBridge));
return result;
}
function getSignatures(bytes32 _msgHash) public view returns(bytes memory) {
uint256 signed = bridge.numMessagesSigned(_msgHash);
require(bridge.isAlreadyProcessed(signed), "message hasn't been confirmed");
// recover number of confirmations sent by oracles
signed = signed & 0x8fffffffffffffffffffffffffffffffffffffffffff;
// !!!WARNING!!!
// This particular helper works only with 3 signatures collected on the xDai bridge
// If the configuration of the bridge is changed, another helper must be prepared
require(signed == 3, "3 confirmations expected");
bytes32 r0; bytes32 r1; bytes32 r2;
bytes32 s0; bytes32 s1; bytes32 s2;
bytes1 v0; bytes1 v1; bytes1 v2;
bytes memory sig = bridge.signature(_msgHash, 0);
(r0, s0, v0) = unpackSignature(sig);
sig = bridge.signature(_msgHash, 1);
(r1, s1, v1) = unpackSignature(sig);
sig = bridge.signature(_msgHash, 2);
(r2, s2, v2) = unpackSignature(sig);
return(abi.encodePacked(uint8(3), v0, v1, v2, r0, r1, r2, s0, s1, s2));
}
function clean() external {
require(msg.sender == owner, "not an owner");
selfdestruct(owner);
}
}

Contract ABI

[{"type":"constructor","stateMutability":"nonpayable","inputs":[{"type":"address","name":"_homeBridge","internalType":"address"},{"type":"address","name":"_foreignBridge","internalType":"address"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"address","name":"","internalType":"contract IHomeErc20ToNativeBridge"}],"name":"bridge","inputs":[]},{"type":"function","stateMutability":"nonpayable","outputs":[],"name":"clean","inputs":[]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"result","internalType":"bytes"}],"name":"getMessage","inputs":[{"type":"bytes32","name":"_msgHash","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes32","name":"","internalType":"bytes32"}],"name":"getMessageHash","inputs":[{"type":"address","name":"_recipient","internalType":"address"},{"type":"uint256","name":"_value","internalType":"uint256"},{"type":"bytes32","name":"_origTxHash","internalType":"bytes32"}]},{"type":"function","stateMutability":"view","outputs":[{"type":"bytes","name":"","internalType":"bytes"}],"name":"getSignatures","inputs":[{"type":"bytes32","name":"_msgHash","internalType":"bytes32"}]}]
            

Deployed ByteCode

0x608060405234801561001057600080fd5b50600436106100575760003560e01c80630139a2211461005c57806330322ce7146100ee5780639bc5106814610132578063e78cea921461014f578063fc4333cd14610173575b600080fd5b6100796004803603602081101561007257600080fd5b503561017d565b6040805160208082528351818301528351919283929083019185019080838360005b838110156100b357818101518382015260200161009b565b50505050905090810190601f1680156100e05780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b6101206004803603606081101561010457600080fd5b506001600160a01b0381351690602081013590604001356102bb565b60408051918252519081900360200190f35b6100796004803603602081101561014857600080fd5b5035610315565b610157610969565b604080516001600160a01b039092168252519081900360200190f35b61017b610978565b005b60015460408051632485196360e11b81526004810184905290516060926001600160a01b03169163490a32c6916024808301926000929190829003018186803b1580156101c957600080fd5b505afa1580156101dd573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561020657600080fd5b8101908080516040519392919084600160201b82111561022557600080fd5b90830190602082018581111561023a57600080fd5b8251600160201b81118282018810171561025357600080fd5b82525081516020918201929091019080838360005b83811015610280578181015183820152602001610268565b50505050905090810190601f1680156102ad5780820380516001836020036101000a031916815260200191505b506040525050509050919050565b600254604080516bffffffffffffffffffffffff19606087811b8216602080850191909152603484018890526054840187905294901b16607482015281516068818303018152608890910190915280519101209392505050565b60015460408051630cbf060160e01b81526004810184905290516060926000926001600160a01b0390911691630cbf060191602480820192602092909190829003018186803b15801561036757600080fd5b505afa15801561037b573d6000803e3d6000fd5b505050506040513d602081101561039157600080fd5b5051600154604080516001620b985d60e21b031981526004810184905290519293506001600160a01b039091169163ffd19e8c91602480820192602092909190829003018186803b1580156103e557600080fd5b505afa1580156103f9573d6000803e3d6000fd5b505050506040513d602081101561040f57600080fd5b5051610462576040805162461bcd60e51b815260206004820152601d60248201527f6d657373616765206861736e2774206265656e20636f6e6669726d6564000000604482015290519081900360640190fd5b6001600960ac1b0316600381146104c0576040805162461bcd60e51b815260206004820152601860248201527f3320636f6e6669726d6174696f6e732065787065637465640000000000000000604482015290519081900360640190fd5b60008060008060008060008060006060600160009054906101000a90046001600160a01b03166001600160a01b0316631812d9968e60006040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b15801561053257600080fd5b505afa158015610546573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561056f57600080fd5b8101908080516040519392919084600160201b82111561058e57600080fd5b9083019060208201858111156105a357600080fd5b8251600160201b8111828201881017156105bc57600080fd5b82525081516020918201929091019080838360005b838110156105e95781810151838201526020016105d1565b50505050905090810190601f1680156106165780820380516001836020036101000a031916815260200191505b506040525050509050610628816109d4565b809650819950829c50505050600160009054906101000a90046001600160a01b03166001600160a01b0316631812d9968e60016040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b15801561069657600080fd5b505afa1580156106aa573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f1916820160405260208110156106d357600080fd5b8101908080516040519392919084600160201b8211156106f257600080fd5b90830190602082018581111561070757600080fd5b8251600160201b81118282018810171561072057600080fd5b82525081516020918201929091019080838360005b8381101561074d578181015183820152602001610735565b50505050905090810190601f16801561077a5780820380516001836020036101000a031916815260200191505b50604052505050905061078c816109d4565b809550819850829b50505050600160009054906101000a90046001600160a01b03166001600160a01b0316631812d9968e60026040518363ffffffff1660e01b8152600401808381526020018281526020019250505060006040518083038186803b1580156107fa57600080fd5b505afa15801561080e573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561083757600080fd5b8101908080516040519392919084600160201b82111561085657600080fd5b90830190602082018581111561086b57600080fd5b8251600160201b81118282018810171561088457600080fd5b82525081516020918201929091019080838360005b838110156108b1578181015183820152602001610899565b50505050905090810190601f1680156108de5780820380516001836020036101000a031916815260200191505b5060405250505090506108f0816109d4565b60408051600360f81b60208201526001600160f81b03199889166021820152968816602288015296166023860152602485019b909b5260448401999099525050606481019690965260848601939093525060a484015260c4808401949094528051808403909401845260e4909201909152509392505050565b6001546001600160a01b031681565b6000546001600160a01b031633146109c6576040805162461bcd60e51b815260206004820152600c60248201526b3737ba1030b71037bbb732b960a11b604482015290519081900360640190fd5b6000546001600160a01b0316ff5b600080600083516041146109e757600080fd5b50505060208101516040820151606090920151909256fea2646970667358221220dc8c39c46e4aa9818427b9ffaa54ad54d5b2ce7ea997fd4a2f9382b6ee605ba864736f6c634300060c0033