Public Resolver
Last updated
Last updated
description |
---|
PublicResolver implements a general-purpose ETHW ID resolver that is suitable for most standard ETHW ID use-cases. The public resolver permits updates to ETHW ID records by the owner of the corresponding name.
The public resolver implements the following EIPs:
EIP 137 - Contract address interface (addr()
).
EIP 165 - Interface Detection (supportsInterface()
).
EIP 181 - Reverse resolution (name()
).
EIP 205 - ABI support (ABI()
).
EIP 619 - SECP256k1 public keys (pubkey()
).
EIP 634 - Text records (text()
).
EIP 1577 - Content hash support (contenthash()
).
EIP 2304 - Multicoin support (addr()
).
{% hint style="warning" %} While the PublicResolver
provides a convenient default implementation, many resolver implementations and versions exist. Callers must not assume that a domain uses the current version of the public resolver, or that all of the methods described here are present. To check if a resolver supports a feature, see Check Interface Support. {% endhint %}
ETHW ID uses ERC 165 for interface detection. ERC 165 requires that supporting contracts implement a function, supportsInterface
, which takes an interface ID and returns a boolean value indicating if this interface is supported or not.
Interface IDs are calculated as the exclusive-or of the four-byte function identifiers of each function included in the interface. For example, addr(bytes32)
has the function ID 0x3b3b57de. Because it is the only function in the Ethereum Address interface, its interface ID is also 0x3b3b57de, and so calling supportsInterface(0x3b3b57de)
will return true for any resolver that supports addr()
.
ERC 165 has an interface ID of 0x01ffc9a7, so supportsInterface(0x01ffc9a7)
will always return true for any ERC 165 supporting contract (and hence for any resolver).
Note that the public resolver does not expose explicit interfaces for setter functions, so there are no automated means to check for support for a given setter function.
Returns the Ethereum address associated with the provided node
, or 0 if none.
This function has interface ID 0x3b3b57de.
This function is specified in EIP 137.
Sets the Ethereum address associated with the provided node
to addr
.
Only callable by the owner of node
.
Emits the following event:
Returns the Blockchain address associated with the provided node
and coinType
, or 0 if none.
This function has interface ID 0xf1cb7e06.
This function is specified in EIP 2304.
The return value is the cryptocurrency address in its native binary format and each blockchain address has a different encoding and decoding method.
For example, the Bitcoin address 1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa
base58check decodes to the 21 bytes 0062e907b15cbf27d5425399ebf6f0fb50ebb88f18
then scriptPubkey encodes to 25 bytes 76a91462e907b15cbf27d5425399ebf6f0fb50ebb88f1888ac
whereas the BNB address bnb1grpf0955h0ykzq3ar5nmum7y6gdfl6lxfn46h2
Bech32 decodes to the binary representation 40c2979694bbc961023d1d27be6fc4d21a9febe6
.
To convert the binary representation into the address, use formatsByCoinType[SYMBOL].encoder(binary)
of address-encoder.
A zero-length string will be returned if the specified coin ID does not exist on the specified node.
Sets the blockchain address associated with the provided node
and coinType
to addr
.
coinType
is the cryptocurrency coin type index from SLIP44.
To convert the address into the binary representation, use formatsByName[SYMBOL].decoder(text)
of address-encoder
Only callable by the owner of node
.
Emits the following event:
Returns the canonical ETHW ID name associated with the provided node
. Used exclusively for reverse resolution.
This function has interface ID 0x691f3431.
This function is specified in EIP 181.
Sets the canonical ETHW ID name for the provided node
to name
.
Only callable by the owner of node
.
Emits the following event:
Returns the content hash for node
, if one exists. Values are formatted as machine-readable multicodecs, as specified in EIP 1577.
contenthash
is used to store IPFS and Swarm content hashes, which permit resolving ETHW ID addresses to distributed content (eg, websites) hosted on these distributed networks.
This function has interface ID 0xbc1c58d1.
This function is specified in EIP 1577.
Sets the content hash for the provided node
to hash
.
Only callable by the owner of node
.
Values are formatted as machine-readable multicodecs, as specified in EIP 1577.
Emits the following event:
Returns a matching ABI definition for the provided node
, if one exists. contentTypes
is the bitwise-OR of the encodings that the caller can accept. If multiple content types are specified, the resolver will select one to return. Currently supported content types are:
ABI
returns a two-tuple of the content type ID and the ABI data. If no data of the appropriate content type ID was found, 0 is returned for the content type ID, and the ABI data will be the empty string.
This function has interface ID 0x2203ab56.
This function is specified in EIP 205.
Sets or updates ABI data for node
. contentType
specifies the content type ID (see Get Contract ABI for valid values); exactly one type ID must be specified. data
contains the encoded ABI data. To clear ABI data for a name, specify the empty string for data
.
Only callable by the owner of node
.
Emits the following event:
Returns the ECDSA SECP256k1 public key for node
, as a 2-tuple (x, y)
. If no public key is set, (0, 0)
is returned.
This function has interface ID 0xc8690233.
This function is specified in EIP 619.
Sets the ECDSA SECP256k1 public key for node
to (x, y)
.
Only callable by the owner of node
.
Emits the following event:
Retrieves text metadata for node
. Each name may have multiple pieces of metadata, identified by a unique string key
. If no text data exists for node
with the key key
, the empty string is returned.
Standard values for key
are:
In addition, anyone may specify vendor-specific keys, which must be prefixed with vnd.
. The following vendor-specific keys are currently known:
This function has interface ID 0x59d1d43c.
This function is specified in EIP 634.
Sets text metadata for node
with the unique key key
to value
, overwriting anything previously stored for node
and key
. To clear a text field, set it to the empty string.
Only callable by the owner of node
.
Emits the following event:
Permits users to set multiple records in a single operation.
Use encodeABI
function to encode your contract calls and pass it to data
.
The frontend usage will be as follows:
Content Type ID | Description |
---|---|
key | Meaning |
---|---|
key | Meaning |
---|---|
The default public resolver.
1
JSON
2
zlib-compressed JSON
4
8
URI
An email address
url
A URL
avatar
A URL to an image used as an avatar or logo
description
A description of the name
notice
A notice regarding this name
keywords
A list of comma-separated keywords, ordered by most significant first; clients that interpresent this field may choose a threshold beyond which to ignore
com.twitter
Twitter handle
com.github
Github username