3

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);
0x00gc
  • 31
  • 2

3 Answers3

2

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
Mirza Setiyono
  • 181
  • 3
  • 10
1
  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)
katopz
  • 591
  • 6
  • 14
  • Yes, I cloned your project and executed the anchor test, the test passed. But in my front-end project, I still get the previous error after execution, please help me take a look, thank you. my project:https://github.com/Marchccc/solana-example-react Following the readme in it will reproduce my situation When the mintNft method is called on the front end, an error will be returned: AnchorError occurred. Error Code: InstructionFallbackNotFound. Error Number: 101. Error Message : Fallback functions are not supported. I'm a newbie and this is totally bugging me, thanks for your time – 0x00gc May 14 '22 at 13:13
1

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.

Mahesh Ghamaand
  • 410
  • 1
  • 3
  • 11