1.0.23 • Published 4 years ago
react-onboard-provider v1.0.23
react-onboard-provider
Wrapper for https://github.com/blocknative/onboard with react hooks and uses ethers-gasnow.
Install
npm install react-onboard-provider
Quick Start
import { useProvider, Wallets } from 'react-onboard-provider'
import ethers from 'ethers'
// infura project id
const INFURA_PROJECT_ID = process.env.INFURA_ID
// alchemy project id
const ALCHEMY_PROJECT_ID = process.env.ALCHEMY_PROJECT_IDL
// ethereum network id
const networkId = 1
// app name
const APP_NAME = 'sample'
// app url
const APP_URL = 'https://foo.bar'
// email (only required for trezor)
const APP_EMAIL = 'x@y.com'
// initialize wallets object to provide to useProvider
const params = {
networkId,
APP_URL,
APP_EMAIL,
APP_NAME,
INFURA_PROJECT_ID,
ALCHEMY_PROJECT_ID,
defaultTo: 'alchemy'
}
const wallets = Wallets(params)
function onWalletChange(wallet) {
// effect for changes in wallet
}
function onAddressChange(address) {
// effect for changes in address
}
// optional parameter - determines which provider is used if metamask/any other wallet isn't found
function makeProvider(networkId) {
return ethers.getDefaultProvider(networkId)
}
const App = () => {
const { signerOrProvider } = useProvider({
wallets,
effects: {
onWalletChange,
onAddressChange
},
networkId,
env: {
INFURA_PROJECT_ID,
ALCHEMY_PROJECT_ID
}
})
}
Author
Vigensh Shankar
Licence
MIT
Keywords
none
1.0.19
4 years ago
1.0.18
4 years ago
1.0.17
4 years ago
1.0.16
4 years ago
1.0.21
4 years ago
1.0.20
4 years ago
1.0.23
4 years ago
1.0.15
4 years ago
1.0.14
4 years ago
1.0.13
4 years ago
1.0.11
4 years ago
1.0.12
4 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago