How would I track the token issuance of a parachain, using either the polkadot api or on-chain data? Does anyone have a simple example?
3 Answers
It is exposed in the state under balances.totalIssuance
, so the following will work -
const total = await api.query.balances.totalIssuance();
console.log(total.toString());
For the parachain connect to the parachain wss endpoint, for the relay chain connect to the relay wss endpoint.
The total issuance of a Substrate chain is most commonly a storage item from the Balances pallet. Here's how you would find this value using Polkadot JS Apps:
- Go to the chain state for the chain you're querying.
- Select the
balances
pallet and thetotalIssuance
storage item. - Hit the "
+
" button on the right and you'll see someu128
value appear.
For example, querying Polkadot's chain state:
subscribe and trace
const unsub = await api.query.balances.totalIssuance((total) => {
console.log(`Total issuance changed to ${total}`);
});