0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

ubuntu 20.04 + Geth環境のether送金

Last updated at Posted at 2020-12-28

ubuntu 20.04 + Geth1.9.25(Go-Ethereum)環境でのether送金手順をまとめる。

EOAアカウントの所有etherの確認

> eth.getBalance(eth.accounts[NUmber])コマンドで、送金元・先のEOAアカウントのether持ち高を確認しておく。

> eth.accounts
["0x911e18204582a6de08dd2b1f7540b9167ce93b67", "0x634c921bfbad7756c7988ea74e4bdf5e5387620d"]
>
> eth.getBalance(eth.accounts[0])
2.105e+21
> eth.getBalance(eth.accounts[1])
100000000000000000000

アカウントロック解除

ether送金時にはアカウントロックを解除する必要がある。personal.unlockAccount(EOAアカウントのアドレス)コマンドでロックを解除する。アンロックの時間はデフォルト300秒でタイムアウトし、ロックされる。

> personal.unlockAccount(eth.accounts[0])
Unlock account 0x911e18204582a6de08dd2b1f7540b9167ce93b67
Passphrase:
true
>

コマンドは、以下のようにオプションを拡張することが可能。アンロック時間に0を指定すると、ロックされない。personal.unlockAccount(EOAアカウントのアドレス, "パスワード", "アンロック時間(秒)")

etherの送金

送金時は採掘処理が実行されている必要がある。プライベートネットワークであり、自身以外に採掘者がいないため、採掘を実行する。

> eth.hashrate
0
> eth.mining
false
> miner.start()
null
> eth.mining
true
> eth.hashrate
2619
>

ロック解除したaccount[0]からaccount[1]へ送金する。送金単位はweiの単位指定となるので、単位変換関数であるweb.toWeiを使う。実行結果としてトランザクションIDが返される。

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

トランザクションの内容はeth.getTransaction('トランザクションのアドレス')コマンドで確認することが出来る。

> eth.getTransaction('0xf03e4882a766d3aa4d3b188bbe191721be63ed2233792e7fcb1d5b7e1dd6b2eb')
{
  blockHash: null,
  blockNumber: null,
  from: "0x911e18204582a6de08dd2b1f7540b9167ce93b67",
  gas: 21000,
  gasPrice: 1000000000,
  hash: "0xf03e4882a766d3aa4d3b188bbe191721be63ed2233792e7fcb1d5b7e1dd6b2eb",
  input: "0x",
  nonce: 0,
  r: "0xda879400e1472aaed815371ab259874a0303f17d732e83959345f4322b5c8195",
  s: "0xc89b9f49f14fa35778b84164eb2a39e34f004ede08044ddc257d332ba7f8fca",
  to: "0x634c921bfbad7756c7988ea74e4bdf5e5387620d",
  transactionIndex: null,
  v: "0x42",
  value: 5000000000000000000
}
>

しばらく時間がかかるようで、送金確認後に更新したいと思う。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?