Skip to content

Instantly share code, notes, and snippets.

@0xdeepmehta
Created December 10, 2022 18:02
Show Gist options
  • Save 0xdeepmehta/ecd76bfe08dfa2bc50c54e14a3de2461 to your computer and use it in GitHub Desktop.
Save 0xdeepmehta/ecd76bfe08dfa2bc50c54e14a3de2461 to your computer and use it in GitHub Desktop.
import * as anchor from "@project-serum/anchor";
import { Program } from "@project-serum/anchor";
import { HelloSupersec } from "../target/types/hello_supersec";
describe("hello-supersec", () => {
// Configure the client to use the local cluster.
const provider = anchor.AnchorProvider.env();
anchor.setProvider(provider);
const program = anchor.workspace.HelloSupersec as Program<HelloSupersec>;
it("hello-playload", async () => {
const magicString = "Hey Superfam."; // INPUT ACCTACK PAYLOAD
const tx = await program.methods.challange(magicString);
const challKey = (await tx.pubkeys()).challAccount;
const txHash = await tx.rpc()
console.log("Your transaction signature", txHash);
const confirmTx = await provider.connection.getSignatureStatus(txHash);
if (confirmTx.value?.confirmationStatus === "confirmed") {
try {
const tx = await program.account.challAccount.fetch(challKey);
if (tx.pawned === true) {
console.log("Fam, you did it. 🎉");
console.log(" This is your first breakthrough, but the road ahead is not as simple as it appears. You must work hard, but it is exciting.");
} else {
console.log("Sorry need to grind more 🏄‍♂️");
console.log("The one who falls and gets up is stronger than the one who never tried.");
}
} catch (e) {
console.log(e);
}
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment