Skip to content

Instantly share code, notes, and snippets.

@PeterBorah
Created January 11, 2017 03:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PeterBorah/61dc14136b4a57359ddab044bce35a9f to your computer and use it in GitHub Desktop.
Save PeterBorah/61dc14136b4a57359ddab044bce35a9f to your computer and use it in GitHub Desktop.
pragma solidity ^0.4.7;
import "./Resolver.sol";
contract EtherRouter {
Resolver resolver;
function EtherRouter(Resolver _resolver) {
resolver = _resolver;
}
function() {
uint r;
// Get routing information for the called function
var (destination, outsize) = resolver.lookup(msg.sig, msg.data);
// Make the call
assembly {
calldatacopy(mload(0x40), 0, calldatasize)
r := delegatecall(sub(gas, 700), destination, mload(0x40), calldatasize, mload(0x40), outsize)
}
// Throw if the call failed
if (r != 1) { throw;}
// Pass on the return value
assembly {
return(mload(0x40), outsize)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment