Harmony-React
A web3-react toolkit for Harmony wallets
Harmony-React adds support for using OneWallet and MathWallet together with web3-react.
Harmony-React is not a fork of web3-react, but rather built on top of web3-react to ensure that the library can be upgraded whenever web3-react gets updated.
Using Harmony-React
Installation
Add web3-react/core and the wallets you want to use (OneWallet, MathWallet or both) to package.json:
"@web3-react/core": "latest",
"@harmony-react/mathwallet-connector": "latest",
"@harmony-react/onewallet-connector": "latest",Install using yarn install or npm install.
Usage
Import packages:
import { OneWalletConnector } from '@harmony-react/onewallet-connector'
import { MathWalletConnector } from '@harmony-react/mathwallet-connector'Instantiate wallets:
const onewallet = new OneWalletConnector({ chainId: 1 }) // 1 = Mainnet, 2 = Testnet
const mathwallet = new MathWalletConnector({ chainId: 1 }) // 1 = Mainnet, 2 = TestnetStore the wallet references in a store or a suitable structure, e.g:
For a more in-depth implementation example check here.
Create a wallet connection/unlock modal (or other suitable UI element):
Implement the Unlock component:
And finally, implement the WalletComponent:
For full reference implementations of Store, UnlockModal, Unlock, and WalletComponent:
Last updated
Was this helpful?