
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
eth-wallet-connector
Advanced tools
Make sure you also have the web3 library
npm install eth-wallet-connector
yarn add eth-wallet-connector
Below examples are with React, however this library does not depend on React and will work with any Javascript web Frontend
import React from 'react'
import { connectMetamask, getWeb3 } from 'eth-wallet-connector'
export default function ConnectComponent() {
const handleConnectMetamask = async () => {
const result = await connectMetamask();
if (result) {
// connected
const web3 = getWeb3(); // this retrieves the web3 instance from the wallet
const accounts = await web3.eth.getAccounts();
}
}
return (
<button onClick={handleConnectMetamask}>Connect Metamask</button>
)
}
Try to connect with metamask and see if a connection was done before, this is useful when user refreshes the page or visits your Dapp again
import React, { useEffect } from 'react'
import { eagerlyConnectMetamask, getWeb3 } from 'eth-wallet-connector'
export default function ConnectComponent() {
useEffect(() => {
const connectEagerlyMetamask = async () => {
const result = await eagerlyConnectMetamask();
if (result) {
// connected
const web3 = getWeb3(); // this retrieves the web3 instance from the wallet
const accounts = await web3.eth.getAccounts();
}
}
connectEagerlyMetamask();
}, [])
return (
<div>This is the landing page</div>
)
}
import React from 'react'
import { connectWalletConnect, getWeb3 } from 'eth-wallet-connector'
export default function ConnectComponent() {
const handleConnectWalletConnect = async () => {
const result = await connectWalletConnect();
if (result) {
// connected
const web3 = getWeb3(); // this retrieves the web3 instance from the wallet
const accounts = await web3.eth.getAccounts();
}
}
return (
<button onClick={handleConnectWalletConnect}>Connect Wallet Connect</button>
)
}
FAQs
A single library to connect all the ETH wallets
We found that eth-wallet-connector demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.