Socket
Socket
Sign inDemoInstall

@metamask/providers

Package Overview
Dependencies
Maintainers
12
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/providers

A JavaScript Ethereum provider that connects to the wallet over a stream.


Version published
Weekly downloads
184K
decreased by-1.42%
Maintainers
12
Weekly downloads
 
Created

What is @metamask/providers?

@metamask/providers is a package that provides a set of tools and utilities to interact with the MetaMask browser extension. It allows developers to integrate Ethereum-based applications with MetaMask, enabling functionalities such as connecting to the user's wallet, sending transactions, and interacting with smart contracts.

What are @metamask/providers's main functionalities?

Connecting to MetaMask

This feature allows you to connect to the user's MetaMask wallet and request access to their Ethereum accounts.

const { ethereum } = window;
if (ethereum) {
  ethereum.request({ method: 'eth_requestAccounts' })
    .then(accounts => console.log(accounts))
    .catch(err => console.error(err));
} else {
  console.log('MetaMask is not installed');
}

Sending Transactions

This feature allows you to send transactions from the user's MetaMask wallet to another Ethereum address.

const transactionParameters = {
  to: '0xRecipientAddress',
  from: ethereum.selectedAddress,
  value: '0x29a2241af62c0000', // 0.1 ETH
  gas: '0x5208', // 21000 GWEI
};
ethereum.request({
  method: 'eth_sendTransaction',
  params: [transactionParameters],
})
.then(txHash => console.log(txHash))
.catch(err => console.error(err));

Interacting with Smart Contracts

This feature allows you to interact with smart contracts deployed on the Ethereum blockchain using the user's MetaMask wallet.

const contractAddress = '0xYourContractAddress';
const abi = [
  // ABI array
];
const contract = new ethers.Contract(contractAddress, abi, ethereum);
contract.someMethod()
  .then(result => console.log(result))
  .catch(err => console.error(err));

Other packages similar to @metamask/providers

Keywords

FAQs

Package last updated on 22 Nov 2023

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc