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)
  }
},

1 Answer 1

1

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 and acknowledge that you have read and understand our privacy policy and code of conduct.

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