Skip to main content

Getting Started

You can integrate Clet in your Dapps to resolve Clet names mainly by using the On-Chain approach or the REST API

On-Chain​

  • Connect to the skale chain with the network details from here

  • Create a new instance of Provider and Contract.

const skaleProvider = new ethers.providers.JsonRpcProvider(SKALE_RPC);
const coreContract = new ethers.Contract(
CORE_CONTRACT_ADDRESS,
CORE_CONTRACT_ABI,
skaleProvider
);
  • Voila!! You can now resolve Clet names using the newly created contract instance (coreContract). Below are some examples.
...
//Code Snippet
const btcAddress = await coreContract.resolve("franz.btc");
//returns 1BaByV2VzmNmvdTU8TWczk4aJjxZuKr5oo

const cletNameXRP = await coreContract.reverseLookup(
"rBRRbH8ucvBizG6wZEK4vvqLaj8mB349u2"
);
//returns pk.xrp


REST API​

You can query any of the endpoints from the api from here. Below is an example using one of the endpoints.

async function fetchData() {
let url = "https://api.clet.domains/api/v1/resolve";
try {
const response = await fetch(`${url}/clet.twitter`);
const data = await response.json();
return data;
} catch (error) {
console.error(error);
}
}

//this returns an object containing with the mapped info => "https://twitter.com/cletNS"