Set Name
Set Name
This POST route is used to set a name for a given address and domain. It will overwrite existing names.
If a name does not exist this route will create it.
If a name does not exist this route will create it.
Parameters
name
(string): The name being set, i.e., the "example" in example.testbrand.eth.domain
(string): The domain ("testbrand.eth").address
(string): The ethereum address the name points to.contenthash
(string)(Optional): The link for an ipfs or ipns website.text_records
(object)(Optional): An object containing key-value pairs representing the text records to be set.coin_types
(object)(Optional): An object containing key-value pairs representing L2 chains and their resolved address.
Multichain Address Resolution
NameStone supports multichain address resolution to any L2 chain permitted within ENS. To convert chain ID into coin type, use the following typescript template.
Curl Example with coin_types
curl -X POST \
-H 'Content-Type: application/json' \
-H 'Authorization: YOUR_API_KEY' \
-d '{
"domain": "namestone.xyz",
"name": "multichain",
"address": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF",
"coin_types": {
"2147483785": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF",
"2147492101": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF",
"2147525809": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF",
"2147483658": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF"
},
"text_records": {
"com.twitter": "namestonehq",
"com.github": "resolverworks",
"url": "https://www.namestone.xyz",
"description": "Multichain Example",
"avatar": "https://imagedelivery.net/UJ5oN2ajUBrk2SVxlns2Aw/e52988ee-9840-48a2-d8d9-8a92594ab200/public"
}
}' \
https://namestone.xyz/api/public_v1/set-name
SDK Example with coin_types
import NameStone, { AuthenticationError, NetworkError, TextRecords, CoinTypes } from 'namestone-sdk';
// Initialize the NameStone instance
const ns = new NameStone(<YOUR_API_KEY_HERE>);
// Define the name parameters
const domain = "namestone.xyz";
const name = "multichain";
const address = "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF";
// Define the coin types
const coinTypes: CoinTypes = {
"2147483785": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF",
"2147492101": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF",
"2147525809": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF",
"2147483658": "0x534631Bcf33BDb069fB20A93d2fdb9e4D4dD42CF"
};
// Define the text records
const textRecords: TextRecords = {
"com.twitter": "namestonehq",
"com.github": "resolverworks",
"url": "https://www.namestone.xyz",
"description": "Multichain Example",
"avatar": "https://imagedelivery.net/UJ5oN2ajUBrk2SVxlns2Aw/e52988ee-9840-48a2-d8d9-8a92594ab200/public"
};
// Use an immediately invoked async function to allow top-level await
(async () => {
try {
const response = await ns.setName({
name:name,
domain:domain,
address:address,
text_records:textRecords,
coin_types:coinTypes
});
console.log("Name set successfully:", response);
} catch (error) {
if (error instanceof AuthenticationError) {
console.error("Authentication failed:", error.message);
} else if (error instanceof NetworkError) {
console.error("Network error:", error.message);
} else {
console.error("An unexpected error occurred:", error);
}
}
})();
Live Example: See multichain.namestone.xyz on the ENS app.