1

fetch list of all nomination pools using polkadot js API. details like poolID, address etc

2 Answers 2

2

using api.query.nominationPools.poolMembers enter image description here

polkadot js doc

However, we don't need to pass AccountId32 as it asking to specify parameters. Instead we can retrieve a list of all the keys and entries for the map, refer docs.

const pools = await api.query.nominationPools.poolMembers.entries()
pools.forEach(([key, value]) => {
    if (value.isSome) {
        const poolMemberData = value.unwrap().toHuman();
        console.log('Pool ID:', poolMemberData.poolId);
        console.log(
            'Account ID:', key.args[0].toString(),
            'Pool Member Info:', JSON.stringify(poolMemberData)
            );
        }
    })

Also refer this answer

2

Once you get the poolID, you can also query the metadata:

await api.query.nominationPools.metadata(pool_id);

You can look more information about this here: Get pool name and stash account from nomination pool creator

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.