# web3-demo **Repository Path**: whl-git/web3-demo ## Basic Information - **Project Name**: web3-demo - **Description**: 练习web3.js的项目 - **Primary Language**: JavaScript - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2024-06-20 - **Last Updated**: 2024-06-28 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # web3-demo ## Project setup ``` npm install ``` ### Compiles and hot-reloads for development ``` npm run serve ``` ### Compiles and minifies for production ``` npm run build ``` ### Lints and fixes files ``` npm run lint ``` ### Customize configuration See [Configuration Reference](https://cli.vuejs.org/config/). ### 安装 web3 第三方包 ``` npm install web3 bip39 ethereumjs-tx@1.3.7 ethereumjs-util ethereumjs-wallet ``` - 注意:ethereumjs-tx 使用1.3.7版本 ### node-polyfill 兼容文件配置 1. 下载 polyfill 插件 npm install node-polyfill-webpack-plugin -D 在 vue.config.js 文件中配置插件 ```js const { defineConfig } = require('@vue/cli-service') // 引入插件 const NodePolyfillWebpackPlugin = require('node-polyfill-webpack-plugin'); module.exports = defineConfig({ transpileDependencies: true, configureWebpack: { plugins: [ new NodePolyfillWebpackPlugin() ] } }) ``` ### 配置 vant-ui 组件库 https://vant-contrib.gitee.io/vant/#/zh-CN 1. 安装 ```base npm install vant npm install @vant/auto-import-resolver unplugin-vue-components unplugin-auto-import -D ``` 2. 在 main.js 导入组件 ```js import Vant from 'vant' // 引入组件样式 import 'vant/lib/index.css' const app = createApp(App) app.use(Vant) app.mount('#app') ``` 3. 测试在 app.vue 添加代码 ```vue ``` ### 以太坊测试网络说明 [Sepolia 测试网](https://blog.csdn.net/bengofrank/article/details/133161513) [web3.js 使用参考文档](https://blog.csdn.net/weixin_39341981/article/details/132198747)