web3-react-v6-phantom
v1.0.5
Published
A Phantom connector for web3-react v6
Downloads
87
Readme
This small package allows you to add a dedicated, functional, connector to integrate Phantom into your web3-react (v6) project.
to install
yarn add web3-react-v6-phantom
# or
npm install web3-react-v6-phantom
# or
pnpm add web3-react-v6-phantom
#
Import
import { PhantomConnector } from 'web3-react-v6-phantom'
Example Usage
import { useWeb3React } from "@web3-react/core"; // v6
import { PhantomConnector } from "web3-react-v6-phantom"
const Phantom = new PhantomConnector({
supportedChainIds: [1]
}
function App() {
const { activate, deactivate, active, chainId, account } = useWeb3React();
return (
<div className="App">
<h1>Web3-React Connector Playbox</h1>
<div>
<button
onClick={() => {
activate(Phantom);
}}
>
Phantom
</button>
<button onClick={deactivate}>Disconnect</button>
</div>
<div className="card">
<div>Connection Status: {active}</div>
<div>Account: {account}</div>
<div>Network ID: {chainId}</div>
</div>
</div>
);
}
export default App;