client.js 651 B

1234567891011121314151617181920212223
  1. const anchor = require('@project-serum/anchor');
  2. // Configure the local cluster.
  3. anchor.setProvider(anchor.Provider.local());
  4. async function main() {
  5. // #region main
  6. // Read the generated IDL.
  7. const idl = JSON.parse(require('fs').readFileSync('./target/idl/basic_0.json', 'utf8'));
  8. // Address of the deployed program.
  9. const programId = new anchor.web3.PublicKey('<YOUR-PROGRAM-ID>');
  10. // Generate the program client from IDL.
  11. const program = new anchor.Program(idl, programId);
  12. // Execute the RPC.
  13. await program.rpc.initialize();
  14. // #endregion main
  15. }
  16. console.log('Running client.');
  17. main().then(() => console.log('Success'));