[英]@solana/web3.js Is there an API for ERC721 Metadata?
Given a token mint address, I'm looking for a way to get access to the metadata of an ERC721 token.给定一个令牌铸造地址,我正在寻找一种方法来访问 ERC721 令牌的元数据。 Is there an API in @solana/web3.js?
@solana/web3.js 中有 API 吗?
Solana stores token metadata at an address that is derived from the original token's address as per https://docs.solana.com/developing/programming-model/calling-between-programs#hash-based-generated-program-addresses Solana 根据https://docs.solana.com/developing/programming-model/calling-between-programs#hash-based-generated-program-addresses在源自原始令牌地址的地址中存储令牌元数据
The reference code is in rust, here is the implementation from @solana/web3.js
.参考代码生锈了,这是来自
@solana/web3.js
。
( source ) ( 来源)
static async findProgramAddress(
seeds: Array<Buffer | Uint8Array>,
programId: PublicKey,
): Promise<[PublicKey, number]> {
let nonce = 255;
let address;
while (nonce != 0) {
try {
const seedsWithNonce = seeds.concat(Buffer.from([nonce]));
address = await this.createProgramAddress(seedsWithNonce, programId);
} catch (err) {
if (err instanceof TypeError) {
throw err;
}
nonce--;
continue;
}
return [address, nonce];
}
throw new Error(`Unable to find a viable program address nonce`);
}
Note that the metadata is encoded in base64, using the borsh library , as per https://docs.metaplex.com/nft-standard#token-metadata-program .请注意,根据https://docs.metaplex.com/nft-standard#token-metadata-program ,元数据使用borsh 库以 base64 编码。
Here is a concise implementation to retrieve and parse metadata using only borsh and @solana/web3.js https://gist.github.com/dvcrn/c099c9b5a095ffe4ddb6481c22cde5f4这是仅使用 borsh 和 @solana/web3.js https://gist.github.com/dvcrn/c099c9b5a095ffe4ddb6481c22cde5f4检索和解析元数据的简明实现
Finally, MagicDen has an endpoint that returns the metadata: https://api-mainnet.magiceden.io/rpc/getNFTByMintAddress/DugthRKbQZRMcDQQfjnj2HeSjz2VARPC8H9abxdNK2SS最后,MagicDen 有一个返回元数据的端点: https ://api-mainnet.magiceden.io/rpc/getNFTByMintAddress/DugthRKbQZRMcDQQfjnj2HeSjz2VARPC8H9abxdNK2SS
No, but one is available via the Blockchain API here: https://docs.theblockchainapi.com/#tag/Solana-NFT/paths/~1v1~1solana~1nft/get不,但可以通过此处的区块链 API 获得: https : //docs.theblockchainapi.com/#tag/Solana-NFT/paths/~1v1~1solana~1nft/get
You just supply the mint_address and get back the metadata.您只需提供 mint_address 并取回元数据。 Pretty simple!
很简单!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.