CORE ID Docs
  • Introduction
  • Connect to CORE ID using ethers.js
  • CID SDK
  • HTTP API
  • Published Contracts
  • Core rpc
  • CORE ID enabling your dapp
  • CORE ID Registry
  • Name processing
  • Public Resolver
  • Resolving Names On Chain
  • Reverse Registrar
  • Decentralized Website
    • Core.Limo Decentralized Gateway
    • Create a decentralized website
    • Quickly create decentralized website
    • Create decentralized blog
  • User Tutorials for .core Domain
    • Set Up a Wallet
    • Register for a .core Domain
    • Set your domain name
    • Set primary name
    • Set Subdomains
    • CID Token
  • App
  • Twitter
  • Telegram
Powered by GitBook
On this page
  • Check Interface Support
  • Get Core Address
  • Set Core Address
  • Get Blockchain Address
  • Set Blockchain Address
  • Get Canonical Name
  • Set Canonical Name
  • Get Content Hash
  • Set Content Hash
  • Get Contract ABI
  • Set Contract ABI
  • Get Public Key
  • Set Public Key
  • Get Text Data
  • Set Text Data
  • Multicall

Public Resolver

PreviousName processingNextResolving Names On Chain

Last updated 2 years ago

description

The default public resolver.

PublicResolver implements a general-purpose CORE ID resolver that is suitable for most standard CORE ID use-cases. The public resolver permits updates to CORE ID records by the owner of the corresponding name.

The public resolver implements the following EIPs:

  • - Contract address interface (addr()).

  • - Interface Detection (supportsInterface()).

  • - Reverse resolution (name()).

  • - ABI support (ABI()).

  • - SECP256k1 public keys (pubkey()).

  • - Text records (text()).

  • - Content hash support (contenthash()).

  • - Multicoin support (addr()).

{% hint style="warning" %} While the PublicResolverprovides 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 %}

Check Interface Support

function supportsInterface(bytes4 interfaceID) external pure returns (bool)

CORE ID uses 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 Core 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.

Get Core Address

function addr(bytes32 node) external view returns (address)

Returns the Core address associated with the provided node, or 0 if none.

This function has interface ID 0x3b3b57de.

Set Core Address

function setAddr(bytes32 node, address addr) external;

Sets the Core address associated with the provided node to addr.

Only callable by the owner of node.

Emits the following event:

event AddrChanged(bytes32 indexed node, address a);

Get Blockchain Address

function addr(bytes32 node, uint coinType) external view returns(bytes memory);

Returns the Blockchain address associated with the provided node and coinType, or 0 if none.

This function has interface ID 0xf1cb7e06.

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.

A zero-length string will be returned if the specified coin ID does not exist on the specified node.

Set Blockchain Address

function setAddr(bytes32 node, uint coinType, bytes calldata a) external;

Sets the blockchain address associated with the provided node and coinType to addr.

Only callable by the owner of node.

Emits the following event:

event AddressChanged(bytes32 indexed node, uint coinType, bytes newAddress);

Get Canonical Name

function name(bytes32 node) external view returns (string memory);

Returns the canonical CORE ID name associated with the provided node. Used exclusively for reverse resolution.

This function has interface ID 0x691f3431.

Set Canonical Name

function setName(bytes32 node, string calldata name) external;

Sets the canonical CORE ID name for the provided node to name.

Only callable by the owner of node.

Emits the following event:

event NameChanged(bytes32 indexed node, string name);

Get Content Hash

function contenthash(bytes32 node) external view returns (bytes memory);

contenthash is used to store IPFS and Swarm content hashes, which permit resolving CORE ID addresses to distributed content (eg, websites) hosted on these distributed networks.

This function has interface ID 0xbc1c58d1.

Set Content Hash

function setContenthash(bytes32 node, bytes calldata hash) external;

Sets the content hash for the provided node to hash.

Only callable by the owner of node.

Emits the following event:

event ContenthashChanged(bytes32 indexed node, bytes hash);

Get Contract ABI

ABI(bytes32 node, uint256 contentTypes) external view returns (uint256, bytes memory);

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:

Content Type ID
Description

1

JSON

2

zlib-compressed JSON

4

8

URI

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.

Set Contract ABI

function setABI(bytes32 node, uint256 contentType, bytes calldata data) external

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:

event ABIChanged(bytes32 indexed node, uint256 indexed contentType);

Get Public Key

function pubkey(bytes32 node) external view returns (bytes32 x, bytes32 y)

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.

Set Public Key

function setPubkey(bytes32 node, bytes32 x, bytes32 y) external

Sets the ECDSA SECP256k1 public key for node to (x, y).

Only callable by the owner of node.

Emits the following event:

event PubkeyChanged(bytes32 indexed node, bytes32 x, bytes32 y);

Get Text Data

function text(bytes32 node, string calldata key) external view returns (string memory)

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:

key
Meaning

email

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

In addition, anyone may specify vendor-specific keys, which must be prefixed with vnd.. The following vendor-specific keys are currently known:

key
Meaning

com.twitter

Twitter handle

com.github

Github username

This function has interface ID 0x59d1d43c.

Set Text Data

function setText(bytes32 node, string calldata key, string calldata value) external

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:

event TextChanged(bytes32 indexed node, string indexedKey, string key);

Multicall

function multicall(bytes[] calldata data) external returns(bytes[] memory results)

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:

var addrSet = resolver.contract.methods['setAddr(bytes32,address)'](node, accounts[1]).encodeABI();
var textSet = resolver.contract.methods.setText(node, "url", "https://ethereum.org/").encodeABI();
var tx = await resolver.multicall([addrSet, textSet], {from: accounts[0]});

This function is specified in .

This function is specified in .

To convert the binary representation into the address, use formatsByCoinType[SYMBOL].encoder(binary) of .

coinType is the cryptocurrency coin type index from .

To convert the address into the binary representation, use formatsByName[SYMBOL].decoder(text) of

This function is specified in .

Returns the content hash for node, if one exists. Values are formatted as machine-readable , as specified in .

This function is specified in .

Values are formatted as machine-readable , as specified in .

This function is specified in .

This function is specified in .

This function is specified in .

Source
EIP 137
EIP 165
EIP 181
EIP 205
EIP 619
EIP 634
EIP 1577
EIP 2304
ERC 165
EIP 137
EIP 2304
address-encoder
SLIP44
address-encoder
EIP 181
multicodecs
EIP 1577
EIP 1577
multicodecs
EIP 1577
EIP 205
EIP 619
EIP 634
CBOR