LocalWalletNode
Generate Local Wallets in Node.js backends, CLIs and scripts.
This is very useful for situations where you need a wallet for your backend services, scripts or CLI.
After generating wallets this way, you can persist it in different ways. For example, you can save it to a file, or store it in a database.
Example
Local Wallet Backup
Local wallets can be persisted in a file, database, or backed up to another cloud provider. Currently 3 formats are supported:
encryptedJSON
- a standard format for encrypted wallets, this requires a password to encrypt/decrypt the wallet. Recommended for safe backups.privateKey
- the raw private key. This can be stored encrypted or un-encrypted. If not encrypted, make sure you store it somewhere safe.mnemonic
- the raw seed phrase. This can be stored encrypted or un-encrypted. If not encrypted, make sure you store it somewhere safe.
We provide encryption capabilities out of the box, but you can customize the type of encryption, and also turn it off completely.
The type of storage can also be overridden, allowing you to store wallets anywhere you want, including remote locations.
By default, the local wallet will be saved in a wallet.json
file at the root of your project. The path to the file can be customized by passing a storageJsonFile
option to the constructor.
Customizing where the wallet data is persisted only requires implementing a simple interface. Here's an example of a Local Wallet with custom storage:
You can implement this any way you like, file persistance, remote cloud storage, etc.
Encryption examples
Here's some examples of different encryption configurations:
Save an encrypted privateKey with default encryption a password as the encryption key:
Import a raw private key or mnemonic (seed phrase) with no encryption:
Save an encrypted mnemonic with a custom encryption: