0

When i'm trying to set my idl at the Program() paramater on my frontend, it always give an error says: TypeError: Cannot read properties of undefined (reading 'kind')

here are some parts of my idl.json file

"name": "VoteAccount",
"type": {
    "kind": "struct",
    "fields": [
           {
              "name": "cand_1",
              "type": "u64"
           },
           {
              "name": "cand_2",
              "type": "u64"
           },
           {
              "name": "cand_3",
              "type": "u64"
           }
         ]
      }
}

and here's the code where i set my program

import idl from "../../anchor/idl.json";
const provider = new anchor.AnchorProvider(connection, wallet, { "preflightCommitment": "processed" })
const program = new Program(JSON.parse(JSON.stringify(idl)), idl.address, provider)

i've tried like passing the idl directly, and JSON parsing it and stringify it again, but it keep giving the same error where it can't read 'kind'

0

Your Answer

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

Browse other questions tagged or ask your own question.