Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ethersproject/wallet

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/wallet

Error utility functions for ethers.

  • 5.0.0-beta.128
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
718K
decreased by-8.9%
Maintainers
1
Weekly downloads
 
Created

What is @ethersproject/wallet?

@ethersproject/wallet is a part of the ethers.js library, which provides a complete, tiny, and simple library for interacting with the Ethereum blockchain. The wallet module specifically deals with creating and managing Ethereum wallets, signing transactions, and interacting with the Ethereum network.

What are @ethersproject/wallet's main functionalities?

Creating a Wallet

This feature allows you to create a new Ethereum wallet with a random private key. The code sample demonstrates how to create a new wallet and print its address.

const { Wallet } = require('@ethersproject/wallet');
const wallet = Wallet.createRandom();
console.log(wallet.address);

Importing a Wallet from a Private Key

This feature allows you to import an existing wallet using a private key. The code sample demonstrates how to create a wallet from a given private key and print its address.

const { Wallet } = require('@ethersproject/wallet');
const privateKey = '0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef';
const wallet = new Wallet(privateKey);
console.log(wallet.address);

Signing a Message

This feature allows you to sign a message using the wallet's private key. The code sample demonstrates how to sign a message and print the resulting signature.

const { Wallet } = require('@ethersproject/wallet');
const wallet = Wallet.createRandom();
const message = 'Hello, Ethereum!';
wallet.signMessage(message).then(signature => {
  console.log(signature);
});

Sending a Transaction

This feature allows you to send a transaction from the wallet. The code sample demonstrates how to connect the wallet to a provider and send a transaction to a recipient address.

const { Wallet } = require('@ethersproject/wallet');
const { providers } = require('@ethersproject/providers');
const wallet = Wallet.createRandom();
const provider = new providers.JsonRpcProvider('https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID');
const walletWithProvider = wallet.connect(provider);
const tx = {
  to: '0xrecipientAddress',
  value: ethers.utils.parseEther('0.01')
};
walletWithProvider.sendTransaction(tx).then(transaction => {
  console.log(transaction);
});

Other packages similar to @ethersproject/wallet

Keywords

FAQs

Package last updated on 03 Aug 2019

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