Some features created in web3
were meant to be utilized in the browser only.
The .save()
and .load
are two of these features.
Stores the wallet encrypted and as string in local storage.
Note
Browser only.
Local Storage 101:
From https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
The read-only localStorage property allows you to access a Storage
object for the Document's origin; the stored data is saved across
browser sessions. localStorage is similar to sessionStorage, except
that while data stored in localStorage has no expiration time, data
stored in sessionStorage gets cleared when the page session ends —
that is, when the page is closed.
It should be noted that data stored in either localStorage or
sessionStorage is specific to the protocol of the page.
The keys and the values are always strings (note that, as with
objects, integer keys will be automatically converted to strings).
web3.eth.accounts.wallet.save() & .load()
From the link, already provided below, there's an example of how to use:
save()
web3.eth.accounts.wallet.save(password [, keyName]);
Parameters password - String: The password to encrypt the wallet.
keyName - String: (optional) The key used for the local storage
position, defaults to "web3js_wallet".
load()
web3.eth.accounts.wallet.load(password [, keyName]);
Parameters password - String: The password to decrypt the wallet.
keyName - String: (optional) The key used for the localstorage
position, defaults to "web3js_wallet".
Source