I see using sendTrytes you would get an bundle, but can I get hash from the bundle and return to me?

const transfers = [ { value: 0, address: address, message: message, tag: "SD" } ];

iota.prepareTransfers(seed, transfers)
    .then(trytes => {
        return iota.sendTrytes(trytes, 3/*depth*/, 14/*minimum weight magnitude*/)
        //min mwm is 9 for devnet, 14 for mainnet
    .then(bundle => {
        console.log(`Bundle: ${JSON.stringify(bundle, null, 1)}`)
        console.log('.then:', JSON.stringify([bundle["bundle"].hash])['hashes'][0])
        return bundle;
    .catch(err => {
        // Catch any errors

The following code returns the tail transaction hash:

.then(bundle => bundle[0].hash)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.