0.1.1 • Published 2 years ago
@kns/js-sdk v0.1.1
KNS JS SDK
This is the JS SDK for KardiaChain Name Service (KNS), built by OdinDAO.
Important Notes
Normalization of Domain Names (Prevent Phishing)
When resolving blockchain addresses from domain name strings (kardiachain.kai
etc.), it is important to notice that domain names are hex encoded values derived from the input.
This means naturally that kardiAchain.kai
is encoded to a different token ID than kardiachain.kai
.
All domains need to be normalized before resolved into a token ID. This is done using the normalize(value: string)
function, which is automatically used in the domainToTokenId(domain: string)
function.
Installation
npm install @kns/js-sdk
Usage
Normalize a Domain Input
You can normalize a domain string using the normalize(value: string)
function as such:
console.log(normalize("kardiAchain.kai")); // "kardiachain"
console.log(normalize("kardiaChain.kai")); // "kardiachain"
console.log(normalize("kardiachain.kai")); // "kardiachain"
console.log(normalize("helloWorld.kai")); // "helloworld"
Convert Domain to Token ID
const tokenId = domainToTokenId("kardiachain.kai"); // "36623631373236343639363136333638363136393665"
Convert Token ID to Domain
const domain = tokenIdToDomain("36623631373236343639363136333638363136393665"); // "kardiachain.kai"
Test
npm run test
Lint
npm run lint
Format
Using Prettier.
npm run format