hello-solana.ts 966 B

12345678910111213141516171819202122232425
  1. import * as anchor from "@coral-xyz/anchor";
  2. import { Program } from "@coral-xyz/anchor";
  3. import { HelloSolana } from "../target/types/hello_solana";
  4. describe("hello-solana", () => {
  5. // Configure the client to use the local cluster.
  6. const provider = anchor.AnchorProvider.env();
  7. anchor.setProvider(provider);
  8. // Generate a new random keypair for the data account.
  9. const dataAccount = anchor.web3.Keypair.generate();
  10. const wallet = provider.wallet;
  11. const program = anchor.workspace.HelloSolana as Program<HelloSolana>;
  12. it("Is initialized!", async () => {
  13. // Initialize a new data account
  14. const tx = await program.methods
  15. .new() // wallet.publicKey is the payer for the new account
  16. .accounts({ dataAccount: dataAccount.publicKey })
  17. .signers([dataAccount]) // dataAccount keypair is a required signer because we're using it to create a new account
  18. .rpc();
  19. console.log("Your transaction signature", tx);
  20. });
  21. });