The boilerplate is powered by Nextjs/typechain which fully supports typescript. Check the result here
- clone the repo:
git clone https://github.com/happyeric77/evm-dapp-boilerplate-ts
- install npm depandencies and generate types:
yarn install
yarn generate-types // Generate a new folder `contractTypes` which contains all the contracts types definition. The types are generated from /utils/contracts/*.json (compiled by truffle)
- Run and listen on localhost port 3000
yarn dev
Use useWeb3 hook to easily access global web3 methods:
const { web3Data, loginWithInjectedWeb3, loginWithWalletConnect, logout, switchNetwork } = useWeb3();
Consume the npm evm-web3-hook react hook
yarn add evm-web3-hooks
or npm install evm-web3-hooks
- Add approve-erc20 page to demo contract interaction
- Introduce typechain (yarn generate-types) to enable types for web3.eth.Contract (see example in
./pages/approve-erc20.tsx
) - Add useLoading hook
- Clean up and small optimization
-
To reduce complexity, truffle section are removed. The contract section can be referred to This repo
-
Remove unnecessary components
-
Add hooks: useWeb3 & useNotify
-
Move all style sheet to ./styles