let tx = await program.methods.initialize(a,b).accounts({
        addAccount: addAccount.publicKey,
        user: provider.wallet.publicKey,
        systemProgram: SystemProgram.programId,

at user line i am getting error.

1 Answer 1


Use the variable defined for useAnchorWallet() instead

const anchorWallet = useAnchorWallet();

let tx = await program.methods.initialize(a,b)
.accounts({ addAccount: addAccount.publicKey, user: anchorWallet.publicKey, systemProgram: SystemProgram.programId, })

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.