Using polkadot.js
api:
- How do I get from an address to the parent address/identity?
- Is there any way to traverse from an identity to the sub-identities?
Just calling the identity of the address returns null
import { ApiPromise, WsProvider } from '@polkadot/api'
// import { hexToString } from '@polkadot/util'
(async () => {
const provider = new WsProvider('wss://kusama-rpc.polkadot.io')
const api = await ApiPromise.create({ provider: provider })
var validator = { stash: "HyLisujX7Cr6D7xzb6qadFdedLt8hmArB6ZVGJ6xsCUHqmx" }; // METASPAN
var identity = await api.query.identity.identityOf(validator.stash)
console.log(identity.toString())
// {"judgements":[[0,{"reasonable":null}]],"deposit":33333333000,"info":{"additional":[],"display":{"raw":"0x4d4554415350414e"},"legal":{"none":null},"web":{"none":null},"riot":{"none":null},"email":{"raw":"0x646572656b406d6574617370616e2e636f6d"},"pgpFingerprint":null,"image":{"none":null},"twitter":{"raw":"0x406d6574617370616e5f696f"}}}
validator = { name: '☀️SHAWN☀️/08🚀', stash: 'GvBUeTDynB9A7fFDPoBt3RGXSjZVeCetoXjYQ44cMNp5myY' }
identity = await api.query.identity.identityOf(validator.stash)
console.log(identity.toString())
// empty
console.debug('done')
setTimeout(() => {
process.exit(0)
}, 5000)
})()