Is it possible to get the total supply of a native token in a smart contract, similar to the following Solidity code from here? One can easily query it from an external API.

address token = 0xE592427A0AEce92De3Edee1F18E0157C05861564;

1 Answer 1


A stated in the other question on this topic, in general, no you can not get the total supply of any native asset available in a plutus script.

The Cardano blockchain is inherently local and deterministic, this means that any data is strictly separated from other data. Global questions like, how many are there of token x on the blockchain, implies knowledge of all these little pieces of data.

This knowledge can be constructed off chain, but is harder to be deduced onchain in a trustless setting. In the off chain case, anyone who has a copy of the chain can just count the amount of minting/burning transactions and add these up (you can use the blockfrost api for this, for example). For a plutus script, the scope is limited by only the inputs you provide in its transaction, adding all these little pieces of data will overflow the available transaction size. Moreover, a plutus script is blind to any historic transactions of the chain, so there is even no way to add knowledge of previous transactions!

That said, there are ways to introduce this knowledge onchain for plutus to use. The first is writing a stateful minting script. This means a script that keeps track of the number of tokens it already minted! This is something that for example liquidity pools use, here they need to keep track of how many tokens they already put out to make sure any new issuance is done according to its protocol.

Secondly, one can use an oracle to introduce trustworthy knowledge on the total supply of a token. This is especially handy for tokens that already have a fixed minting policy and thus cannot introduce a stateful minting script.

Lastly, there is a new token standard for fungible tokens (CIP 67 and CIP 68). This allows the addition of metadata to tokens onchain, such as the total supply! This means that creators of tokens can add the amount of the supply there such that it is available onchain. Note, however, that this is something the creators can put in themselves, in no way does this ensure that the minting policy used abides that amount.

I suppose that in the future, as these things mature, there will come a standard open source stateful minting script that will ensure these things. Similar to the ECR20 standard you referred to.

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.