
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.
Use signer is a React Hook designed to provide convenient access to a web3modal.
address, the network chainId and the current wallet statusInstall the library on your project:
npm install use-signer
Add the provider at the root of your React app
import { useSigner, UseSignerProvider } from "use-signer";
import { IProviderOptions } from "web3modal";
const App = () => {
return (
<UseSignerProvider>
<AppBody />
</UseSignerProvider>
);
};
Optionally, parameterize the wallets shown by web3modal:
import { useSigner, UseSignerProvider } from "use-signer";
import { IProviderOptions } from "web3modal";
import WalletConnectProvider from "@walletconnect/web3-provider";
const App = () => {
const DEFAULT_CHAIN_ID = 1;
// Customize the wallets you support
// See: https://github.com/Web3Modal/web3modal#custom-provider
const providerOptions: IProviderOptions = {
metamask: {
// custom settings
}
walletconnect: {
package: WalletConnectProvider,
options: {
infuraId: "1234...",
},
},
};
return (
<UseSignerProvider providerOptions={providerOptions} defaultChainId={1}>
<AppBody />
</UseSignerProvider>
);
};
Use the hook on any child component:
const AppBody = () => {
const { provider, signer, status, address, chainId, methods } = useSigner();
const onClickSelect = () => {
const cacheProvider = true;
const networkId = "mainnet";
methods.selectWallet(cacheProvider, networkId); // cacheProvider and networkId are optional
}
const onClickDisconnect = () => methods.disconnect();
return (
<div style={{ fontFamily: "sans-serif" }}>
<h2>Use Signer example</h2>
<p>{provider ? "Provider available" : "No provider"}</p>
<p>{signer ? "Signer available" : "No signer"}</p>
<p>Status: {status}</p>
<p>Address: {address}</p>
<p>Chain ID: {chainId}</p>
<div>
{status === "disconnected"
? <button onClick={onClickSelect}>Connect wallet</button>
: status === "connected"
? <button onClick={onClickDisconnect}>Disconnect</button>
: <span>Connecting...</span>}
</div>
</div>
);
};
When calling useSigner() you can invoke the following methods:
methods.selectWallet()
cacheProvider and networkId parametersmethods.disconnect()
methods.refreshChainId()
When calling useSigner() you receive the following variables:
provider
signer
status
"disconnected", "connecting" or "connected"address
chainId
yarn build
yarn lint
yarn lint -- --fix
yarn size
yarn start
yarn test
Start the example web server:
yarn example
See in the example folder: pages/_app.tsx and pages/index.tsx
Navigate to localhost:8080
FAQs
React hook for using web3modal
We found that use-signer 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.