Install react and react-dom
npm install --save ethers yarn add ethers
yarn add web3
npm install @ethersproject/providers
web3-react
Run the following command to install web-react:
npm install @web-react/core
or
yarn add @web3-react/core
Now, in order to connect the browser-based wallet, we need to install the following web3-react package:
npm install @web3-react/injected-connector
or
yarn add @web3-react/injected-connector
什么是 Web3-React?
Web3-react 是一个基于 React 的框架,有助于简化 dApp 的前端开发。
Web3-react 还充当状态机,用于维护与您的 dApp 相关的数据,并将其注入组件树中任何需要的位置。Web3-React 支持多种钱包,从 Metamask 和 Coinbase 等浏览器钱包到 Trezor 和 Ledger 等硬件钱包。
在 Web3 中,我们使用 Web3-Modal 在 dApp 中进行钱包连接。Web3-模态非常适合初学者,但随着我们扩展项目,处理 Web3-模态变得更加困难。
因此,web3-react 可能是一个更好的选择,因为:
• 更适合构建现代 dApp
• 拥有更好的开发人员体验
• 减少代码冗余
• 并且是一个直观的框架,可以使用
(上面解释从网上找的。。)
Supplementary note: The npm command fails and try changing to yarn.
To be continued. . .