Contracts
ERSRegistry

Solidity API

ERSRegistry

Fork of ENSRegistry with adapted data structures and accessibility logic in order to conform to the needs of ERS. Node owners can create any subnode. A node tracks the owner of the node and the address the node resolves to. Within the context of ERS, a resolver represents either a smart contract OR a chip. The owner has the ability to create any subnodes of its choosing; however, only the DeveloperRegistry is able to change both the owner and the resolver for a given node once created. The ChipRegistry is able to change the owner of a node (signifying a transfer of a chip) but is not able to change the resolver. These permissions are put in place to maintain a track record of authenticity for chips while allowing the DeveloperRegistry to re-assign sub-domains to new DeveloperRegistrars. Note that if a DeveloperRegistry's subnode is reassigned to a new DeveloperRegistrar, the new DeveloperRegistrar CANNOT overwrite the nodes created by the previous node owner.

NewOwner

event NewOwner(bytes32 node, bytes32 subnode, bytes32 nameHash, address owner)

Transfer

event Transfer(bytes32 node, address owner)

NewResolver

event NewResolver(bytes32 node, address resolver)

Record

struct Record {
  address owner;
  address resolver;
}

authorised

modifier authorised(bytes32 _node)

chipRegistry

contract IChipRegistry chipRegistry

developerRegistry

contract IDeveloperRegistry developerRegistry

records

mapping(bytes32 => struct ERSRegistry.Record) records

constructor

constructor(contract IChipRegistry _chipRegistry, contract IDeveloperRegistry _developerRegistry) public

Constructs a new ERS registry.

Parameters

NameTypeDescription
_chipRegistrycontract IChipRegistryAddress of the ChipRegistry contract
_developerRegistrycontract IDeveloperRegistryAddress of the DeveloperRegistry contract

createSubnodeRecord

function createSubnodeRecord(bytes32 _node, bytes32 _nameHash, address _owner, address _resolver) external virtual returns (bytes32)

Sets the record for a new subnode. May only be called by the owner of the node (checked in _setSubnodeOwner).

Parameters

NameTypeDescription
_nodebytes32The parent node.
_nameHashbytes32The hash of the nameHash specifying the subnode.
_owneraddressThe address of the new owner.
_resolveraddressThe address of the resolver.

Return Values

NameTypeDescription
[0]bytes32The newly created subnode hash

deleteSubnodeRecord

function deleteSubnodeRecord(bytes32 _node, bytes32 _nameHash) external virtual

ONLY Developer REGISTRY: Deletes the record for an already created subnode.

Parameters

NameTypeDescription
_nodebytes32The parent node.
_nameHashbytes32The hash of the nameHash specifying the subnode.

setNodeOwner

function setNodeOwner(bytes32 _node, address _newOwner) external virtual

ONLY CHIP REGISTRY: Transfers ownership of a node to a new address.

Parameters

NameTypeDescription
_nodebytes32The node to transfer ownership of.
_newOwneraddressThe address of the new owner.

isValidChipState

function isValidChipState(bytes32 _node, address _chipId, address _owner) external view virtual returns (bool)

Validate that state has been correctly set for a chip. Used by ChipRegistry to validate that a ProjectRegistrar has set the correct state for a chip.

Parameters

NameTypeDescription
_nodebytes32The specified node.
_chipIdaddressThe specified chipId.
_owneraddressThe specified owner.

Return Values

NameTypeDescription
[0]boolbool indicating whether the state is valid

getOwner

function getOwner(bytes32 _node) public view virtual returns (address)

Returns the address that owns the specified node.

Parameters

NameTypeDescription
_nodebytes32The specified node.

Return Values

NameTypeDescription
[0]addressAddress of the owner.

getSubnodeOwner

function getSubnodeOwner(bytes32 _node, bytes32 _nameHash) external view virtual returns (address)

Returns the address that owns the specified subnode.

Parameters

NameTypeDescription
_nodebytes32The specified node.
_nameHashbytes32The specified nameHash.

Return Values

NameTypeDescription
[0]addressAddress of the owner.

getResolver

function getResolver(bytes32 _node) external view virtual returns (address)

Returns the address of the resolver for the specified node.

Parameters

NameTypeDescription
_nodebytes32The specified node.

Return Values

NameTypeDescription
[0]addressAddress of the resolver.

recordExists

function recordExists(bytes32 _node) public view virtual returns (bool)

Returns whether a record has been written to the registry for that node.

Parameters

NameTypeDescription
_nodebytes32The specified node.

Return Values

NameTypeDescription
[0]boolBool indicating if a record exists

getSubnodeHash

function getSubnodeHash(bytes32 _node, bytes32 _nameHash) external pure returns (bytes32)

Returns the subnode hash of node + nameHash.

Parameters

NameTypeDescription
_nodebytes32The specified node.
_nameHashbytes32The specified nameHash.

Return Values

NameTypeDescription
[0]bytes32The subnode hash

_calculateSubnode

function _calculateSubnode(bytes32 _node, bytes32 _nameHash) internal pure returns (bytes32)

_setOwner

function _setOwner(bytes32 node, address owner) internal virtual

_setResolver

function _setResolver(bytes32 _node, address _resolver) internal virtual