akegaviar / ton-foo

MIT License
0 stars 0 forks source link

How we generate a Transaction Hash in the TON Blockchain? #490

Open akegaviar opened 4 months ago

akegaviar commented 4 months ago

As mentioned in this question: "3) Poll for the latest transactions from the Blockchain using your wallet account ID and match the transaction using the pre-generated hash" (source).

My question is, how is the transaction hash generated or calculated in general?

I understand that we have a public key for signing.

Answer

You can generate hash with boc before transaction or after transaction with response boc.


const bocCell = TonWeb.boc.Cell.oneFromBoc(TonWeb.utils.base64ToBytes(response.boc));

const hash = TonWeb.utils.bytesToBase64(await bocCell.hash());

Original