Store a Wallet on a Remote Drive
This section of the documentation focuses on the importance of storing a wallet.
Overview​
During the development of a web application that incorporates a wallet, you can choose to store it in the browser's local storage. This default storage approach makes the implementation of the wallet easier for developers, thus streamlining the testing process and the development of new features.
However, it is crucial to understand that this method of storing the wallet in local storage MUST NOT be used in a production environment. Local storage does not provide the necessary security measures to protect sensitive data such as wallet keys share and can be easily lost if the browser cache is cleared.
For a production application, it is highly recommended to use a more reliable storage method, such as a remote drive (e.g., Google Drive or Dropbox). These remote storage solutions provide robust security features, data encryption, and backup options, ensuring the safety and accessibility of the wallet data.
Storing a Wallet​
In this code snippet, we demonstrate how to set up and utilize the SDK for storing a wallet. The script initiates the SDK with a provided client ID, stores the wallet to the user's Google Drive. This serves as a foundation example for developers who are looking to build and manage a wallet using the SDK.
Retrieving a Wallet​
Retrieving the wallet is completely transparent to the developer, as it is integrated into the instantiate method of the Wallet namespace.
References​
- Eniblock class
- WalletNamespace.instantiate() method
- AccountNamespace.get() method
- Account.getAddress() method
- Account.alias property
- Account.getNativeBalance() method
- Account.getPublicKey() method
- Account.creationDate property
Store a wallet with Google Drive​
Step 1: Create a Google Cloud Platform (GCP) Project​
Visit the Google Cloud Platform Console.
Sign in with your Google account or create a new account if you don't have one.
Click on the project dropdown and select or create the project you want to use for your web app.
Click on the project dropdown
Create the project you want to use for your web app
Name and save your new projectSelect your new project
Step 2: Enable Google drive API​
Enter in the "Enable APIS AND SERVICES" section
Select "Google Drive API" and enable the API
Step 3: Set Up OAuth 2.0 Consent Screen​
Navigate to the "APIs & Services" dashboard
From the dashboard, click on "Explore and enable APIs"
From the dashboard, click on "Click on "Credentials."Open the consent screen configuration
Click on "Configure consent screen"Select the appropriate User Type for your app
Create your consent screenFill the consent screen configuration
Fill all the consent screen configurationEdit scopes
Click on "ADD OR REMOVE SCOPES"Add manually a new scope
https://www.googleapis.com/auth/drive.appdataOptionnaly, function of the User Type, add Test users.
Step 4: Set Up OAuth 2.0 Client IDs​
Select Credentials
Click on "Create credentials" and select "OAuth client ID."Set the application type
Choose "Web application" as the application type.Fill in the required fields
Such as the "Name," "Authorized JavaScript origins," and "Authorized redirect URIs."Click "Create" to generate your OAuth 2.0 credentials
Save the generated "Client ID" and "Client Secret" for later use.
Next Steps​
Once you have created a wallet and added an account, you can perform various actions like checking the account balance, sending and receiving assets.