useWallet() v0.7.0
This version adds the new ProvidedConnector
, which you can use when you want to provide your own EIP-1193
compatible provider object
Pull request
- API: Add
ProvidedConnector
and its configuration options (#39)
ProvidedConnector
The ProvidedConnector
is a special kind of connector: it acts just like the normal InjectedConnector
from web3-react
(use-wallet
's default connector), but with the ability to configure it to use any other EIP-1193
compatible provider object through the provided
key. This enables a lot of possibilities, such as developing a system to manage multiple providers in the future.
Here's an example:
import { useWallet, UseWalletProvider } from 'use-wallet'
function App() {
const { activate } = useWallet()
return (
<button
onClick={() => activate('provided')}
>
connect
</button>
)
}
export default () => (
<UseWalletProvider
connectors={{
// You can use window.ethereum, or any other compatible provider object
provided: { provider: window.ethereum },
}}
>
<App />
</UseWalletProvider>
)