Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@Arachnid
Created October 31, 2019 19:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save Arachnid/fef0257345a2279924dfbb8074407de0 to your computer and use it in GitHub Desktop.
Save Arachnid/fef0257345a2279924dfbb8074407de0 to your computer and use it in GitHub Desktop.
contract Registrar is Owned {
ENS public ens;
mapping(address=>boolean) public controllers;
constructor(ENS _ens) public {
ens = _ens;
setController(msg.sender, true);
}
function setController(address controller, boolean isController) ownerOnly {
controllers[controller] = isController;
}
modifier controllerOnly {
require(controllers[msg.sender]);
_;
}
function setSubnodeOwner(bytes32 node, bytes32 label, address owner) controllerOnly {
require(ens.owner(keccak256(abi.encodePacked(node, label))) == address(0));
ens.setSubnodeOwner(node, label, owner);
}
function setResolver(bytes32 node, address resolver) controllerOnly {
ens.setResolver(node, resolver);
}
function setTTL(bytes32 node, uint ttl) controllerOnly {
ens.setTTL(node, ttl);
}
function setOwner(bytes32 node, address owner) controllerOnly {
ens.setOwner(node, owner);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment