智能合约vote部署
1 前言
solidity官方文档上有一个vote智能合约。我使用truffle框架进行编写和部署。
2 环境
2.1 编辑
vscode + 插件
2.2 安装node
到官网下载node 8,解压后安装,配置环境变量。
2.3 solidity编译器
npm install -g solc
2.4 truffle安装
npm install -g truffle
2.5 ethereum安装
从https://github.com/ethereum/go-ethereum下载编译,配置环境。
3 ethereum私有链搭建
3.1 创建目录
/home/hlf/eth/data/00
3.2 genesis.json
/home/hlf/eth/genesis.json
{
"config": {
"chainId": 168, //不要为0
"homesteadBlock": 0,
"eip155Block": 0,
"eip158Block": 0
},
"alloc" : {},
"coinbase" :"0x0000000000000000000000000000000000000000",
"difficulty" : "0x400",
"extraData" :"",
"gasLimit" :"0x2fefd8",
"nonce" :"0x0000000000000042",
"mixhash" :"0x0000000000000000000000000000000000000000000000000000000000000000",
"parentHash" :"0x0000000000000000000000000000000000000000000000000000000000000000",
"timestamp" :"0x00"
}
3.3 初始化脚本
/home/hlf/eth/init.sh
geth --datadir /home/hlf/eth/data/00 init/home/hlf/eth/genesis.json
3.4 start脚本
geth --identity "TestNode" --rpc--rpcport "8545" --datadir /home/hlf/eth/data/00--port "30303" --rpcapi "db,eth,net,web3" --netw