import { Connection, Keypair, PublicKey, clusterApiUrl } from "@solana/web3.js";
import { Program, setProvider, web3, AnchorProvider } from "@coral-xyz/anchor";
import { NodeStringSaver, IDL } from "../target/types/node_string_saver";
import "dotenv/config";
import NodeWallet from "@coral-xyz/anchor/dist/cjs/nodewallet";
import { bs58 } from "@coral-xyz/anchor/dist/cjs/utils/bytes";
const connection = new Connection(clusterApiUrl("devnet"));
const program = new Program<NodeStringSaver>(
IDL,
new PublicKey("LwLEiVLfLitKwkTSo6rScZspxTF1PfeEX8HBp71LCHE"),
{
connection,
}
);
const keyPair = Keypair.fromSecretKey(
bs58.decode(process.env.PRIVATE_KEY ?? "")
);
const wallet = new NodeWallet(keyPair);
const provider = new AnchorProvider(connection, wallet, {
commitment: "processed",
});
setProvider(provider);
const start = async () => {
const myAccount = web3.Keypair.generate();
await program.methods
.initialize("Users")
.accounts({
stringHolder: myAccount.publicKey,
signer: provider.wallet.publicKey,
systemProgram: web3.SystemProgram.programId,
})
.signers([myAccount])
.rpc();
console.log(await program.account.stringHolder.all());
};
start();
and this is my error Error: This function requires 'Provider.sendAndConfirm' to be implemented.