Can I get txn hash without injecting operation in block chain? After injecting I will get same txn hash?
1 Answer
You can forge operations remotly using a node, with the rpc : /chains/main/blocks/head/helpers/forge/operations. This is a POST request, you have to give a json file like: { "branch" : block_hash, "contents" : operation list}. Operation type is a bit tricky, you can find some documentation in http://tezos.gitlab.io/mainnet/api/rpc.html#post-block-id-helpers-forge-operations. So the hash of the operation depends on the "branch" which is normally taken as the head hash. If you inject it with the same "branch" it will have the same hash, but be careful since the "branch" becomes invalid after 64 levels. If you are using the client, you can also use the transfer command with the -D option as "dry-run", that will do all the work of forging and checking but only do a fake injection.
-
1After you forged an op you have to sign it, append the signature to the data vector, take blake2b hash (32 bytes) of it, prepend 0x0574, and base58 encode the result. Aug 6, 2019 at 9:03
-
Use injection/operation data h := blake2b.Sum256(rawBytes) hash := CheckEncode(h[:], opPrefix) Jul 23, 2020 at 7:06