Socket
Socket
Sign inDemoInstall

@ethersproject/abstract-signer

Package Overview
Dependencies
5
Maintainers
1
Versions
52
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/abstract-signer

An Abstract Class for desribing an Ethereum Signer for ethers.


Version published
Weekly downloads
681K
decreased by-10.89%
Maintainers
1
Install size
1.56 MB
Created
Weekly downloads
 

Package description

What is @ethersproject/abstract-signer?

@ethersproject/abstract-signer is a part of the ethers.js library, which provides a collection of utilities for interacting with the Ethereum blockchain. The abstract-signer module specifically deals with the abstraction of signing transactions and messages, allowing developers to create custom signers or use existing ones to sign data securely.

What are @ethersproject/abstract-signer's main functionalities?

Signing Transactions

This feature allows you to sign a transaction using a wallet instance. The code sample demonstrates how to create a wallet, define a transaction, and sign it.

const { Wallet } = require('@ethersproject/wallet');
const { parseEther } = require('@ethersproject/units');
const { JsonRpcProvider } = require('@ethersproject/providers');

async function signTransaction() {
  const provider = new JsonRpcProvider('https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID');
  const wallet = new Wallet('YOUR_PRIVATE_KEY', provider);
  const tx = {
    to: '0xADDRESS',
    value: parseEther('0.01'),
    gasLimit: 21000,
    gasPrice: parseUnits('10', 'gwei')
  };
  const signedTx = await wallet.signTransaction(tx);
  console.log(signedTx);
}
signTransaction();

Signing Messages

This feature allows you to sign a message using a wallet instance. The code sample demonstrates how to create a wallet and sign a simple message.

const { Wallet } = require('@ethersproject/wallet');

async function signMessage() {
  const wallet = new Wallet('YOUR_PRIVATE_KEY');
  const message = 'Hello, Ethereum!';
  const signedMessage = await wallet.signMessage(message);
  console.log(signedMessage);
}
signMessage();

Connecting to a Provider

This feature allows you to connect a wallet to a provider. The code sample demonstrates how to create a wallet and connect it to an Ethereum provider.

const { Wallet } = require('@ethersproject/wallet');
const { JsonRpcProvider } = require('@ethersproject/providers');

async function connectToProvider() {
  const provider = new JsonRpcProvider('https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID');
  const wallet = new Wallet('YOUR_PRIVATE_KEY', provider);
  console.log(wallet.address);
}
connectToProvider();

Other packages similar to @ethersproject/abstract-signer

Readme

Source

Abstract Signer

This sub-module is part of the ethers project.

It is an abstraction of an Ethereum account, which may be backed by a private key, signing service (such as Geth or Parity with key managment enabled, or a dedicated signing service such as Clef), hardware wallets, etc.

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 {

    Signer,
    VoidSigner,

    // Types
    ExternallyOwnedAccount

} = require("@ethersproject/abstract-signer");

License

MIT License

Keywords

FAQs

Last updated on 19 Aug 2022

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