Accounts and Addresses
Since the Chrysalis protocol, addresses in the IOTA/Shimmer ecosystem are reusable. This means you map them to your users in a clear and concise way. You can use your seed to generate any number of accounts. You create one account for each user or use a single account and generate multiple addresses, which you can then link to the users in your database.
Accounts
Accounts are related to a specific IOTA or Shimmer Layer 1 Network. You can create as many accounts as you want per seed, and then use those accounts to generate as many addresses as you want.
Addresses
The client libraries use the BIP32 method to generate addresses as Ed25519 key pairs generated that follow the BIP44 logical hierarchy.
Account Approaches
The client libraries also allow you to assign a meaningful alias to each account. Since addresses are reusable, they can be mapped to your users in a clear and concise way.
Multi-Account Approach
You should use the multi-account approach if you want to create an account for each individual user. You can link the accounts to the internal user IDs as an account alias, which are distinctly separated.
Single Account Approach
You should use the single account approach if you want to create a single account and then create an address for each user. You will need to link the associated addresses to the internal user IDs and store who owns which address in a database. Most exchanges are familiar with the single account approach and find it easier to use, implement, and backup.
BIP32 - Tree Structure
The BIP32 standard describes an approach to Hierarchical Deterministic Wallets. The standard was improved by BIP44.
This standard defines a tree structure as a base for address and key space generation which is represented by
derivation path
:
m / purpose / coin_type / account / change / address_index
m
: A master node (seed).purpose
: A constant which is {44}.coin_type
: A constant set for each cryptocurrency. IOTA = 4218, for instance.account
: Account index. Zero-based increasingint
. This level splits the address/key space into independent branches (ex. user identities) which each has own set of addresses/keys.change
: Change index which is{0, 1}
, also known aswallet chain
.
There are two independent chains of addresses or keys. 0
is reserved for public addresses (to receive coins) and 1
is
reserved for internal addresses (also known as change) to which transaction change is returned. Since IOTA/Shimmer allows address
reuse, it is valid to return transaction change to the same originating address.
address_index
: Address index. Zero-based increasingint
that indicates an address index.
As outlined, there is quite a large address/key space that is secured by a single unique seed.
And there are few additional interesting notes:
- Each level defines a completely different subtree (subspace) of addresses/keys, and those are never mixed up.
- The hierarchy is ready to "absorb" addresses/keys for many coins at the same time (
coin_type
), and all those coins are secured by the same seed. This means any BIP32/44-compliant wallet is potentially able to manage any \ BIP32/44-compliant coin(s). - There may be also other
purposes
in the future. However, consider a single purpose for now. The constant44
stands for BIP44. - The standard was agreed upon by different crypto communities, although not all
derivation path
components are always in active use. For example,account
is not always actively leveraged across the crypto space (if this is the case thenaccount=0
is usually used). - Using different
accounts
may be useful to split addresses/keys into some independent spaces, and it is up to developers to implement. _Using differentaccounts
may have a negative impact on a performance while you are on the account discovery phase. If you are planning on using many multiple accounts then you may be interested in our stateful library wallet.rs that incorporates all business logic needed to efficiently manage independent accounts. Our exchange guide provides some useful tips on how different accounts may be leveraged.
In case of IOTA, the derivation path of address/key space is [seed]/44/4218/{int}/{0,1}/{int}
. The levels purpose
and coin_type
are given, the rest levels are up to developers to integrate.