Algorand2 SDK Generating random Transaction hash for the transactions using TxId() method

Hi @fabrice
I am using Algorand2 SDK, below is my code to get the transaction hash for the transactions but it is returning random transaction hashes which are not matching with the explorer hash for the transaction

string ALGOD_API_ADDR = "http://1localhost:8887/";
string ALGOD_API_TOKEN = "8300d867cc2dbc9398dff961d0dbaefae8eaf8730217f5c468a358a4";

var httpClient = HttpClientConfigurator.ConfigureHttpClient(ALGOD_API_ADDR, ALGOD_API_TOKEN);
DefaultApi algodApiInstance= new DefaultApi(httpClient);
var blockinfo = await algodApiInstance.GetBlockAsync(211518);
foreach (var txndata in blockinfo.Block.Transactions)
{
    string trsnsactionHash=txndata.Tx.TxID();
}

The issue is that transactions read from the block API need to be processed before being able to compute their transaction ID.

See Calculating Transaction ID - #2 by fabrice
You can see some Go code for that there: indexer/util.go at a63f591c59bc64ea870c742b0197c072003ed0e6 · algorand/indexer · GitHub
You can adapt it to Java.

But the easiest solution is really to use an indexer.

PS: I’ve fixed indentation in code and wrote it between ``` to make it easier to read.

1 Like

Actually I think that issue is to do with the genesis id / hash stuff being missing in the block transactions…

@Sowna you can probably fix it by iterating over the transactions in the block and setting the missing genesis field(s) (I forget which ones but I think Fabrice linked to them). The TxId is a computed field, and when the node returns the transactions in the block, it “compresses” out the fields that belong to the block. Those then need to be re-added into the transaction to get the right id.

However, I should probably add a utility method in the SDK to be honest.

1 Like

Thank you @FrankS , It worked after setting the genesis fields.

1 Like

Hi @FrankS Signed transaction is not having Receiver Rewards, it is null here but explorer is having value . Can you please help me with this

Hey there. Don’t you wanna join the Discord? I am on the NET SDK channel there, but people will be able to help you out too if I am not around.

sure, I will join but do you have solution for above issue

Yeah I don’t understand the issue. I don’t know what “receiver rewards” is in this context.

Hi @FrankS ,
Using Algorand2 SDK able to get the blockdata which contains all the signed transactions
example for block no. 17497913
Transaction “M2JNAHUX2D4M3ZRYGCR5OJOW2OMAQNIXMVDJOAXWRIDFWVX6LTIQ” below the result where SenderRewards is null which supposed to be 0.000003

Please help me with this

Hi @fabrice , do you have any idea regarding this issue

Sorry I don’t know anything about the rewards mechanisms. You’ll get more help on Discord.

No problem @FrankS , I have posted the question in Discord channel