How to derive steem transaction id in Javascript

View this thread on: d.buzz | hive.blog | peakd.com | ecency.com
·@gobright12·
0.000 HBD
How to derive steem transaction id in Javascript
# 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
```javascript
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));
});

```
👍 ,