text: const anchor = require('@project-serum/anchor');
  const fs = require('fs');
  const SystemProgram = anchor.web3.SystemProgram;
  
  const provider = anchor.Provider.local();
  anchor.setProvider(provider);
  
  let _myAccount;
  
  async function initialize() {
      const idl = JSON.parse(fs.readFileSync('./target/idl/basic1.json', 'utf-8'));
      const programId = new anchor.web3.PublicKey('53jvqj1KMZSJaLet5UTHXNFKT5fKcpdpULMhFaTczsXL');
  
      const program = new anchor.Program(idl, programId);
      // const program = anchor.workspace.Basic1;
  
      const myAccount = anchor.web3.Keypair.generate();
  
      await program.rpc.initialize(new anchor.BN(1234), {
          accounts: {
              myAccount: myAccount.publicKey,
              user: provider.wallet.publicKey,
              systemProgram: SystemProgram.programId,
          },
          signers: [myAccount],
      });
  
      _myAccount = await program.account.myAccount.fetch(myAccount.publicKey);
      console.log("initialized account:", _myAccount);
  }
  
  async function update(account) {
      const myAccount = account;
  
      const idl = JSON.parse(fs.readFileSync('./target/idl/basic1.json', 'utf-8'));
      const programId = new anchor.web3.PublicKey('53jvqj1KMZSJaLet5UTHXNFKT5fKcpdpULMhFaTczsXL');
  
      const program = new anchor.Program(idl, programId);
  
      await program.rpc.update(new anchor.BN(4321), {
          accounts: {
              myAccount: myAccount.publicKey,
          },
      });
  
      const _account = await program.account.myAccount.fetch(myAccount.publicKey);
      console.log("updated account:", _account);
  }
  
  async function main() {
      initialize().then(
          idata => {
              console.log("initialize sucess. Data: ", idata);
              update(_myAccount).then(
                  udata => {
                      console.log("update sucess. Data: ", udata);
                  },
                  uerr => console.log("update error:", uerr)
              );
          },
          ierr => console.log("initialize error:", ierr)
      )
  }
  
  main().then(
      () => console.log("Program successful"),
      err => console.log("Error: ", err));