Name Service
Last updated
Last updated
In Web3 systems, an address is used as a user's identity. However, addresses are difficult to recognize and remember. Take an address on the Ethereum blockchain for example, it is a heximal string with a length of 40 characters. It is not easy to recognize that in a social setting.
Therefore, we devised a Relation Name Service contract parsing readable names (eg. "relation.soul") as computer-readable identifiers.
Meanwhile, we also use arweave, a decentralized storage system, to expand properties of an identity to build a comprehensive profile. Users can store other information in arweave and save the arweave transaction hash in the Name Service contract.
Relation Name Service, or RNS, is an important part of the Relation Protocol. RNS is a SBT itself, allowing users to control their own social identity data in the Relation network.
Name Service SBTs are owned by individual addresses. They have two status:
hold: Under this status, a Name Service SBT can be transferred. But no one can search for it with its name or query its address.
resolved: When an address undertakes a "resolve" action to bind the token with Soul, the Name Service SBT 's name will be bound to an address. It can not be transferred under this status.
To ensure a unique result for recommendation and searching by the social graph, an address can hold multiple Name Service SBTs, but it can only "Bound" one at the same time.
The schema corresponding to the Relation Name Service contract is saved to Arweave in the form of a ttl file, with the transaction hash as the schemaURI to be passed to the contract during its initialization stage. For example:
The list of prefixes.
Class
":Soul" represents the address accepting and bounding names. ":Domain" represents a domain name.
Predicate
"p:hold" means the address holds an address but has not yet resolved it. "p:resolved" means the address has linked with a domain name, thus one can resolve the address via the domain name."p:profileURI" means the profileURI of an address.
The interface of the Name Service contract is as follows:
Full source code:
We set a few rules for the Name Service:
The shortest length for a domain name is 3 characters.
A domain name can only be resolved properly by the contract after setting a resolve record. This can be done in two ways:
To set the record during "register".
To call the "setNameForAddr" method after "register"
If the current domain name has set a resolve record, you need to unbound it from the previous address before you can resolve it to a new one.
The contract disables "transfer" by default, effectively banning all token transfers. To turn on this option, you can call the "setTransferable" method.
Only tokens without a current resolve record can be transferred.