Skip to content

Instantly share code, notes, and snippets.

@0xDeeep
Created December 10, 2022 18:02
Show Gist options
  • Save 0xDeeep/ecd76bfe08dfa2bc50c54e14a3de2461 to your computer and use it in GitHub Desktop.
Save 0xDeeep/ecd76bfe08dfa2bc50c54e14a3de2461 to your computer and use it in GitHub Desktop.

Revisions

  1. 0xDeeep created this gist Dec 10, 2022.
    38 changes: 38 additions & 0 deletions hack.ts
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,38 @@
    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);
    }
    }
    });
    });