5

Say I have a script to generate addresses automatically, how can I attach it to the tangle using the library?

From the Javascript library I see that these are the parameters:

*   @param {string} trunkTransaction
*   @param {string} branchTransaction
*   @param {integer} minWeightMagnitude
*   @param {array} trytes

If I just want to simulate the official wallet to attach a new address, how can I prepare those parameters?

  • Why not just use sendTransfer by providing zero value tx with your addresses? – Akkumulator Feb 2 '18 at 7:20
3

Attaching an address is just sending a 0 value tx to this address.

You can use the sendTransfer method of the JavaScript library. It handles the tip-selection (branch- and trunkTransaction) and conversion to trytes for you.

var transfers = [{
    'address': addressToAttach,
    'value': 0,
  }]
var minWeightMagnitude = 14 // as in the light-wallet
var depth = 3
iota.api.sendTransfer(seed, depth, minWeightMagnitude, transfers, (e, bundle) => {})
  • It's sendTransfer method deprecated? – Albert Olivé 3 hours ago

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.