metaplex-foundation / mpl-token-metadata

Program to attach additional data to Fungible or Non-Fungible tokens on Solana.
https://developers.metaplex.com/token-metadata
Other
98 stars 42 forks source link

testnet createNft failed #91

Closed yuhj86 closed 5 months ago

yuhj86 commented 5 months ago

run this example code, is ok on devnet, but got error on testnet

import { generateSigner, percentAmount, keypairIdentity } from "@metaplex-foundation/umi"
import { createNft, mplTokenMetadata } from "@metaplex-foundation/mpl-token-metadata"
import { createUmi } from "@metaplex-foundation/umi-bundle-defaults"
import { clusterApiUrl } from '@solana/web3.js'
import secret from 'PATH_TO_WALLET_ID.json' with { type: "json" }

const umi = createUmi(clusterApiUrl("devnet"))
  .use(keypairIdentity({
    publicKey: 'WALLET_ADDRESS',
    secretKey: new Uint8Array(secret)
  }))
  .use(mplTokenMetadata())
// Create the Collection NFT.
const collectionUpdateAuthority = generateSigner(umi);
const collectionMint = generateSigner(umi);

const tx = await createNft(umi, {
  mint: collectionMint,
  authority: collectionUpdateAuthority,
  name: "My Collection NFT",
  uri: "https://example.com/path/to/some/json/metadata.json",
  sellerFeeBasisPoints: percentAmount(9.99, 2), // 9.99%
  isCollection: true,
}).sendAndConfirm(umi);

console.log(tx)

package.json

{
  "name": "my-ntf-example",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "type": "module",
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@metaplex-foundation/mpl-candy-machine": "^6.0.0",
    "@metaplex-foundation/mpl-token-metadata": "^3.1.2",
    "@metaplex-foundation/umi": "^0.9.0",
    "@metaplex-foundation/umi-bundle-defaults": "^0.9.0",
    "@solana/web3.js": "^1.89.1"
  }
}

error log:

logs: [
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s invoke [1]',
    'Program log: Error: BorshIoError',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s consumed 3626 of 400000 compute units',
    'Program metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s failed: Failed to serialize or deserialize account data: Unknown'
]
MarkSackerberg commented 5 months ago

Hey @yuhj86 testnet has not the latest versions of the program since testnet is not made for us developers but to test solana itself. You should use devnet or localnet instead for testing.

yuhj86 commented 5 months ago

Thank you for explaining.

omair-rit commented 4 months ago

Having a similar problem, looks like devnet is down, getting error: failed to send transaction: Transaction simulation failed: Error processing Instruction 0: Failed to serialize or deserialize account data: Unknown at Connection.sendEncodedTransaction const connection = new Connection(clusterApiUrl('testnet'), "confirmed"); const umi = createUmi(connection) .use(walletAdapterIdentity(wallet)) .use(mplCandyMachine()); const mint = generateSigner(umi) await createNft(umi, { mint, name: 'My NFT', uri: 'https://example.com/my-nft.json', sellerFeeBasisPoints: percentAmount(5.5), }).sendAndConfirm(umi) const asset = await fetchDigitalAsset(umi, mint.publicKey)