instantiate Wallets and Accounts
This section of the documentation focuses on the instantiation of Wallets and accounts using the Eniblock SDK.
Overview​
A "wallet" in the Eniblock SDK is essentially a collection of accounts. Each of these accounts is separate and can be dedicated to specific usages such as daily transactions, savings, investment funds, etc. Adding more accounts to a wallet has no adverse side effects on storage due to the mechanism of Hierarchical Deterministic (HD) wallets used for account creation.
Hierarchical Deterministic Wallets and Storage​
In a HD wallet, all accounts are derived from a single "master" seed. This master seed is used to generate a master private key and a corresponding master public key. From this master key pair, an almost infinite number of child key pairs (accounts) can be derived. Each of these child key pairs acts as an individual account within the wallet.
The beauty of this approach is that you can generate all of these child key pairs from the original seed. Hence, you don't have to store each key pair individually. You simply store the original seed. When you need to use a particular account, you can regenerate its key pair on-the-fly using the seed.
This approach significantly reduces storage requirements since you only need to store the seed instead of every key pair. Also, it enhances security since individual key pairs don't need to be stored and can be regenerated when needed. Furthermore, it simplifies backup since you only need to backup the seed to recover all accounts.
- Login (responsibility of the application creator): Your customer accesses your decentralized application (dApp) and "Login" or "Sign in".
- Instantiate a wallet ((responsibility of the application creator): At a suitable moment, such as during the login process, before minting or making a purchase, you instantiate the wallet with the SDK.
- Check identity(responsibility of Eniblock): Eniblock services verify the identity of the end-user based on the authentication performed by your IDP
- Distributed Key Generation(responsibility of Eniblock): the wallet, including its secret share, is generated specifically for the customer.
- Store secret share (responsibility of the application creator): You have to secure the wallet by saving the customer's secret share on their preferred cloud storage platform, safeguarding their assets: Store and retrieve a Wallet.
Prerequisites​
Before you begin, make sure you have the Eniblock SDK installed and imported into your project.
Instantiating a Wallet​
Follow these steps to instantiate a new wallet using the Eniblock SDK:
Instantiating a Second Account​
This code will create a second account within the same wallet instance. The second account will have a separate balance and address from the first account, but will be equally manageable through the wallet instance in the SDK.
API References​
- Eniblock class
- WalletNamespace.instantiate() method
- AccountNamespace.get() method
- Account.getAddress() method
- Account.alias property
- Account.getNativeBalance() method
- Account.getPublicKey() method
- Account.creationDate property
Next Steps​
When you instantiate a wallet, it is crucial to store it up to avoid losing access to your funds. Storing the wallet keys client share in a secure and reliable location is essential to prevent unauthorized access and ensure you can recover your wallet if needed.
To learn how to correctly store and retrieve a wallet, please follow the step-by-step tutorial: Store and retrieve a Wallet.
Once you have instantiated a wallet and instantiated an account, you can perform various actions like checking the account balance, sending and receiving assets.