IOTA Tutorial 11 | Attach Address To Tangle
Attach Address To Tangle
In this video series different topics will be explained which will help you to understand IOTA. It is recommended to watch each video sequentially as I may refer to certain IOTA topics explained earlier.
The IOTA Light Wallet is a stateless wallet, meaning all information such as balance and which address is in use are retrieved from the Tangle. The IOTA Light Wallet does not store any information on your computer. The Trinity Wallet retrieves information from the Tangle and some of this information is stored on your computer. Therefore the Trinity Wallet is called a stateful wallet. The information provided in this video applies to the IOTA Light Wallet. When making this video the Trinity Wallet was not released.
When you attach an address to the Tangle, you create a transaction where you transfer 0 IOTA to the address. When the address is attached to Tangle, the transaction is ALWAYS pending. Example (using iota.lib.js v0.4.6).
In the example, you will notice the following:
- The transaction bundle contains only one transaction, indicated by lastIndex = 0.
- The transaction does not have a signature.
- The transaction references two unreferenced transactions (aka tips), see the trunkTransaction and branchTransaction hashes.
- The transaction has a nonce, which means it had to do PoW.
The purpose of attaching an address to Tangle is to prevent the re-use of the address’s private key. If you attach an address to Tangle you indicate that the address is in use or will be in use. A way to find a non-attached address, repeat the following steps:
- If an address is in use, call the getNewAddress API to get the next address. The getNewAddress API can deterministically generate addresses.
- Next call the findTransactions API to check if an address is in use.
You can always successfully sent IOTAs to non attached addresses but it is recommended to attach an address first before using it.
When you use the IOTA Light Wallet apply the following rules:
- For every RECEIVING payment always create a new address and attach this address to the Tangle before handing out this address. This address should only be used once!
- After a snapshot attach the same number of addresses you had before the snapshot.
These two rules will prevent you, using an address more than once for outgoing transactions when using the IOTA Light Wallet.
To use the same IOTA address to receive regular payments, for example an IOTA donation address, use the following procedure:
- Create a separate wallet by creating a new seed.
- Use this wallet only to RECEIVE regular payments and do not create any outgoing transactions from this wallet.
- When you decide to withdraw from this wallet, it is recommended to withdraw the complete balance.
- Once the complete balance is withdrawn, attach a new address to the Tangle and use this new address to receive regular payments again.