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

@ethersproject/providers

Package Overview
Dependencies
Maintainers
1
Versions
114
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ethersproject/providers

Ethereum Providers for ethers.

  • 5.7.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
915K
increased by9.56%
Maintainers
1
Weekly downloads
 
Created

What is @ethersproject/providers?

@ethersproject/providers is a module from the ethers.js library that provides a way to interact with Ethereum nodes. It allows developers to connect to Ethereum networks, query blockchain data, and send transactions.

What are @ethersproject/providers's main functionalities?

Connecting to a Provider

This feature allows you to connect to an Ethereum node using a JSON-RPC provider. In this example, we use Infura as the provider.

const { ethers } = require('ethers');
const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID');

Querying Blockchain Data

This feature allows you to query blockchain data. In this example, we fetch the current block number from the Ethereum network.

const { ethers } = require('ethers');
const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID');
async function getBlockNumber() {
  const blockNumber = await provider.getBlockNumber();
  console.log('Current block number:', blockNumber);
}
getBlockNumber();

Sending Transactions

This feature allows you to send transactions on the Ethereum network. In this example, we create a wallet instance and send a transaction to a recipient address.

const { ethers } = require('ethers');
const provider = new ethers.providers.JsonRpcProvider('https://mainnet.infura.io/v3/YOUR_INFURA_PROJECT_ID');
const wallet = new ethers.Wallet('YOUR_PRIVATE_KEY', provider);
async function sendTransaction() {
  const tx = {
    to: '0xRecipientAddress',
    value: ethers.utils.parseEther('0.01')
  };
  const transaction = await wallet.sendTransaction(tx);
  console.log('Transaction hash:', transaction.hash);
}
sendTransaction();

Other packages similar to @ethersproject/providers

Keywords

FAQs

Package last updated on 19 Oct 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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc