1.0.23 • Published 2 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
2 years ago
1.0.18
2 years ago
1.0.17
2 years ago
1.0.16
2 years ago
1.0.21
2 years ago
1.0.20
2 years ago
1.0.23
2 years ago
1.0.15
2 years ago
1.0.14
3 years ago
1.0.13
3 years ago
1.0.11
3 years ago
1.0.12
3 years ago
1.0.10
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago