5 things to know when building on IOTA

The full article was originally published by Phani on Medium. Read the full article here.

Here are a few lessons learned while working on IOTA for the past 4 months.

1. Attaching addresses to Tangle

A new address can be generated using getNewAddress API method. The libraries/API do not attach the address to the Tangle automatically for you. You can always successfully send IOTAs to non-attached addresses but it is recommended to attach an address before using it.

You can attach it by sending a zero-value transaction.

Wait a minute! Then what would be the source address?

Good question, in IOTA, a zero-value transaction bundle does not have (or need) a source address. So, your source address will be the destination address you want to attach.

2. Javascript vs Java IOTA(JIOTA) client lib

The IOTA javascript library is simple to use. The Java library has almost the same inbuilt function names. Minor heads up, “optional” parameters in Javascript are to be replaced by empty (equivalent to the argument type) in Java. Always good to check the Java documentation before making an assumption.

Also, there can be few caveats with optional parameter assumption. The optional parameter is not an empty string but an equivalent null. Below is a simple prepareTransfers method:

List <String> trytes = jiota.prepareTransfers(seed, security, transfers, remainderAddress, inputs, tips, validateInputs);

Here remainderAddress is an optional param. When

String remainderAddress = "";

remainderAddress is an empty string, it would work fine for 0 value transactions but would fail for any > 0i value transactions. The correct way to make it optional is setting to null.

String remainderAddress = null;

3. Promoting vs Reattaching

When the transaction is pending for a long time, it is unlikely to be accepted because the tip selection algorithm favors newer transactions. Users that are in a hurry to see their transaction confirmed are thus likely to rebroadcast it.

Rebroadcasting can be done by “promote” or “reattaching”. In practice “promoting”, which involves the creation of a zero value transaction, appears to be more effective.

The difference is promoting will create a zero value transaction and is now the top of Tangle and is more likely to get confirmed by other transactions, whereas, reattaching we create a new transaction with the same signed bundle as the original.

Not all transactions can be promoted. In IOTA.js, there is a handy method isPromotable that tells you if a tail transaction can be promoted or not.

Read the full Article

The full article was originally published by Phani on Medium, where people are continuing the conversation by highlighting and responding to this story.

You might also like

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. AcceptRead More

Did you know?

Buy in without the stress of trying to time the market

when you setup a savings plan. If you haven’t started a plan yet, head to your Bitpanda account to get started!

Purchasing cryptocurrencies comes with a number of risks.
Never invest money that you can't afford to lose.

You can automatically invest

in IOTA with Bitpanda Savings!