Permalink
Cannot retrieve contributors at this time
Name already in use
A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
ens/contracts/FIFSRegistrar.sol
Go to fileThis commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
36 lines (31 sloc)
1008 Bytes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pragma solidity ^0.7.0; | |
import "./ENS.sol"; | |
/** | |
* A registrar that allocates subdomains to the first person to claim them. | |
*/ | |
contract FIFSRegistrar { | |
ENS ens; | |
bytes32 rootNode; | |
modifier only_owner(bytes32 label) { | |
address currentOwner = ens.owner(keccak256(abi.encodePacked(rootNode, label))); | |
require(currentOwner == address(0x0) || currentOwner == msg.sender); | |
_; | |
} | |
/** | |
* Constructor. | |
* @param ensAddr The address of the ENS registry. | |
* @param node The node that this registrar administers. | |
*/ | |
constructor(ENS ensAddr, bytes32 node) public { | |
ens = ensAddr; | |
rootNode = node; | |
} | |
/** | |
* Register a name, or change the owner of an existing registration. | |
* @param label The hash of the label to register. | |
* @param owner The address of the new owner. | |
*/ | |
function register(bytes32 label, address owner) public only_owner(label) { | |
ens.setSubnodeOwner(rootNode, label, owner); | |
} | |
} |