Ethereumプローブ

2466 ワード

0 x 00 Ethereum概要
Ethereum(イーサ坊)は,スマート契約を実行して中心化したオープンソースプラットフォームである.デジタル通貨、商業契約、クラウドファンディングプロジェクトなどに用いられ、主に双方の信頼問題を解決する.
0 x 01環境構築
リファレンスhttps://github.com/ethereum/go-ethereumgo言語構築、簡単に実行できるのはgethだけです.
0 x 02プライベートチェーン構築
コマンドパラメータ
--ipcdisable--nodiscoverはアクティブにブロードキャストしません--networkidネットワークIDは、同じネットワークとプロトコルバージョンにある場合にのみ接続できます.
#        
#    ,genesis.json      
geth --datadir "/home/xxx/blockchain" init genesis.json
# genesis.json    :config    ,alloc      
{
  "config": {
        "chainId": 0,
        "homesteadBlock": 0,
        "eip155Block": 0,
        "eip158Block": 0
    },
  "alloc"      : {},
  "coinbase"   : "0x0000000000000000000000000000000000000000",
  "difficulty" : "0x20000",
  "extraData"  : "",
  "gasLimit"   : "0x2fefd8",
  "nonce"      : "0x0000000000000042",
  "mixhash"    : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "parentHash" : "0x0000000000000000000000000000000000000000000000000000000000000000",
  "timestamp"  : "0x00"
}
#   
geth --datadir /home/xxx/blockchain --networkid 36101 --ipcdisable --nodiscover console
#      admin.nodeInfo, eth.accounts js        
#        ,           
personal.newAccount("password")
#     ,  1  1   
# miner.start(1)
#     
# miner.stop()

#        ,           
#    ,genesis.json      ,                  ,               
geth --datadir "/home/xxx/blockchain" init genesis.json
#   
geth --datadir /home/xxx/blockchain --networkid 36101 --ipcdisable --nodiscover console
#        ,ecodeuri         ,  admin.nodeInfo   ecode ,  [::]       ip
admin.addPeer("ecodeuri")
#          
admin.peers

#             eth ,block  
#     mined potential block,   block,  eth 

#       
# wei
eth.getBalance(eth.accounts[0]).toNumber()
# ether=1  18 0 wei
web3.fromWei(eth.getBalance(eth.accounts[0]), "ether")

#     ,from  to 1 ether,from to  eth.accounts[0]   
eth.sendTransaction({from:'0xce417f51ebbc59e5cff597acecf10cedbf6075d3', to:'0x1b23bba8d4106cdfe8bb1d951c6b605db1ee750e',value:web3.toWei(1,"ether")})
#              
personal.unlockAccount('0xce417f51ebbc59e5cff597acecf10cedbf6075d3')
#                  
#         
eth.getBlock("pending", true).transactions