搭建环境
git clone https://github.com/Capgemini-AIE/ethereum-docker
cd ethereum-docker
docker-compose -f docker-compose-standalone.yml up -d
docker-compose up -d # 启动集群
docker-compose scale eth=3 # 设置三个节点
挖矿
docker exec -it ethereumdocker_eth_1 geth attach ipc://root/.ethereum/devchain/geth.ipc # 进入Ethan console
miner.start()
以太坊常用命令
-
personal.newAccount():创建账户; -
personal.unlockAccount():解锁账户; -
eth.accounts:枚举系统中的账户; -
eth.getBalance():查看账户余额,返回值的单位是 Wei(Wei 是以太坊中最小货币面额单位,类似比特币中的聪,1 ether = 10^18 Wei); -
eth.blockNumber:列出区块总数; -
eth.getTransaction():获取交易; -
eth.getBlock():获取区块; -
miner.start():开始挖矿; -
miner.stop():停止挖矿; -
web3.fromWei():Wei 换算成以太币; -
web3.toWei():以太币换算成 Wei; -
txpool.status:交易池中的状态; -
admin.addPeer():连接到其他节点;
智能合约部署-remix
-
浏览器打开 http://remix.ethereum.org/
-
编写合约(key-value存储)
pragma solidity ^0.4.0;
contract Sample {
mapping(string => string) private dict;
function get(string key) constant public returns (string value) {
return dict[key];
}
function set(string key,string value) public {
dict[key]= value;
}
}
- 合约发布
- 选择
web3 provider
- 选择

web3.personal.unlockAccount("0x???", "")
第一个参数是账号,第二个参数是账号密钥
- 点击create

- 合约操作


珠三角区块链研究开发QQ群:695790208