1.安装node
2.安装 solc
npm install -g socl
3.安装 truffle
npm install -g truffle
4.安装 ganache-cli
npm install -g ganache-cli
5.安装 web3
npm install -g web3
6.安装 webpack
npm install webpack
7.新建 DAPP
truffle unbox webpack
# 可能会报错,在 C:\Windows\System32\drivers\etc\hosts 里面加入
# GitHub Start
192.30.255.112 gist.github.com
192.30.255.112 github.com
192.30.255.112 www.github.com
151.101.56.133 avatars0.githubusercontent.com
151.101.56.133 avatars1.githubusercontent.com
151.101.56.133 avatars2.githubusercontent.com
151.101.56.133 avatars3.githubusercontent.com
151.101.56.133 avatars4.githubusercontent.com
151.101.56.133 avatars5.githubusercontent.com
151.101.56.133 avatars6.githubusercontent.com
151.101.56.133 avatars7.githubusercontent.com
151.101.56.133 avatars8.githubusercontent.com
151.101.56.133 camo.githubusercontent.com
151.101.56.133 cloud.githubusercontent.com
151.101.56.133 gist.githubusercontent.com
151.101.56.133 marketplace-screenshots.githubusercontent.com
151.101.56.133 raw.githubusercontent.com
151.101.56.133 repository-images.githubusercontent.com
151.101.56.133 user-images.githubusercontent.com
# GitHub End
8.安装项目依赖的 NPM 包
cd app npm install
9.启动节点
ganache-cli -d 生成 10 个测试账户,可以绑定到 metaMask
10.编译合约
truffle compile abi 在 build 文件夹下
11.部署合约
truffle migrate
参考:
https://truffleframework.com/docs/truffle/getting-started/creating-a-project
https://truffleframework.com/docs/truffle/reference/configuration
https://github.com/trufflesuite/truffle-init-webpack
https://truffleframework.com/docs/truffle/getting-started/truffle-with-metamask
https://truffleframework.com/tutorials/truffle-and-metamask