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