Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
pragma solidity ^0.5.0;
import './ENS.sol';
library BytesUtils {
* @dev Returns the 32 byte value at the specified index of self.
* @param self The byte string.
* @param idx The index into the bytes
* @return The specified 32 bytes of the string.
function readBytes32(bytes memory self, uint idx) internal pure returns (bytes32 ret) {
require(idx + 32 <= self.length);
assembly {
ret := mload(add(add(self, 32), idx))
contract ResolverProxy {
ENS public ens;
using BytesUtils for bytes;
constructor(ENS _ens) public {
ens = _ens;
function() external {
bytes memory data =;
// First call argument is the namehash
bytes32 node = data.readBytes32(4);
address resolver = ens.resolver(node);
// Proxy the call to the resolver
(bool success, bytes memory ret) = resolver.staticcall(data);
// Return exactly what the resolver returned.
assembly {
return(add(ret, 32), mload(ret))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.