How to derive steem transaction id in Javascript

in #transactionid7 years ago (edited)

Preparation

Install steem and sha256 npm package
npm install --save steem sha256

Reference

Please refer to below post for creating steem transaction object:
https://steemit.com/steem/@xeroc/steem-transaction-signing-in-a-nutshell

Derive Steem Transaction Id

const sha256 = require('sha256');
const steem = require('steem');

// I will assume that you have already made your transaction object
// const tx;

// signatures are not part of transaction id
tx.signatures = [];

steem.api.getTransactionHex(tx, (err, txHex) => {
  console.log('transaction id:', sha256(new Buffer(txHex.slice(0, -2), 'hex')).slice(0, 40));
});

Sort:  

Congratulations @gobright12! You received a personal award!

Happy Birthday! - You are on the Steem blockchain for 2 years!

You can view your badges on your Steem Board and compare to others on the Steem Ranking

Vote for @Steemitboard as a witness to get one more award and increased upvotes!