0

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();
      anchor.setProvider(provider);
    
      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 })
         .signers([dataAccount]).rpc();
       console.log("Your transaction signature", tx);
    
       const val1 = await program.methods.get()
         .accounts({ dataAccount: dataAccount.publicKey })
         .view();
    
       console.log("state", val1);
    
       await program.methods.flip()
         .accounts({ dataAccount: dataAccount.publicKey })
         .rpc();
    
    
       const stringSing = await program.methods.sing("I am saurav").accounts({dataAccount:dataAccount.publicKey}).rpc()
    
       console.log("stringSing",stringSing)
    
       const stringValue = await program.methods.line().accounts({dataAccount:dataAccount.publicKey}).view()
    
       console.log("value",stringValue)
      }
    
      check()

this is my anchor.toml file : 
[features]
seeds = false
skip-lint = false
[programs.localnet]
starter = "C5fvGN6yt7UCPcShNNfDZdjgjf6mbmhVMAD3hwY7N6bY"

[registry]
url = "http://localhost:8899/"

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

[scripts]
test = "yarn run ts-mocha -p ./tsconfig.json -t 1000000 tests/**/*.ts"
1
  • 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

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.