Moralis NFT
所有方法都扩展自 Moralis.SolanaAPI.nft
getNFTMetadata
返回 SPL NFT 的metadata。
选项:
-
network
:要从中获取数据的网络集群。 有效值列在支持的网络上。 默认值主网。 -
address
:一个 SPL NFT 地址(即 HsXZnAba2...)。
你可以使用JS
、React
、curl
、Unity
来实现
// get devnet metadata for a given SPL NFT address
const options = {
network: "devnet",
address: "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe",
};
const nftMetadata = await Moralis.SolanaAPI.nft.getNFTMetadata(options);
import { useMoralisSolanaApi, useMoralisSolanaCall } from "react-moralis";
const { nft } = useMoralisSolanaApi();
// get devnet SPL NFT metadata for a given address
const options = {
network: "devnet",
address: "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe",
};
const { fetch, data, isLoading } = useMoralisSolanaCall(
nft.getNFTMetadata,
options
);
curl -X 'GET' \
'https://solana-gateway.moralis.io/nft/devnet/6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe/metadata' \
-H 'accept: application/json' \
-H 'X-API-Key: MY-API-KEY'
using System.Collections.Generic;
using Moralis.SolanaApi.Models;
using Moralis.SolanaApi;
using MoralisWeb3ApiSdk;
// get mainnet metadata for a given SPL NFT address
public async void GetSPLNftMetadata()
{
NftMetadata nftmetadata = await MoralisSolanaClient.SolanaApi.Nft.GetNFTMetadata(NetworkTypes.mainnet, "6XU36wCxWobLx5Rtsb58kmgAJKVYmMVqy4SHXxENAyAe");
print(nftmetadata);
}
示例结果
{
"mint": "string",
"standard": "string",
"name": "string",
"symbol": "string",
"metaplex": {
"metadataUri": "string",
"masterEdition": true,
"isMutable": true,
"primarySaleHappened": true,
"sellerFeeBasisPoints": 0,
"updateAuthority": "string"
}
}