Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to calculate transactionId in tag@v20.0.0-beta2? #460

Closed
Ryan3655 opened this issue Dec 14, 2018 · 2 comments

Comments

@Ryan3655
Copy link

commented Dec 14, 2018

Hi,
How to calculate the final transaction hash in the new version of eosjs?
Your help will be very much appreciated!! Thanks~~

tag@16.0.9
const buf = Fcbuffer.toBuffer(Transaction, txObject)
const tr = Transaction.toObject(txObject)
const transactionId  = createHash('sha256').update(buf).digest().toString('hex')
@c0d3ster

This comment has been minimized.

Copy link
Collaborator

commented Jan 3, 2019

If you are in a browser environment, you can use the SubtleCrypto web API to calculate the sha256 hash which can be found here. Be sure to create the hash from the serialized transaction (uInt8 array format), and if you want the hex format you can utilize the arrayToHex function from eosjs-serialize. I'm closing this for now, but let us know if you have any other questions. We'll add an example for reference in the future since this will likely be a common question.

@Ryan3655

This comment has been minimized.

Copy link
Author

commented Jan 24, 2019

Crypto.createHash("sha256").update(serializedTransaction).digest("hex");

This way can get a transaction hash

Thank you~~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
2 participants
You can’t perform that action at this time.