3

Background:

In my application I am creating an account to store some arbitrary information.

I then want to display the transaction id/address of the transaction that created such an account.

Question:

Does anyone know how to do this without storing the transaction id immediately after executing the transaction?

Options:

One option is to look up the account address and then fetch the very first transaction id (since this created the account, right?). If this is the only solution, does anyone know how to go about this in terms of the Solana Javascript SDK?

Are there other solutions?

1 Answer 1

1

Try this one:

    let before: string;
    while (true) {
      const signatures = await this.connection.getSignaturesForAddress(
        new PublicKey(address),
        {
          300, // limit
          undefined, // until
          before,
        },
      );
      if (signatures.length > 0)
        before = signatures[signatures.length - 1].signature;
      if (signatures.length < limit) {
        console.log("Genesis transaction hash:", before);
        break;
      }
    }

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.