@solana/web3.js ERC721元数据有API吗?
@solana/web3.js Is there an API for ERC721 Metadata?
给定一个代币铸造地址,我正在寻找一种方法来访问 ERC721 代币的元数据。 @solana/web3.js中有没有API?
不,目前没有 API,但是 phantom wallet uses the metaplex on-chain program at: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
to get the info it needs about the NFT which is hosted on arweave 和相应的数据帐户。
Solana 将代币元数据存储在从原始代币地址派生的地址中
https://docs.solana.com/developing/programming-model/calling-between-programs#hash-based-generated-program-addresses
参考代码是 rust,这里是 @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`);
}
请注意,元数据使用 borsh library, as per https://docs.metaplex.com/nft-standard#token-metadata-program.
以 base64 编码
这是一个仅使用 borsh 和@solana/web3.js 检索和解析元数据的简洁实现
https://gist.github.com/dvcrn/c099c9b5a095ffe4ddb6481c22cde5f4
最后,MagicDen 有一个 returns 元数据的端点:
https://api-mainnet.magiceden.io/rpc/getNFTByMintAddress/DugthRKbQZRMcDQQfjnj2HeSjz2VARPC8H9abxdNK2SS
不,但可以通过区块链 API 获得一个:https://docs.theblockchainapi.com/#tag/Solana-NFT/paths/~1v1~1solana~1nft/get
您只需提供 mint_address 并取回元数据。很简单!
给定一个代币铸造地址,我正在寻找一种方法来访问 ERC721 代币的元数据。 @solana/web3.js中有没有API?
不,目前没有 API,但是 phantom wallet uses the metaplex on-chain program at: "metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s"
to get the info it needs about the NFT which is hosted on arweave 和相应的数据帐户。
Solana 将代币元数据存储在从原始代币地址派生的地址中 https://docs.solana.com/developing/programming-model/calling-between-programs#hash-based-generated-program-addresses
参考代码是 rust,这里是 @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`);
}
请注意,元数据使用 borsh library, as per https://docs.metaplex.com/nft-standard#token-metadata-program.
以 base64 编码这是一个仅使用 borsh 和@solana/web3.js 检索和解析元数据的简洁实现 https://gist.github.com/dvcrn/c099c9b5a095ffe4ddb6481c22cde5f4
最后,MagicDen 有一个 returns 元数据的端点: https://api-mainnet.magiceden.io/rpc/getNFTByMintAddress/DugthRKbQZRMcDQQfjnj2HeSjz2VARPC8H9abxdNK2SS
不,但可以通过区块链 API 获得一个:https://docs.theblockchainapi.com/#tag/Solana-NFT/paths/~1v1~1solana~1nft/get
您只需提供 mint_address 并取回元数据。很简单!