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

@web3auth/ethereum-provider

Package Overview
Dependencies
Maintainers
1
Versions
150
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3auth/ethereum-provider

---

  • 0.3.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
9.4K
decreased by-11.85%
Maintainers
1
Weekly downloads
 
Created
Source

@web3auth/ethereum-provider


Introduction:-

This package exposes a class EthereumPrivateKeyProvider, which accepts a secp251k1 private key and returns EIP1193 compatible provider, which can be used with various wallet sdks. For ex: CustomAuth and Openlogin sdk by torus.


Usage:-

Using Provider

import { EthereumPrivateKeyProvider } from "@web3auth/ethereum-provider";
import type { SafeEventEmitterProvider } from "@web3auth/base";
const signEthMessage = async (provider: SafeEventEmitterProvider): Promise<string> => {
  const web3 = new Web3(provider as any);
  const accounts = await web3.eth.getAccounts();
  // hex message
  const message = "0x47173285a8d7341e5e972fc677286384f802f8ef42a5ec5f03bbfa254cb01fad";
  const signature = await web3.eth.sign(message, accounts[0]);
  return signature;
};

(async () => {
  const provider = await EthereumPrivateKeyProvider.getProviderInstance({
    chainConfig: {
      rpcTarget: "https://polygon-rpc.com",
      chainId: "0x89", // hex chain id
      networkName: "matic",
      ticker: "matic",
      tickerName: "matic",
    },
    privKey: "4c0883a69102937d6231471b5dbb6204fe5129617082792ae468d01a3f362318",
  });
  const signedMessage = await signEthMessage(provider);
})();

All providers must implement interface of IBaseProvider Must implement chain functionality of addChain & switchChain Handlers must be in a separate file no reassigning of _providerEngineProxy use request instead of sendAsync emit from state

FAQs

Package last updated on 23 Feb 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