12

I was debugging an issue in our backend where two parallel transaction ended up having the same Transaction ID.

This is what Solana docs say about the Transaction ID:

Transaction ID
The first signature in a transaction, which can be used to uniquely identify the transaction across the complete ledger.

Here's an excerpt from the docs for sendTransaction RPC call:

The returned signature is the first signature in the transaction, which is used to identify the transaction (transaction id).
This identifier can be easily extracted from the transaction data before submission.

Does this mean that the transaction signature doesn't depend on the on chain state?

If I have a transaction with an instruction AddOne which does something like program_data.x += 1, the instruction data will be constant right? So the transaction signature will also be the same?

5
  • 1
    Does this answer your question? How to generate the hash of a transaction?
    – trent.sol
    Jul 13, 2022 at 6:33
  • No it just shows the steps of retrieving the signature from the JS transaction object before sending it.
    – itsfarseen
    Jul 13, 2022 at 6:56
  • The transaction ID is the first signature (that of the fee-payer) of a transaction
    – trent.sol
    Jul 13, 2022 at 7:03
  • 1
    Or perhaps the question should be reworded to instead ask which data the signature covers?
    – trent.sol
    Jul 13, 2022 at 7:14
  • 1
    I have reworded the title :)
    – itsfarseen
    Jul 13, 2022 at 7:15

1 Answer 1

14

The signature is a 64-byte ed25519 signature, which is a hash, based on the instructions and a recent (latest) blockhash. This blockhash makes the signature unique from other identical instructions. It indeed does not depend on the on-chain state of any account info.

It's therefore possible that a transaction is signed two times with an identical blockhash. This can practically happen if you create a burst of transactions, for instance in a parallel application.

5
  • So we can send only one transaction with the same data per block?
    – itsfarseen
    Jul 13, 2022 at 7:14
  • 5
    Same hash (signature) per block. Yes. If you want to send more instructions in one block, just add extra instructions to your transaction.
    – Omega
    Jul 13, 2022 at 7:19
  • 5
    Please take care when referring to Solana transaction IDs, they are always signatures and never hashes. In my experience, some folks confuse this terminology with the transaction's recent_blockhash field, which is used as a cluster-specific nonce
    – trent.sol
    Jul 13, 2022 at 7:34
  • I briefly adapted the answer. Though, in my opinion a signature is still a hash, but I understand the confusion it can cause.
    – Omega
    Jul 13, 2022 at 9:21
  • 2
    @itsfarseen technically you could just use a different blockhash as the recent_blockhash - you can gather a rolling couple hundred valid recent blockhashes at any given time. Jul 13, 2022 at 21:07

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.