Geth コンソール基礎知識


gethの起動コマンド

geth --networkid "10" --nodiscover --datadir ~/geth/private_net/ --rpc --rpcaddr "localhost" --rpcport "8545" --rpccorsdomain "*" --rpcapi "eth,net,web3,personal" --targetgaslimit "20000000" console 2>> ~/geth/private_net/error.log

アカウント作成

personal.newAccount("password")

コインベースアカウントの確認

eth.counbase

コインベースアカウントの変更

miner.setEtherbase(eth.accounts[?])

genesisブロックの確認

eth.getBlock(0)

マイニングの開始、確認、停止

miner.start(1)
eth.mining
miner.stop()

コインベースの残高確認

eth.getBalance(eth.accounts[0])
web3.fromWei(eth.getBalance(eth.accounts[0], "either")

送金

(eth.accountがロックされてるので送金不可)

eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(5, "ether")})

PASSWORDアンロック

personal.unlockAccount(eth.accounts[0])

送金が成功したトランザクション

eth.getTransaction("address")

トランザクション内のblockNumberに残高が存在する

web3.fromWei(eth.getBalance(eth.accounts[1], 58), "ether")

レシート

eth.getTransactionReceipt("address")