0x00gc
0x00gc

Reputation: 31

AnchorError occurred. Error Code: InstructionFallbackNotFound. Error Number: 101. Error Message: Fallback functions are not supported

I am trying to call the mintNft function on the front end but it throws an error and I can't fix it

the error is: "Program log: AnchorError occurred. Error Code: InstructionFallbackNotFound. Error Number: 101. Error Message: Fallback functions are not supported."

see http response: rpc response

lib.rs

web.ts:

  const tx = await program.rpc.mintNft(
    mintKey.publicKey,
    "https://arweave.net/y5e5DJsiwH0s_ayfMwYk-SnrZtVZzHLQDSTZ5dNRUHA",
    "NFT Title",
    {
      accounts: {
        mintAuthority: program.provider.wallet.publicKey,
        mint: mintKey.publicKey,
        tokenAccount: NftTokenAccount,
        tokenProgram: TOKEN_PROGRAM_ID,
        metadata: metadataAddress,
        tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID,
        payer: program.provider.wallet.publicKey,
        systemProgram: SystemProgram.programId,
        rent: anchor.web3.SYSVAR_RENT_PUBKEY,
        masterEdition: masterEdition,
      },
    }
  );
  console.log(tx);
  // console.log("Your transaction signature", tx);

Upvotes: 3

Views: 4027

Answers (3)

Mahesh Ghamaand
Mahesh Ghamaand

Reputation: 515

The error is thrown because of capital N in your function-name mintNft. Capital letters are not supported for function name in solana program.

I also found out that underscore + number is also not supported, e.g. exchange1 is valid function name, but exchange_1 is invalid function name.

Upvotes: 2

Mirza Setiyono
Mirza Setiyono

Reputation: 355

its because the instruction that you want to call is not available! could be because a couple of things, such as:

  1. check if IDL is the latest one, try erasing the target dir and run anchor build (dont forget to replace the program ID in the lib file of your programs)
  2. check if anchor.toml program id equal the deployed program public key in /target/deploy directory

Upvotes: 3

katopz
katopz

Reputation: 671

  1. update your code to match anchor 0.24.2, It should look like this in Cargo.toml
[dependencies]
anchor-lang = "0.24.2"
mpl-token-metadata = { version="1.2.5", features = [ "no-entrypoint" ] }
anchor-spl = "0.24.2"
  1. update package.json
{
    "dependencies": {
        "@project-serum/anchor": "^0.24.2",
        "@solana/spl-token": "^0.2.0"
    },
    "devDependencies": {
        "@types/chai": "^4.3.1",
        "@types/mocha": "^9.1.1",
        "chai": "^4.3.6",
        "mocha": "^10.0.0",
        "ts-mocha": "^10.0.0",
        "typescript": "^4.6.4"
    }
}
  1. migrate the code to match anchor 0.24.2 for example (too long to post here) https://github.com/katopz/metaplex-anchor-nft/commit/f54ffaf087858f3997e797133ccc6d7748309c0a

  2. and also rpc here https://github.com/katopz/metaplex-anchor-nft/commit/a72929548c8041ac422708c04078b8543e0f8a67

  3. If nothing work, try run anchor test my forked here (tested today) https://github.com/katopz/metaplex-anchor-nft

  4. For frontend, I think you will need to pass wallet provider to make it work. Should be something like this.

anchor.setProvider(new Client(programId, wallet).provider)

Upvotes: 1

Related Questions