this is my code and error is occur when i calling new method :

 import * as anchor from "@coral-xyz/anchor";
    import { Program } from "@coral-xyz/anchor";
    import { Starter } from "../target/types/starter";
      // Configure the client to use the local cluster.
      const provider = anchor.AnchorProvider.env();
      const dataAccount = anchor.web3.Keypair.generate();
      const wallet = provider.wallet;
      const program = anchor.workspace.Starter as Program<Starter>;
     async function check(){
         // Add your test here.
         const tx = await program.methods.new(wallet.publicKey)
         .accounts({ dataAccount: dataAccount.publicKey })
       console.log("Your transaction signature", tx);
       const val1 = await program.methods.get()
         .accounts({ dataAccount: dataAccount.publicKey })
       console.log("state", val1);
       await program.methods.flip()
         .accounts({ dataAccount: dataAccount.publicKey })
       const stringSing = await program.methods.sing("I am saurav").accounts({dataAccount:dataAccount.publicKey}).rpc()
       const stringValue = await program.methods.line().accounts({dataAccount:dataAccount.publicKey}).view()

this is my anchor.toml file : 
seeds = false
skip-lint = false
starter = "C5fvGN6yt7UCPcShNNfDZdjgjf6mbmhVMAD3hwY7N6bY"

url = "http://localhost:8899/"

cluster = "Localnet"
wallet = "/home/saurav/.config/solana/id.json"

test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
  • If you're on anchor-cli v 0.28.0 run anchor keys sync. If not, run anchor keys list and then copy the displayed program ID to match that in declare_id!() in lib.rs, and also update the program-id in anchor.toml to match.
    – Ademola
    Commented Aug 19, 2023 at 20:46

1 Answer 1


Have you checked the program ID you have written in your Rust code?

declare_id!("THE ID")

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.