NodeJS
NodeJS is natively supported and doesn't require any additional setup.
Have a look at these example package.json
and index.js
files for reference:
{
"name": "kilt-sdk-node-test",
"type": "module",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"dependencies": {
"@kiltprotocol/sdk-js": "0.35.0"
}
}
- Typescript
- Javascript
import * as Kilt from '@kiltprotocol/sdk-js'
export async function queryAccountWeb3Name(
lookupAccountAddress: Kilt.KiltAddress
): Promise<Kilt.Did.Web3Name | null> {
const api = Kilt.ConfigService.get('api')
const encodedLinkedDetails = await api.call.did.queryByAccount(
Kilt.Did.accountToChain(lookupAccountAddress)
)
const { web3Name } = Kilt.Did.linkedInfoFromChain(encodedLinkedDetails)
if (web3Name) {
console.log(
`web3name for account "${lookupAccountAddress}" -> "${web3Name}"`
)
} else {
console.log(
`Account "${lookupAccountAddress}" does not have a linked web3name.`
)
}
return web3Name
}
# loading code...