Socket
Socket
Sign inDemoInstall

@ethersproject/json-wallets

Package Overview
Dependencies
Maintainers
1
Versions
41
Alerts
File Explorer

Advanced tools

Socket logo

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
663K
decreased by-2.52%
Maintainers
1
Weekly downloads
 
Created

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

Keywords

FAQs

Package last updated on 30 Mar 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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc