Skip to main content

getUri

The getUri method for the ERC-1155 token standard fetches the URI associated with a specific token ID. This URI often points to a metadata file, containing details about the token, such as its name, description, image, and other attributes. The method is an integral part of the ERC1155Instance object, which can be accessed through an appropriate method of the EdexaClient or the relevant library.

Method Signature

getUri(id: string): Promise<string>

Parameters

ParameterTypeDescription
idstringThe specific ID of the ERC-1155 token for which the URI is being retrieved.

Returns

  • A Promise resolving to a string which represents the URI associated with the provided ERC-1155 token ID.

Usage Example

First, instantiate the desired ERC-1155 token contract:

const erc1155 = edexaClient.getERC1155Instance("your ERC-1155 contract address here");

Then, call the getUri method for the desired token ID:

const tokenId = "token-specific-id";
const tokenUri = await erc1155.getUri(tokenId);
console.log(`Token URI for ID ${tokenId}: ${tokenUri}`);

Notes

  • The returned URI often points to a metadata JSON file, providing detailed information about the token. This could include attributes such as the token's name, description, image, and more.

  • It's essential to ensure the validity of the token ID provided; otherwise, the method might throw an error or return a null value.