truffle部署智慧合約

NO IMAGE

專案初始化

建立一個目錄,並在目錄下面新建專案:

[email protected]:/home/ubuntu# source ~/.profile 
[email protected]:/home/ubuntu# mkdir truffleProject
mkdir: cannot create directory 鈥榯ruffleProject鈥 File exists
[email protected]:/home/ubuntu# mkdir truffle1
[email protected]:/home/ubuntu# cd truffle1
[email protected]:/home/ubuntu/truffle1# truffle init
Downloading project...
Project initialized.
Documentation: http://truffleframework.com/docs
Commands:
Compile: truffle compile
Migrate: truffle migrate
Test:    truffle test
[email protected]:/home/ubuntu/truffle1# ll
total 24
drwxr-xr-x  5 root   root   4096 Jul 11 17:32 ./
drwxr-xr-x 12 ubuntu ubuntu 4096 Jul 11 17:32 ../
drwxr-xr-x  2 root   root   4096 Jul 11 17:32 contracts/
drwxr-xr-x  2 root   root   4096 Jul 11 17:32 migrations/
drwxr-xr-x  2 root   root   4096 Jul 11 17:32 test/
-rw-r--r--  1 root   root    154 Jul 11 17:32 truffle.js

每個目錄的作用如下:


├── app 
│   ├── images 前端介面用到的圖片
│   ├── index.html 前端介面用到的頁面
│   ├── javascripts 前端介面用到的javascript
│   │   └── app.js
│   └── stylesheets 前端介面用到的css檔案
│       └── app.css
├── contracts 智慧合約檔案
│   ├── ConvertLib.sol
│   ├── MetaCoin.sol
│   └── Migrations.sol
├── migrations 部署用到的指令碼
│   ├── 1_initial_migration.js
│   └── 2_deploy_contracts.js
├── test 編寫的測試
│   └── metacoin.js
└── truffle.js