2

How do I get the list of all the assets that are present and their supply in Statemint?

Ideally either with Polkadot-JS api or py-substrate-interface.

2 Answers 2

3

Using PolkadotJS you can get the list of assets with this script:

    const wsProvider = new WsProvider('wss://statemint.api.onfinality.io/public-ws');
    const api = await ApiPromise.create({ provider: wsProvider });

    const chain = await api.rpc.system.chain();
    console.log(`----- Chain: ${chain} -----`);

    const assets = await api.query.assets.metadata.entries();
    assets.forEach(([{args: [id] } ,asset]) => {
      console.log(`${id}: ${asset}`);
      });

You can also query the list of assets using PolkadotJS UI calling the extrinsic metadata and disabling Include Option

enter image description here

1

Using py-substrate-interface it would be something like:

substrate = SubstrateInterface(url="wss://statemint-rpc.polkadot.io")

assets_metadata = substrate.query_map(
    'Assets', 'Metadata'
)

for asset, metadata in assets_metadata:
    print(f'Metadata of asset "{asset.value}": {metadata.value})')

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.