使用Metaplex JS更新NFT元数据时遭遇Invalid token standard错误
解决Metaplex JS更新NFT元数据时的"Invalid token standard"错误
问题描述
使用Metaplex JS库更新NFT元数据,严格按照官方文档操作后,持续收到"Invalid token standard"错误。无论上传新的Arweave存储URL,还是仅修改NFT名称,都会触发该错误。
相关代码
const new_uri = await metaplex.nfts().uploadMetadata( uri_obj, ) await metaplex.nfts().update({ nftOrSft: nft, uri:new_uri.uri });
完整错误信息
return resolvedError ? new ProgramError.ParsedProgramError(program, resolvedError, error.logs) : new ProgramError.UnknownProgramError(program, error); ^ ParsedProgramError: The program [TokenMetadataProgram] at address [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s] raised an error of code [135] that translates to "Invalid token standard". Source: Program > TokenMetadataProgram [metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s] Caused By: InvalidTokenStandard: Invalid token standard Program Logs: | Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1] | Program log: Instruction: Token Metadata Update | Program log: Invalid token standard | Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 18628 of 200000 compute units | Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: custom program error: 0x87
使用的uri_obj
{ name: 'Suteki #467', symbol: 'TEKI', description: "Suteki is a unique collection of 6000 anime PFP's that focus on community building and creating real-world value. Claim your Buzoku (tribe), follow the lore and work up the ranks of the hierarchy to become a Oyabun (Family boss).", seller_fee_basis_points: 900, image: 'https://bafybeifsrfzvrms7ptbuv2pjhg3a5lr6waxhd6qyjzpm3ynogs3cbvfcdq.ipfs.nftstorage.link/467.png?ext=png', attributes: [ { trait_type: 'Background', value: 'Sand' }, { trait_type: 'Type', value: 'Light Scar' }, { trait_type: 'Tattoo or Scar Small', value: 'Mouth Scar' }, { trait_type: 'Tattoo or Scar Large', value: 'Suteki Faction' }, { trait_type: 'Mouth', value: 'Smile' }, { trait_type: 'Eyes', value: 'Blue' }, { trait_type: 'EyeBrows', value: 'Raised Right' }, { trait_type: 'Clothes', value: 'Spike Blazer' }, { trait_type: 'Mask', value: 'Cloth Wrap Blizzard' }, { trait_type: 'Hair', value: 'Blue Comb Over' }, { trait_type: 'Rank', value: 'Shatei (Little Brother)' }, { trait_type: 'Buzoku', value: 'Akamatsu' } ], properties: { category: 'image', files: [ [Object] ], creators: [ [Object], [Object] ] }, collection: { name: 'Suteki', family: 'Suteki' } }
可能的解决方案
1. 确认NFT的token标准有效性
该错误核心原因是目标NFT不符合Token Metadata Program要求的标准,比如是旧版非规范NFT,或SFT未正确标记。
- 通过Metaplex获取完整NFT数据,检查
tokenStandard字段:const nft = await metaplex.nfts().findByMint({ mintAddress: mintAddr }); console.log(nft.tokenStandard); // 正常应为NonFungible或NonFungibleEdition - 若
tokenStandard缺失或错误,需先将NFT升级至最新标准,或确保获取的nft对象包含正确标准信息。
2. 保证nftOrSft参数完整
传入的nft对象若缺少关键字段,会导致程序无法识别其token标准:
- 禁止手动构造
nft对象,必须通过Metaplex的findByMint、findByMetadata等方法获取完整NFT数据后再传入更新方法。 - 检查
nft对象是否包含tokenStandard、mintAddress、metadataAddress等核心字段。
3. 检查Metaplex版本兼容性
不同版本的Metaplex JS库与Token Metadata Program的交互逻辑存在差异:
- 确认使用的是Metaplex JS最新稳定版,避免版本不匹配引发的标准识别错误。
- 若使用旧版本,尝试升级后重新测试。
4. 验证元数据格式合规性
即使修改名称也报错,仍需确认元数据完全符合Metaplex规范:
- 若包含
collection字段,需确保格式正确(使用验证集合时,需包含verified和key字段)。 - 检查
properties.creators中的对象是否包含address、share、verified等必填字段。
内容的提问来源于stack exchange,提问作者Fares Hassen
相关产品推荐
相关产品推荐

