truffle 發布 智慧型合約

2022-02-09 09:53:19 字數 990 閱讀 2973

參考 這篇 說的已經很詳細了 

genesis.json 過時了可參考修改為如下

"config" :

geth --datadir privchain init genesis.json

geth --port 3000 --networkid 58342 --nodiscover --datadir="privchain" --maxpeers=0 --rpc --rpcport 8545 --rpcaddr 127.0.0.1 --rpccorsdomain "*" --rpcapi "eth,net,web3"

然後新啟動乙個終端輸入 如下 

geth attach ipc://home/someone/privchain/geth.ipc

geth啟動基本也就完成了 

personal.newaccount('password')

personal.unlockaccount(web3.eth.coinbase, "password", 15000) 解鎖賬戶 不然發布的時候會報錯  15000應該是時間 超時之後重新解鎖賬戶就可以了 

miner.start() 保證挖礦狀態

truffle migrate --reset (此處為了避免遇到錯誤 我直接帶上reset引數)

truffle console

helloworld.deployed() 就算完成了 

中途遇到2個錯誤 其一  error: no network specified. cannot determine current network異常

原因是 truffle配置檔案中沒有指定networkid 

module.exports = 

}};其二 error: exceeds block gas limit

gas給的(或者消耗的)太多超出區塊最大的gas限制量了 修改gaslimit

Truffle開發框架建立智慧型合約

2.安裝truffle npm install g truffle 3.安裝testrpc testrpc自帶10個使用者賬戶主要用於truffle除錯 npm install g ethereumjs testrpc 4.接下來我們就可以建立專案了 truffle init webpack 由於新...

編寫智慧型合約

1.安裝node.js 2.安裝truffle npm install g truffle 3.啟動testrpc以太坊環境 testrpc 4.另開終端視窗新建專案 mkdir demo cd demo 5.初始化專案目錄 truffle init 6.建立合約檔案 truffle create ...

積分智慧型合約

pragma solidity 0.4.22 title safemath dev math operations with safety checks that throw on error library safemath function div uint256 a,uint256 b int...