$ mv .env.example .env.local
# Add Infura token to .env.local
$ yarn install
$ yarn start
I've deployed the contract and validated the code on Etherscan.
- Boilerplate: I've used
npx create-react-app my-app --template redux-typescript
as a starting point. - web3 connection:
@usedapp/core
. - Typechain: I've used typechain to generate the types for the contract (Token).
- Redux tool: @reduxjs/toolkit
- Redux middleware: Sagas.
- WrongNetwork component.
- Modal-From validator
- Network configurable by env vars. For simplicity I thought it was enough to only configure one network (kovan).
-
Using redux/middleware has a strong limitation because it does not allow to use React Hooks. For example when I call
balanceOf
I can't consumeuseEthers
from@usedapp/core
. That's why I've created<SetProvider />
component, it sets the library (web3provider) insrc/utils/provider.ts
. This hack allows me to use the connected provider to interact with the Token contract. -
I've used createEntityAdapter from
@reduxjs/toolkit
, note thatwalletsAdapter.getSelectors
already implementsreselect
Each selector function will be created using the createSelector function from Reselect, to enable memoizing calculation of the results.