1

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
        console.log(err);
    });
  }catch(e){
    console.log(e)
  }
},
matt
  • 13
  • 2

1 Answers1

1

The following code returns the tail transaction hash:

.then(bundle => bundle[0].hash)
chris
  • 36
  • 3