getTokenMetadata
/** Get a token metadata
* @param {string} contractAddress address of the contract which holds the token
* @param {number} tokenId ID of the token
* @returns {Promise<object>} Token metadata
*/
async getTokenMetadata({ contractAddress, tokenId }) {
if (!contractAddress || !utils.isAddress(contractAddress)) {
throw new Error(
errorLogger({
location: ERROR_LOG.location.SDK_getTokenMetadata,
message: ERROR_LOG.message.invalid_contract_address,
}),
);
}
if (!Number.isFinite(tokenId)) {
throw new Error(
errorLogger({
location: ERROR_LOG.location.SDK_getTokenMetadata,
message: ERROR_LOG.message.no_tokenId_supplied,
}),
);
}
const apiUrl = `${this.#apiPath}/nfts/${contractAddress}/tokens/${tokenId}`;
const { data } = await this.#httpClient.get(apiUrl);
return data;
}
Copy link