1. 安装
npm install -g truffle
2. 建立MetaCoin工程
mkdir MetaCoin
cd MetaCoin
truffle unbox metacoin
3. 启动私链(https://github.com/luoiefly/ethfun)
./geth --rpc --mine --minerthreads=1 --etherbase=aaba4749df21949095ff9445449ded85347f7154 console
networks: {
development1 : {
host: "localhost",
port: 8545,
network_id: "*", // 匹配任何network id
gas: 3000000,
gasPrice: 0x1
}
}
6. truffle migrate
报错:Error: authentication needed: password or unlock
7. 要unlock account
WiRoams-MacBook-Air:bin luoie$ ./geth account list
Account #0: {15ed970cc673c6a8912c42663104c25e9d25698a} keystore:///Users/luoie/Library/Ethereum/keystore/UTC--2018-01-22T00-54-14.944479172Z--15ed970cc673c6a8912c42663104c25e9d25698a
Account #1: {aaba4749df21949095ff9445449ded85347f7154} keystore:///Users/luoie/Library/Ethereum/keystore/UTC--2018-01-22T00-54-24.027018315Z--aaba4749df21949095ff9445449ded85347f7154
Account #2: {b4e18cf5fa72cd47796b0bebc5bcc824d93c5c75} keystore:///Users/luoie/Library/Ethereum/keystore/UTC--2018-01-29T00-42-07.946381709Z--b4e18cf5fa72cd47796b0bebc5bcc824d93c5c75
Account #3: {e8c88c029ddd7b9880b9a3a8d1458ee7a1932dbb} keystore:///Users/luoie/Library/Ethereum/keystore/UTC--2018-01-29T14-26-23.123370914Z--e8c88c029ddd7b9880b9a3a8d1458ee7a1932dbb
WiRoams-MacBook-Air:bin luoie$
要使用第一个。
改变私链启动命令。
./geth --rpc --unlock 15ed970cc673c6a8912c42663104c25e9d25698a --mine --minerthreads=1 --etherbase=aaba4749df21949095ff9445449ded85347f7154 console
module.exports = function(deployer) {
//deployer.deploy(Migrations);
};
WiRoams-MacBook-Air:MetaCoin luoie$ truffle migrate
Using network 'development'.
Running migration: 1_initial_migration.js
Saving artifacts...
Running migration: 2_deploy_contracts.js
Replacing ConvertLib...
... 0x1fd4a181f09d3df25c1c18109c9e305f5ee670e81f450872778219c03d1b7ec4
ConvertLib: 0xc7b9a4302748ba75da0c6a39a2c12ba2b1fb98bc
Linking ConvertLib to MetaCoin
Replacing MetaCoin...
... 0xcc67bd245f1260d27db72b250913c308e2c3245d0ff5c4aea4f90688232cf0dd
MetaCoin: 0x8ce003908df3075307c22a18d6a8951dccdb24e7
Saving artifacts...
WiRoams-MacBook-Air:MetaCoin luoie$
成功啦