Socket
Socket
Sign inDemoInstall

@ethersproject/json-wallets

Package Overview
Dependencies
13
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/json-wallets

Wallet management utilities for KeyStore and Crowdsale JSON wallets.


Version published
Weekly downloads
559K
decreased by-11.58%
Maintainers
1
Created
Weekly downloads
 

Package description

What is @ethersproject/json-wallets?

@ethersproject/json-wallets is a part of the ethers.js library, which provides utilities for handling JSON wallets. JSON wallets are a common format for storing Ethereum private keys in a secure, encrypted manner. This package allows you to create, encrypt, decrypt, and manage these wallets.

What are @ethersproject/json-wallets's main functionalities?

Creating a JSON Wallet

This feature allows you to create a new Ethereum wallet and encrypt it into a JSON format using a password.

const { Wallet } = require('@ethersproject/wallet');
const { save } = require('@ethersproject/json-wallets');

async function createJsonWallet(password) {
  const wallet = Wallet.createRandom();
  const json = await wallet.encrypt(password);
  console.log(json);
}

createJsonWallet('your-password');

Decrypting a JSON Wallet

This feature allows you to decrypt an existing JSON wallet using the password it was encrypted with, and access the wallet's address and other properties.

const { Wallet } = require('@ethersproject/wallet');
const { fromEncryptedJson } = require('@ethersproject/json-wallets');

async function decryptJsonWallet(json, password) {
  const wallet = await Wallet.fromEncryptedJson(json, password);
  console.log(wallet.address);
}

decryptJsonWallet('your-json-wallet', 'your-password');

Saving a JSON Wallet to a File

This feature allows you to create a new JSON wallet and save it to a file for later use.

const { Wallet } = require('@ethersproject/wallet');
const { save } = require('@ethersproject/json-wallets');
const fs = require('fs');

async function saveJsonWalletToFile(password, filePath) {
  const wallet = Wallet.createRandom();
  const json = await wallet.encrypt(password);
  fs.writeFileSync(filePath, json);
}

saveJsonWalletToFile('your-password', 'wallet.json');

Other packages similar to @ethersproject/json-wallets

Readme

Source

Secret Storage JSON Wallet Utilities

This sub-module is part of the ethers project.

It is responsible for encoding, decoding, encrypting and decrypting JSON wallet formats.

For more information, see the documentation.

Importing

Most users will prefer to use the umbrella package, but for those with more specific needs, individual components can be imported.

const {

    isCrowdsaleWallet,
    decryptCrowdsale,

    isKeystoreWallet,
    decryptKeystore,
    decryptKeystoreSync,
    encryptKeystore,

    getJsonWalletAddress,

    decryptJsonWallet,
    decryptJsonWalletSync,

    // Types

    ProgressCallback,

    EncryptOptions

} = require("@ethersproject/json-wallets");

License

MIT License

Keywords

FAQs

Last updated on 20 Oct 2021

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc