Is there a way to extract the selected network of an account, that is configured through the Polkadot JS Extension, through accounts.subscribe?

Account Network

1 Answer 1


No directly, but you can get that value.

With the script below you get your accounts with its meta information (as you mentioned):

    import { web3AccountsSubscribe } from '@polkadot/extension-dapp';
    await web3AccountsSubscribe(( injectedAccounts ) => { 
        injectedAccounts.map(( accounts ) => {
            const accountMeta = accounts.meta;

The meta information has this format:

    "genesisHash": "0x91b171bb158e2d3848fa23a9f1c25182fb8e20313b2c1eb49219da7a70ce90c3",
    "name": "testingB",
    "source": "polkadot-js"

From here we need the genesisHash because is the hash of the network you are looking for.

You can compare it with this file of genesis strings to get the name of your network: https://github.com/polkadot-js/common/blob/master/packages/networks/src/defaults/genesis.ts

In my example is Polkadot.

If is a network registered in this list (Testnets like Westened from your example are not included): https://github.com/paritytech/ss58-registry/blob/main/ss58-registry.json

You can query all the networks using the @poladot/networks library and create a function to find the network information of the genesisHash of your account:

    import { allNetworks } from '@polkadot/networks';

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.