搭建私链
搭建私链参考这里https://blog.csdn.net/loy_184548/article/details/77989092
挖矿交易
挖矿操作、发送交易参考这里
https://www.jianshu.com/p/755a37ce1693
补充
1、以太币单位换算
> web3.fromWei(75000000000000000000)
"75"
2、查看区块高度
> eth.blockNumber
15
//查询下最后一个区块信息
> eth.getBlock(14)
{
difficulty: 131904,
extraData: "0xd883010803846765746886676f312e31308777696e646f7773",
gasLimit: 3184794,
gasUsed: 0,
hash: "0xfa6747700d28c4b08b7c4c0d5909cf49769098f4ea91c701939d1e37bae2f65e",
logsBloom: "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
miner: "0x5c2bce3d8f21cf3443009a3de8eca858d1ffb8bb",
mixHash: "0x4ebef04b30ba03b9a5ca92f908f6e71d3c54c0f65962af259ac5a67449266c2c",
nonce: "0x1ccb10a847fab2f6",
number: 14,
parentHash: "0x00a5fe5afc75000d86b13c7d031f544f55f4a6f249329909e7cb8421131acc07",
receiptsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
sha3Uncles: "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
size: 536,
stateRoot: "0x96c687ba1d78514962711a3d6e772f9af4523f82b4308b43415a8593837512b8",
timestamp: 1523348519,
totalDifficulty: 1971904,
transactions: [],
transactionsRoot: "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
uncles: []
}
3、命令备份
########################################################
#######创建账号
########################################################
#创建一个新的账号、密码为123456
> personal.newAccount("123456")
"0xa9d1489d17933776a4f9522731451690f061cc75"
########################################################
#######查看所有的账号
########################################################
> personal.listAccounts
["0x5c2bce3d8f21cf3443009a3de8eca858d1ffb8bb", "0xa9d1489d17933776a4f9522731451690f061cc75"]
########################################################
#######查看账号余额
########################################################
> eth.getBalance(eth.accounts[0])
75000000000000000000
########################################################
#######解锁账号
########################################################
#解锁后可以发生交易https://blog.csdn.net/ddffr/article/details/74327876
#说明"123456"是密码、必须写成字符串形式
> personal.unlockAccount(eth.accounts[0],"123456")
true
########################################################
#######转账交易
########################################################
#账号0给账号1发送以太币、只有挖矿以后交易才成功、挖矿之后账号1才有以太币
> eth.sendTransaction({from:"0x5c2bce3d8f21cf3443009a3de8eca858d1ffb8bb", to: "0xa9d1489d17933776a4f9522731451690f061cc75", gas:31000, 'gasPrice': web3.toWei(300, 'gwei'), "value":
"1"})
"0x2f9973a5ab34d3122029453af5e755960754363193dcb1fe7f57ef6484ac8b05"
> eth.getBalance(eth.accounts[0])
75000000000000000000
> eth.getBalance(eth.accounts[1])
0
> miner.start()
null
> miner.stop()
true
> eth.getBalance(eth.accounts[1])
3
########################################################
#######打开geth控制台
########################################################
geth console
########################################################
#######启动私链
########################################################
geth --datadir "./" --nodiscover console 2>>geth.log
########################################################
#######创建智能合约
########################################################
#Building a smart contract using the command line
#https://www.ethereum.org/greeter
#https://www.jianshu.com/p/c53ede8fab36