How can I generate an ID of a transaction before submitting it to an RPC node? I know I can get a transaction signature as a result of web3.sendAndConfirmTransaction call but is it possible to generate the signature deterministically?

  • 1
    Transaction IDs on Solana are signatures (signature[0]), not hashes. I'd suggest updating your question to clarify this fact and avoid propagating misinformation
    – trent.sol
    Commented Jul 12, 2022 at 23:25
  • This was supposed to be a question from a person who comes from EVM background (who from my perspective comprise the bigger part of devs coming to Solana). Commented Jul 13, 2022 at 19:33
  • No sense misinforming them. Accuracy is key to understanding
    – trent.sol
    Commented Jul 13, 2022 at 20:21

1 Answer 1


You can manually sign the transaction before sending it, and then retrieve signature:

const bs58 = require('bs58');

// build a transaction
const transaction = new Transaction(...);

// sign it explicitly

// retrieve the signature as base58
const signature = bs58.encode(transaction.signature())

You will need to already have a blockhash defined and set against the transaction for this to work.

This will not work with sendTransaction, which re-signs everything. So serialize the message directly to send:

const message = transaction.serialize();

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.