@dapptools/evm
v2.0.10-rc1
Published
[![Npm package version](https://badgen.net/npm/v/@dapptools/evm)](https://npmjs.com/package/@dapptools/evm)
Downloads
39
Readme
dAppTools
Ethereum 🤝 React
Framework for rapid Dapp development. Simple. Robust. Extendable. Testable.
About
Introduces great features:
- 🏗️ React hooks - Uses React hooks as your primary building ingredient
- 🚅 Auto refresh - Refreshes on a new block, wallet change or network change
- 🛒 Multicall - Combines multiple blockchain calls into a single multicall
Combines the best practices:
- 🔧 Modern stack - Employs ethers.js, multicall & waffle
- 📚 Extendability - Extends easily with custom hooks
- 💡 Testability - Simple integration tests for UI and blockchain
Example
import { Mainnet } from '@dapptools/evm/modal/chain/ethereum'
import { useEvm, useNativeBalance } from '@dapptools/evm'
const config = {
readOnlyChainId: Mainnet.chainId,
readOnlyUrls: {
[Mainnet.chainId]: 'https://mainnet.infura.io/v3/62687d1a985d4508b2b7a24827551934',
},
}
ReactDOM.render(
<DAppProvider config={config}>
<App />
</DAppProvider>,
document.getElementById('root')
)
const STAKING_CONTRACT = '0x00000000219ab540356cBB839Cbe05303d7705Fa'
export function App() {
const { activateBrowserWallet, deactivate, account } = useEvm()
const userBalance = useNativeBalance(account)
const stakingBalance = useNativeBalance(STAKING_CONTRACT)
return (
<div>
{!account && <button onClick={activateBrowserWallet}> Connect </button>}
{account && <button onClick={deactivate}> Disconnect </button>}
{stakingBalance && <p>ETH2 staking balance: {formatEther(stakingBalance)} ETH </p>}
{account && <p>Account: {account}</p>}
{userBalance && <p>Ether balance: {formatEther(userBalance)} ETH </p>}
</div>
)
}
See application here.
Documentation
For detailed feature walkthrough checkout documentation.
Contributing
Contributions are always welcome, no matter how large or small. Before contributing, please read the code of conduct and contribution policy.
Before you issue pull request:
- Make sure all tests pass.
- Make sure linter passes.
- Make sure you have test coverage for any new features.
To install dependencies type:
npm i -g pnpm
pnpm install
To build project:
yarn build
To run tests type:
yarn test
To run linter type:
yarn lint
Acknowledgement
This library was forked from usedapp, and inspired by the moralis