This forum is a read-only archive. Posting, replying and signing in are disabled.

Are transaction signatures unique?

Starscream

Is it possible to have 2 transactions with the same signature when using the same private key?

scholtz

On Algorand the hash of the transaction is transaction id. So if you attempt to create same transactions it will be one transaction and second time you try to add it to the blockchain it will tell you that it is already there.

If you want them to be unique, add there nonce, make the transaction note field different or change for example valid until time.

When you sign the transaction you always sign all data, so technically it is not possible to create two transactions with same valid signature.

Starscream

How do I obtain TxID of a transaction on the blockchain? I am using algod API, but do not see “txid” anywhere when I query a block. I’m not interested in using indexer.

edited
scholtz

I use for example this method to calculate txId from core algod data

Starscream

Is there a way to do this without using the SDK? I mean, using any programming language, is there a generic formula to calculate the TxID from the JSON information on a block provided by the algod API?

scholtz

all sdks are open source so technically you can calculate it on your own… the txid is just the hash of something so it should not be difficult

Starscream

Would you happen to know exactly what the formula is? I can’t seem to find it anywhere.

scholtz

I still dont know what language you are coding in…

Starscream

Thanks. But how am I suppose to get the TxID from the algod JSON response that looks like this:

{
  "block": {
    "earn": 27521,
    "fees": "A7NMWS3NT3IUDMLVO26ULGXGIIOUQ3ND2TXSER6EBGRZNOBOUIQXHIBGDE",
    "frac": 2061697303,
    "gen": "testnet-v1.0",
    "gh": "SGO1GKSzyE7IEPItTxCByw9x8FmnrCDexi9/cOUJOiI=",
    "prev": "blk-5VT353VFJZQU4CAW3JK5JKZLCJ4MJFANEA7C76LRAJV77BK2TD3A",
    "proto": "https://github.com/algorandfoundation/specs/tree/abd3d4823c6f77349fc04c3af7b1e99fe4df699f",
    "rnd": 32161726,
    "rwcalr": 32500000,
    "rwd": "7777777777777777777777777777777777777777777777777774MSJUVU",
    "seed": "gKpQ4G4LdhREw5bw86wCU+sG5oFEISMjGNGLQ3wy7Fc=",
    "spt": {
      "0": {
        "n": 32161792
      }
    },
    "tc": 275213679,
    "ts": 1692057423,
    "txn": "RMrqMRugJyEFVsZQb8pUCoUWKwXwDbSo5+zA6ol/xU4=",
    "txn256": "KWxIx/ANMp8SY83Cv3OhYd3jha8OLYt3HV/12LSjo5Y=",
    "txns": [
     ...,
      {
        "hgi": true,
        "sig": "fKpBB24QFNl4trtdhNNjmqmbpWear8MxtbbPyLWzngm6Ki4k1pgAVVdEC2R75kqdDGtiDAo3cmcfu6dX6No9Bg==",
        "txn": {
          "fee": 1000,
          "fv": 32161724,
          "lv": 32162724,
          "note": "eyJ0eF90eXBlIjogImNoZWNrX2luIiwgInR5cGUiOiAibSIsICJsb2NhdGlvbiI6IHsibG9jYXRpb25fbmFtZSI6ICIzMDMwIiwgImxvbmdpdHVkZSI6IDMwLCAibGF0aXR1ZGUiOiAzMH0sICJpc19hc2xlZXAiOiBmYWxzZSwgIm5vdGljZV9vZl9tZWV0aW5nIjogW119",
          "rcv": "6WMABAAUQSBYXEN7ARZX7FYO3N65IVMR6HCF7GPWM36YR6XXITEMRBMHQY",
          "snd": "3ELSBOZDRV2BSCI4W3QSRFC4KXD3K6YSJ722GRKHOSLCCOJYBWPS4PKRH4",
          "type": "pay"
        }
      }
    ]
  }
}

By the way, I am using the Ruby language.

scholtz

Sorry, i cannot help you with ruby… i know typescript and this is how it is done there:

Perhaps someone from algoand can help? The best would be to write on algorand discord to dev channel…

scholtz

i think it is true right now, but in 10 years period many things can change…