TypeError: Cannot read properties of undefined (reading 'kind')

TypeError: Cannot read properties of undefined (reading 'kind')

Manage alerts

Loading saved threads...

noxx · External communityPost link
External question — Solana Stack Exchange Author: noxx Original post: https://solana.stackexchange.com/questions/17828 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. 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'
Quote
Report
Dharam Sojitra · External communityPost link
External answer — Solana Stack Exchange Author: Dharam Sojitra Original post: https://solana.stackexchange.com/a/21568 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. Try this version of Anchor "@coral-xyz/anchor": "^0.31.0", And use const program = new Program(idl, provider);
Quote
Report

Post Reply

Checking account access…