Source Code
Overview
ETH Balance
0 ETH
Eth Value
$0.00Loading...
Loading
Loading...
Loading
Cross-Chain Transactions
Loading...
Loading
Contract Name:
TxRelay
Compiler Version
v0.4.15+commit.bbb8e64f
Optimization Enabled:
Yes with 200 runs
Other Settings:
default evmVersion
Contract Source Code (Solidity)
/**
*Submitted for verification at Etherscan.io on 2017-11-27
*/
pragma solidity 0.4.15;
// This contract is meant as a "singleton" forwarding contract.
// Eventually, it will be able to forward any transaction to
// Any contract that is built to accept it.
contract TxRelay {
// Note: This is a local nonce.
// Different from the nonce defined w/in protocol.
mapping(address => uint) nonce;
// This mapping specifies a whitelist of allowed senders for transactions.
// There can be one whitelist per ethereum account, which is the owner of that
// whitelist. Users can specify which whitelist they want to use when signing
// a transaction. They can use their own whitelist, a whitelist belonging
// to another account, or skip using a whitelist by specifying the zero address.
mapping(address => mapping(address => bool)) public whitelist;
/*
* @dev Relays meta transactions
* @param sigV, sigR, sigS ECDSA signature on some data to be forwarded
* @param destination Location the meta-tx should be forwarded to
* @param data The bytes necessary to call the function in the destination contract.
* Note: The first encoded argument in data must be address of the signer. This means
* that all functions called from this relay must take an address as the first parameter.
*/
function relayMetaTx(
uint8 sigV,
bytes32 sigR,
bytes32 sigS,
address destination,
bytes data,
address listOwner
) public {
// only allow senders from the whitelist specified by the user,
// 0x0 means no whitelist.
require(listOwner == 0x0 || whitelist[listOwner][msg.sender]);
address claimedSender = getAddress(data);
// use EIP 191
// 0x19 :: version :: relay :: whitelistOwner :: nonce :: destination :: data
bytes32 h = keccak256(byte(0x19), byte(0), this, listOwner, nonce[claimedSender], destination, data);
address addressFromSig = ecrecover(h, sigV, sigR, sigS);
require(claimedSender == addressFromSig);
nonce[claimedSender]++; //if we are going to do tx, update nonce
require(destination.call(data));
}
/*
* @dev Gets an address encoded as the first argument in transaction data
* @param b The byte array that should have an address as first argument
* @returns a The address retrieved from the array
(Optimization based on work by tjade273)
*/
function getAddress(bytes b) public constant returns (address a) {
if (b.length < 36) return address(0);
assembly {
let mask := 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
a := and(mask, mload(add(b, 36)))
// 36 is the offset of the first parameter of the data, if encoded properly.
// 32 bytes for the length of the bytes array, and 4 bytes for the function signature.
}
}
/*
* @dev Returns the local nonce of an account.
* @param add The address to return the nonce for.
* @return The specific-to-this-contract nonce of the address provided
*/
function getNonce(address add) public constant returns (uint) {
return nonce[add];
}
/*
* @dev Adds a number of addresses to a specific whitelist. Only
* the owner of a whitelist can add to it.
* @param sendersToUpdate the addresses to add to the whitelist
*/
function addToWhitelist(address[] sendersToUpdate) public {
updateWhitelist(sendersToUpdate, true);
}
/*
* @dev Removes a number of addresses from a specific whitelist. Only
* the owner of a whitelist can remove from it.
* @param sendersToUpdate the addresses to add to the whitelist
*/
function removeFromWhitelist(address[] sendersToUpdate) public {
updateWhitelist(sendersToUpdate, false);
}
/*
* @dev Internal logic to update a whitelist
* @param sendersToUpdate the addresses to add to the whitelist
* @param newStatus whether to add or remove addresses
*/
function updateWhitelist(address[] sendersToUpdate, bool newStatus) private {
for (uint i = 0; i < sendersToUpdate.length; i++) {
whitelist[msg.sender][sendersToUpdate[i]] = newStatus;
}
}
}Contract Security Audit
- No Contract Security Audit Submitted- Submit Audit Here
Contract ABI
API[{"constant":true,"inputs":[{"name":"add","type":"address"}],"name":"getNonce","outputs":[{"name":"","type":"uint256"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"sendersToUpdate","type":"address[]"}],"name":"removeFromWhitelist","outputs":[],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"sendersToUpdate","type":"address[]"}],"name":"addToWhitelist","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"","type":"address"},{"name":"","type":"address"}],"name":"whitelist","outputs":[{"name":"","type":"bool"}],"payable":false,"type":"function"},{"constant":false,"inputs":[{"name":"sigV","type":"uint8"},{"name":"sigR","type":"bytes32"},{"name":"sigS","type":"bytes32"},{"name":"destination","type":"address"},{"name":"data","type":"bytes"},{"name":"listOwner","type":"address"}],"name":"relayMetaTx","outputs":[],"payable":false,"type":"function"},{"constant":true,"inputs":[{"name":"b","type":"bytes"}],"name":"getAddress","outputs":[{"name":"a","type":"address"}],"payable":false,"type":"function"}]Contract Creation Code
6060604052341561000f57600080fd5b5b6106338061001f6000396000f300606060405236156100755763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632d0335ab811461007a578063548db174146100ab5780637f649783146100fc578063b092145e1461014d578063c3f44c0a14610186578063c47cf5de14610203575b600080fd5b341561008557600080fd5b610099600160a060020a0360043516610270565b60405190815260200160405180910390f35b34156100b657600080fd5b6100fa600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965061028f95505050505050565b005b341561010757600080fd5b6100fa600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965061029e95505050505050565b005b341561015857600080fd5b610172600160a060020a03600435811690602435166102ad565b604051901515815260200160405180910390f35b341561019157600080fd5b6100fa6004803560ff1690602480359160443591606435600160a060020a0316919060a49060843590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965050509235600160a060020a031692506102cd915050565b005b341561020e57600080fd5b61025460046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061056a95505050505050565b604051600160a060020a03909116815260200160405180910390f35b600160a060020a0381166000908152602081905260409020545b919050565b61029a816000610594565b5b50565b61029a816001610594565b5b50565b600160209081526000928352604080842090915290825290205460ff1681565b60008080600160a060020a038416158061030d5750600160a060020a038085166000908152600160209081526040808320339094168352929052205460ff165b151561031857600080fd5b6103218561056a565b600160a060020a038116600090815260208190526040808220549295507f19000000000000000000000000000000000000000000000000000000000000009230918891908b908b90517fff000000000000000000000000000000000000000000000000000000000000008089168252871660018201526c01000000000000000000000000600160a060020a038088168202600284015286811682026016840152602a8301869052841602604a820152605e810182805190602001908083835b6020831061040057805182525b601f1990920191602091820191016103e0565b6001836020036101000a0380198251168184511617909252505050919091019850604097505050505050505051809103902091506001828a8a8a6040516000815260200160405260006040516020015260405193845260ff90921660208085019190915260408085019290925260608401929092526080909201915160208103908084039060008661646e5a03f1151561049957600080fd5b5050602060405103519050600160a060020a03838116908216146104bc57600080fd5b600160a060020a0380841660009081526020819052604090819020805460010190559087169086905180828051906020019080838360005b8381101561050d5780820151818401525b6020016104f4565b50505050905090810190601f16801561053a5780820380516001836020036101000a031916815260200191505b5091505060006040518083038160008661646e5a03f1915050151561055e57600080fd5b5b505050505050505050565b600060248251101561057e5750600061028a565b600160a060020a0360248301511690505b919050565b60005b825181101561060157600160a060020a033316600090815260016020526040812083918584815181106105c657fe5b90602001906020020151600160a060020a031681526020810191909152604001600020805460ff19169115159190911790555b600101610597565b5b5050505600a165627a7a723058200027e8b695e9d2dea9f3629519022a69f3a1d23055ce86406e686ea54f31ee9c0029
Deployed Bytecode
0x606060405236156100755763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632d0335ab811461007a578063548db174146100ab5780637f649783146100fc578063b092145e1461014d578063c3f44c0a14610186578063c47cf5de14610203575b600080fd5b341561008557600080fd5b610099600160a060020a0360043516610270565b60405190815260200160405180910390f35b34156100b657600080fd5b6100fa600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965061028f95505050505050565b005b341561010757600080fd5b6100fa600460248135818101908301358060208181020160405190810160405280939291908181526020018383602002808284375094965061029e95505050505050565b005b341561015857600080fd5b610172600160a060020a03600435811690602435166102ad565b604051901515815260200160405180910390f35b341561019157600080fd5b6100fa6004803560ff1690602480359160443591606435600160a060020a0316919060a49060843590810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965050509235600160a060020a031692506102cd915050565b005b341561020e57600080fd5b61025460046024813581810190830135806020601f8201819004810201604051908101604052818152929190602084018383808284375094965061056a95505050505050565b604051600160a060020a03909116815260200160405180910390f35b600160a060020a0381166000908152602081905260409020545b919050565b61029a816000610594565b5b50565b61029a816001610594565b5b50565b600160209081526000928352604080842090915290825290205460ff1681565b60008080600160a060020a038416158061030d5750600160a060020a038085166000908152600160209081526040808320339094168352929052205460ff165b151561031857600080fd5b6103218561056a565b600160a060020a038116600090815260208190526040808220549295507f19000000000000000000000000000000000000000000000000000000000000009230918891908b908b90517fff000000000000000000000000000000000000000000000000000000000000008089168252871660018201526c01000000000000000000000000600160a060020a038088168202600284015286811682026016840152602a8301869052841602604a820152605e810182805190602001908083835b6020831061040057805182525b601f1990920191602091820191016103e0565b6001836020036101000a0380198251168184511617909252505050919091019850604097505050505050505051809103902091506001828a8a8a6040516000815260200160405260006040516020015260405193845260ff90921660208085019190915260408085019290925260608401929092526080909201915160208103908084039060008661646e5a03f1151561049957600080fd5b5050602060405103519050600160a060020a03838116908216146104bc57600080fd5b600160a060020a0380841660009081526020819052604090819020805460010190559087169086905180828051906020019080838360005b8381101561050d5780820151818401525b6020016104f4565b50505050905090810190601f16801561053a5780820380516001836020036101000a031916815260200191505b5091505060006040518083038160008661646e5a03f1915050151561055e57600080fd5b5b505050505050505050565b600060248251101561057e5750600061028a565b600160a060020a0360248301511690505b919050565b60005b825181101561060157600160a060020a033316600090815260016020526040812083918584815181106105c657fe5b90602001906020020151600160a060020a031681526020810191909152604001600020805460ff19169115159190911790555b600101610597565b5b5050505600a165627a7a723058200027e8b695e9d2dea9f3629519022a69f3a1d23055ce86406e686ea54f31ee9c0029
Swarm Source
bzzr://0027e8b695e9d2dea9f3629519022a69f3a1d23055ce86406e686ea54f31ee9c
Loading...
Loading
Loading...
Loading
Net Worth in USD
$0.00
Net Worth in ETH
0
Multichain Portfolio | 33 Chains
| Chain | Token | Portfolio % | Price | Amount | Value |
|---|
Loading...
Loading
Loading...
Loading
Loading...
Loading
A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.