https://github.com/jimvdH/react/blob/main/src/utils/anchorClient.js Here is the code i am trying to use.

I am trying to connect to a live smart contract https://solscan.io/account/Goats192jeQq3r2sn8pe69LyJtisLMfEoq8LyDienct1#anchorProgramIDL and interact with it. In this case use the withdraw function.

Whenever I run this code I get the following error in the web console.Calling the withdraw function when pressing the shoot button.

provider.ts:104 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'publicKey') at w.send (provider.ts:104:31) at Object.withdraw (rpc.ts:25:38) at Object.withdraw (anchorClient.js:86:32) at async submitJoke (JokeArena.js:18:9)

And when I click on the provider.ts error log I get the following Could not load content for http://localhost:1234/__parcel_source_root/node_modules/@project-serum/src/provider.ts (HTTP error: status code 404, net::ERR_HTTP_RESPONSE_CODE_FAILURE)

Hope someone can help me! Thank you in advance!

In the anchorClient.js I am running the following code

const privateKey =[54,32,etc];
const wallet1 = web3.Keypair.fromSecretKey(new Uint8Array(privateKey));
const withdraw = async (wallet, network) => {
    const pairAddress = new PublicKey('4RsEwVg3gw6MX1PrXkdXJLwatUDDxK5o9hPFJP8keYS3');
    const pairAuthorityAddress = new PublicKey('GWJ26hQgem1t64E9HnfL23KRbBBC9H6rUCXqvPmx9SE2');
    const program = await getProgram(wallet, network);
    const amount = new BN(99);
   const tx =await program.rpc.withdraw(amount, {
        accounts: {
            pair: pairAddress,
            pairAuthority: pairAuthorityAddress,
            owner: wallet1.publicKey,
            systemProgram: web3.SystemProgram.programId,
        signers: [wallet1], 
    console.log('Withdrawal successful');
} ```

1 Answer 1


It's tough to tell from the limited code, but it looks like there's a problem with wallet not being a real signer.

Since it looks like wallet1 is a keypair, and we don't know what wallet is, try using wallet1 everywhere by changing program's creation to:

    const program = await getProgram(wallet1, network);
  • Thank you, I forgot to give the wallet parameter to the signer so that was the reason it didn't work.
    – progj
    Commented Dec 19, 2023 at 10:15

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.