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.

iotaJs.isPromotable(tail);

However, in JIOTA(Java) you can try to promote a bundle using below method. It will throw NotPromotableException if it is not possible to promote the bundle. In that case, you have to try reattaching it.

try {

iota.promoteTransaction(tail, depth, minWeightMagnitude, bundle);

} catch (NotPromotableException e) {

// try reattaching

}

Here is an example of a basic transaction in latest (1.0.0-beta2) Iota.js https://gist.github.com/pasupulaphani/e22048046bd893f19678ec9595595b6d and JIOTA(JAVA) https://gist.github.com/pasupulaphani/45ac4989bacca6c79057bc40028e45bc

4. Documentation and library versioning

Not only the IOTA network but also the IOTA libraries in many programming languages are being developed very actively. Major versions are in beta right now. Most of the Google searches point to older version fo IOTA API, it would save a lot of time to ensure the version of the docs you are checking against.

Pro tip: The library code is well maintained along with code comments. So, it is quite easy to read the code implementation directly.

Java doc: https://iotaledger.github.io/iota-java/javadoc/overview-summary.html

5. IOTA nodes and Remote Proof of Work

You can run your own IOTA node easily. However, if you are looking for a load balanced node, the community has recommended using https://nodes.thetangle.org:443

as a provider. It even offers very good response times for remote PoW which is great, especially for mobile users.

The IOTA community is very active on Discord. Here you will get quick responses from expert IOTA developers than anywhere else.