user7939: 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;
IERC20(token).totalSupply();


user2335: 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.

7939: <p>Is it possible to get the total supply of a native token in <a href="https://cardano.stackexchange.com/questions/4677/is-there-a-way-to-find-the-total-number-of-tokens-in-circulation-generated-by-a">a smart contract</a>, similar to the following Solidity code from <a href="https://cardano.stackexchange.com/questions/7248/what-is-the-cardanos-equivalent-to-the-ethereums-evm?noredirect=1&amp;lq=1">here</a>? One can easily query it from an external <a href="https://cardano.stackexchange.com/questions/9102/is-there-a-way-to-get-the-current-circulating-supply-of-an-asset-via-api">API</a>.</p>
<pre><code>address token = 0xE592427A0AEce92De3Edee1F18E0157C05861564;
IERC20(token).totalSupply();
</code></pre>
 2335: <p>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.</p>
<p>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.</p>
<p>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 <a href="https://docs.blockfrost.io/#tag/Cardano-Assets/paths/%7E1assets/get" rel="nofollow noreferrer">example</a>). 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!</p>
<p>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.</p>
<p>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.</p>
<p>Lastly, there is a new token standard for fungible tokens (CIP <a href="https://github.com/cardano-foundation/CIPs/tree/master/CIP-0067" rel="nofollow noreferrer">67</a> and CIP <a href="https://github.com/cardano-foundation/CIPs/tree/master/CIP-0068" rel="nofollow noreferrer">68</a>). 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.</p>
<p>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.</p>
