Argument of type 'PublicKey' is not assignable to parameter of type 'Provider'

Argument of type 'PublicKey' is not assignable to parameter of type 'Provider'

Manage alerts

Loading saved threads...

papi · External communityPost link
External question — Solana Stack Exchange Author: papi Original post: https://solana.stackexchange.com/questions/15981 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I wanna write a client to call program already deployed in devnet, below is the main part of my code const idl = require('../idl/idl.json'); const wallet = useAnchorWallet(); // Create the provider export const provider = new anchor.AnchorProvider( connection, wallet, anchor.AnchorProvider.defaultOptions() ); anchor.setProvider(provider); // Initialize the program const PROGRAM_ID = new PublicKey("dTwLMQBF1AR46Y3aufwQgXWaTCzgbFjyMEC9da3dV"); const program = new anchor.Program(idl as anchor.Idl, PROGRAM_ID, provider); and the code get the error Property 'connection' is missing in type 'PublicKey' but required in type 'Provider'.
Quote
Report
Jimii · External communityPost link
External answer — Solana Stack Exchange Author: Jimii Original post: https://solana.stackexchange.com/a/15985 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. If this is a react app, try adding a check for whether the wallet is initialized. if (!wallet) { throw new WalletNotConnectedError(); } const provider = new AnchorProvider( connection, wallet, AnchorProvider.defaultOptions() );
Quote
Report

Post Reply

Quoted from Forex.com.bd-Editorial External question — Solana Stack Exchange Author: papi Source score (net votes, not local likes): 0 Original post: https://solana.stackexchange.com/questions/15981 License: CC BY-SA 4.0 — https://creativecommons.org/licenses/by-sa/4.0/ Adaptation: HTML converted to plain text; contact email addresses removed. I wanna write a client to call program already deployed in devnet, below is the main part of my code const idl = require('../idl/idl.json'); const wallet = useAnchorWallet(); // Create the provider export const provider = new anchor.AnchorProvider( connection, wallet, anchor.AnchorProvider.defaultOptions() ); anchor.setProvider(provider); // Initialize the program const PROGRAM_ID = new PublicKey("dTwLMQBF1AR46Y3aufwQgXWaTCzgbFjyMEC9da3dV"); const program = new anchor.Program(idl as anchor.Idl, PROGRAM_ID, provider); and the code get the error Property 'connection' is missing in type 'PublicKey' but required in type 'Provider'.

Cancel quote

Checking account access…