2
$ anchor idl init -f target/idl/program.json `solana address -k target/deploy/program-keypair.json` 

Error: RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: invalid program argument [3 log messages]

Caused by:
    RPC response error -32002: Transaction simulation failed: Error processing Instruction 0: invalid program argument [3 log messages]

I have been unable to find:

  • the error -32002 specific to this case
  • the log messages mentioned in the brackets
  • what does Instruction 0 mean
  • which program argument is invalid
  • any solution in general

Solang version: v0.3.2
Anchor-cli version: v0.28.0
Solana-cli version: v1.16.17

edit to add my instruction 0:

    {
      "name": "new",
      "accounts": [
        {
          "name": "dataAccount",
          "isMut": true,
          "isSigner": true,
          "isOptional": false
        },
        {
          "name": "payer",
          "isMut": true,
          "isSigner": true,
          "isOptional": false
        },
        {
          "name": "systemProgram",
          "isMut": false,
          "isSigner": false,
          "isOptional": false
        }
      ],
      "args": []
    }

edit: I experimented with changing the function order and its arguments and the problem is still there, suggesting to me a compatibility issue.

edit:
You can reproduce this by trying to deploy the program created with:

anchor init program --solidity

Opened issue in anchor github

1 Answer 1

1

As a temporary workaround, since idl files are simple .json files you can bundle it within the web-app and load it with a simple:

import idl from "./testprogram.json";
...
new anchor.Program(idl, ...)

Edit:
Even better, you may copy the target/types/testprogram.ts file into the app and import both the IDL and Contract type with:

import { Testprogram, IDL } from "./testprogram";

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.