ユーザ用ツール

サイト用ツール


blockchain:ethereum構築ハンズオン_ganache編

差分

このページの2つのバージョン間の差分を表示します。

この比較画面へのリンク

両方とも前のリビジョン前のリビジョン
blockchain:ethereum構築ハンズオン_ganache編 [2022/04/27 07:04] dotblockchain:ethereum構築ハンズオン_ganache編 [2022/04/28 01:48] (現在) dot
行 42: 行 42:
 「起動」の手順で確認した「RPC SERVER URL」を使用して、以下のようにコンソール接続することができます。 「起動」の手順で確認した「RPC SERVER URL」を使用して、以下のようにコンソール接続することができます。
  
-<code - sh>+<code PowerShell>
 geth --nodiscover attach http://127.0.0.1:7545 geth --nodiscover attach http://127.0.0.1:7545
 </code> </code>
行 49: 行 49:
  
 送金前 送金前
-<code - sh>+<code PowerShell>
 > eth.getBalance(eth.accounts[0]) > eth.getBalance(eth.accounts[0])
 100000000000000000000 100000000000000000000
行 57: 行 57:
  
 送金 送金
-<code - sh>+<code PowerShell>
 > eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(5, "ether")}) > eth.sendTransaction({from: eth.accounts[0], to: eth.accounts[1], value: web3.toWei(5, "ether")})
 </code> </code>
  
 送金後(eth.accounts[0] についてはガス代分も少なくなっている) 送金後(eth.accounts[0] についてはガス代分も少なくなっている)
-<code - sh>+<code PowerShell>
 > eth.getBalance(eth.accounts[0]) > eth.getBalance(eth.accounts[0])
 94999580000000000000 94999580000000000000
行 86: 行 86:
 内部にカウンターをもち、カウンターの値を取得する(get)と、カウンターの値を1増やす(inc)するスマートコントラクトを実装します。 内部にカウンターをもち、カウンターの値を取得する(get)と、カウンターの値を1増やす(inc)するスマートコントラクトを実装します。
  
-<code Counter.sol>+<code JavaScript Counter.sol>
 // SPDX-License-Identifier: MIT // SPDX-License-Identifier: MIT
 pragma solidity ^0.8.13; pragma solidity ^0.8.13;
行 114: 行 114:
 スマートコントラクトのコンパイルはコマンドラインから solc を使用して実行します。 スマートコントラクトのコンパイルはコマンドラインから solc を使用して実行します。
  
-<code - sh>+<code PowerShell>
 solc-windows.exe --abi --bin Counter.sol solc-windows.exe --abi --bin Counter.sol
 </code> </code>
行 132: 行 132:
  
  
-<code コンパイル実行結果>+<code PowerShell コンパイル実行結果>
 ======= Counter.sol:Counter ======= ======= Counter.sol:Counter =======
 Binary: Binary:
行 144: 行 144:
 スマートコントラクトのデプロイは geth console 上で行います。 スマートコントラクトのデプロイは geth console 上で行います。
  
-<code - sh>+<code PowerShell>
 geth --datadir private_network --nodiscover console geth --datadir private_network --nodiscover console
 > var bin = "0x608060405234801561001057600080fd5b50610209806100206000396000f3fe608060405234801561001057600080fd5 > var bin = "0x608060405234801561001057600080fd5b50610209806100206000396000f3fe608060405234801561001057600080fd5
行 164: 行 164:
 デプロイ処理が完了しているため「Contract Account」がaddressに付与されています。 デプロイ処理が完了しているため「Contract Account」がaddressに付与されています。
  
-<code - sh>+<code PowerShell>
 > miner.start() > miner.start()
 null null
行 211: 行 211:
  
  
-<code - sh>+<code PowerShell>
 > myContract.inc.sendTransaction({from:eth.accounts[0]}) > myContract.inc.sendTransaction({from:eth.accounts[0]})
 "0xd254b4b2e830350da787720e9b037e1e27cc11ad93452ff79345e88d716b9cf2" "0xd254b4b2e830350da787720e9b037e1e27cc11ad93452ff79345e88d716b9cf2"
行 222: 行 222:
 get でカウンターの値を参照する。 get でカウンターの値を参照する。
  
-<code - sh>+<code PowerShell>
 > myContract.get.call() > myContract.get.call()
 0 0
行 237: 行 237:
 確認してみましょう。 確認してみましょう。
  
-<code - sh>+<code PowerShell>
 > eth.getBalance(eth.accounts[0]) > eth.getBalance(eth.accounts[0])
 1.496999999999998206439e+21 1.496999999999998206439e+21
blockchain/ethereum構築ハンズオン_ganache編.1651043058.txt.gz · 最終更新: 2022/04/27 07:04 by dot