aboutsummaryrefslogtreecommitdiffstats
path: root/contracts/ens/contract/FIFSRegistrar.sol
diff options
context:
space:
mode:
Diffstat (limited to 'contracts/ens/contract/FIFSRegistrar.sol')
-rw-r--r--contracts/ens/contract/FIFSRegistrar.sol39
1 files changed, 39 insertions, 0 deletions
diff --git a/contracts/ens/contract/FIFSRegistrar.sol b/contracts/ens/contract/FIFSRegistrar.sol
new file mode 100644
index 000000000..51629c2b6
--- /dev/null
+++ b/contracts/ens/contract/FIFSRegistrar.sol
@@ -0,0 +1,39 @@
+pragma solidity ^0.4.0;
+
+import './AbstractENS.sol';
+
+/**
+ * A registrar that allocates subdomains to the first person to claim them.
+ */
+contract FIFSRegistrar {
+ AbstractENS ens;
+ bytes32 rootNode;
+
+ modifier only_owner(bytes32 subnode) {
+ var node = sha3(rootNode, subnode);
+ var currentOwner = ens.owner(node);
+
+ if (currentOwner != 0 && currentOwner != msg.sender) throw;
+
+ _;
+ }
+
+ /**
+ * Constructor.
+ * @param ensAddr The address of the ENS registry.
+ * @param node The node that this registrar administers.
+ */
+ function FIFSRegistrar(AbstractENS ensAddr, bytes32 node) {
+ ens = ensAddr;
+ rootNode = node;
+ }
+
+ /**
+ * Register a name, or change the owner of an existing registration.
+ * @param subnode The hash of the label to register.
+ * @param owner The address of the new owner.
+ */
+ function register(bytes32 subnode, address owner) only_owner(subnode) {
+ ens.setSubnodeOwner(rootNode, subnode, owner);
+ }
+}