Retrieving Total Supply and Token URI
This document covers two essential functionalities provided by the edeXa ERC721 SDK: retrieving the total supply of minted tokens and fetching a token's URI. These operations are crucial for managing and interacting with Non-Fungible Tokens (NFTs).
Overview of the getTotalSupply
Method
The getTotalSupply
method enables you to inquire about the total number of tokens that have been minted within a specific smart contract.
Prerequisites
- Installation of the edeXa ERC721 SDK in your project.
- An authentication token obtained through the SDK's authentication method. This token is necessary to authorize your requests.
Sample Code Snippet
Here is a JavaScript code snippet demonstrating the use of the getTotalSupply
method:
import { ERC721, Network } from 'edeXa-sdk';
async function getTotalSupply() {
const settings = {
network: Network.SANDBOX, // or Network.MAINNET for the mainnet network
authorization: `Bearer ${token}`, // Replace 'token' with your own authentication token
};
const erc721 = new ERC721(settings);
try {
const getTotalSupplyResponse = await erc721.getTotalSupply({});
// Handle success
} catch (error) {
// Handle error
}
}
Request Parameters
Parameter | Required | Type | Description |
---|---|---|---|
chaincode | No | String | Name of the smart contract or chaincode managing the tokens. |
channel | No | String | Name of the channel in the blockchain network. |
Response Format
Attribute | Type | Description |
---|---|---|
supply | Number | The total number of minted tokens in the contract. |