client.js 711 B

123456789101112131415161718192021222324
  1. // client.js is used to introduce the reader to generating clients from IDLs.
  2. // It is not expected users directly test with this example. For a more
  3. // ergonomic example, see `tests/basic-0.js` in this workspace.
  4. const anchor = require("@coral-xyz/anchor");
  5. // Configure the local cluster.
  6. anchor.setProvider(anchor.AnchorProvider.local());
  7. async function main() {
  8. // #region main
  9. // Read the generated IDL.
  10. const idl = require("./target/idl/basic_0.json");
  11. // Generate the program client from IDL.
  12. const program = new anchor.Program(idl);
  13. // Execute the RPC.
  14. await program.rpc.initialize();
  15. // #endregion main
  16. }
  17. console.log("Running client.");
  18. main().then(() => console.log("Success"));