この文書の現在のバージョンと選択したバージョンの差分を表示します。
| 次のリビジョン | 前のリビジョン | ||
|
ethereum [2017/10/14 21:21] fifi 作成 |
ethereum [2017/10/15 00:19] (現在) fifi |
||
|---|---|---|---|
| ライン 1: | ライン 1: | ||
| - | # イーサリアムの環境の構築 | + | # Ethereum |
| - | ## memo | + | ### 備忘録 |
| - | ```bash | + | [[:ethereum:チュートリアル]] |
| - | 1 ether = 10^3 finney | + | |
| - | 1 ether = 10^6 szabo | + | |
| - | 1 ether = 10^18 wei | + | |
| - | ``` | + | |
| + | [[:ethereum:コントラクト送信失敗対策]] | ||
| - | ## チュートリアル参考 | + | ### Tools |
| - | - [Ethereum スマートコントラクト入門:geth のインストールから Hello World まで](https://qiita.com/amachino/items/b59ec8e46863ce2ebd4a) | + | [Browser-Solidity Remix](https://ethereum.github.io/browser-solidity/) |
| - | + | ||
| - | + | ||
| - | # geth のインストール | + | |
| - | + | ||
| - | ```bash | + | |
| - | Ubuntu の場合 | + | |
| - | + | ||
| - | sudo add-apt-repository -y ppa:ethereum/ethereum | + | |
| - | sudo apt update | + | |
| - | sudo apt install ethereum | + | |
| - | ``` | + | |
| - | + | ||
| - | + | ||
| - | ## geth の起動 | + | |
| - | + | ||
| - | ```bash | + | |
| - | 作業フォルダを作る | + | |
| - | mkdir ~/workspace/my_eth_chain | + | |
| - | + | ||
| - | サーバーを起動? | + | |
| - | $ geth --dev --datadir /home/ubuntu/workspace/my_eth_chain | + | |
| - | + | ||
| - | そうしたら別のターミナルを開き、以下のコマンドで geth のコンソールを開きます。geth.ipc があるディレクトリ (datadir) の中で実行してください。 | + | |
| - | $ geth attach geth.ipc | + | |
| - | ``` | + | |
| - | + | ||
| - | ## 以下コマンドメモ | + | |
| - | + | ||
| - | ```bash | + | |
| - | アカウントの作成 personal.newAccount() | + | |
| - | アカウントの確認 eth.accounts | + | |
| - | コインベースの確認 eth.coinbase (デフォルトではeth.accounts[0]) | + | |
| - | マイニング eth.getBalance(eth.accounts[0]) | + | |
| - | アカウントのアンロック personal.unlockAccount(eth.accounts[0]) | + | |
| - | アカウントのアンロック personal.unlockAccount(address, "password") | + | |
| - | 残高 eth.getBalance(eth.accounts[0]) | + | |
| - | 残高 eth.getBalance("0x******************") | + | |
| - | 送金 eth.sendTransaction({from:eth.accounts[0], to:eth.accounts[1], value:1000000000000000000}) | + | |
| - | トランジションの確認 eth.getTransaction("0x295a6db3a1eb7192057982f531ffd2c74dfd956d22319f4758eac30177f4afc5") | + | |
| - | 同期の確認 eth.syncing | + | |
| - | コインベースの変更 miner.setEtherbase(eth.accounts[0]) | + | |
| - | プライベートキーのインポート $ geth --datadir /someOtherEthDataDir account import ./key.prv | + | |
| - | + | ||
| - | ``` | + | |
| - | + | ||
| - | # スマートコントラクト | + | |
| - | + | ||
| - | ```bash | + | |
| - | Ubuntu の場合 | + | |
| - | $ sudo apt install solc | + | |
| - | $ solc --version | + | |
| - | solc, the solidity compiler commandline interface | + | |
| - | Version: 0.4.17+commit.bdeb9e52.Linux.g++ | + | |
| - | + | ||
| - | + | ||
| - | $ solc --bin --abi HelloWorld.sol | + | |
| - | ``` | + | |
| - | + | ||
| - | + | ||
| - | ```bash | + | |
| - | 以下コピペしてくる | + | |
| - | + | ||
| - | + | ||
| - | > bin = "0x60606040.......................5" | + | |
| - | > abi=[{"constant":fal ... le","type":"function"}] | + | |
| - | > contract = eth.contract(abi) | + | |
| - | + | ||
| - | > personal.unlockAccount(eth.accounts[0]) | + | |
| - | > HelloWorld = contract.new({from: eth.accounts[0], data:bin, gas:1000000 }) | + | |
| - | > miner.start() | + | |
| - | > miner.stop() | + | |
| - | > HelloWorld | + | |
| - | { | + | |
| - | abi: [{ | + | |
| - | constant: false, | + | |
| - | inputs: [{...}], | + | |
| - | name: "setMessage", | + | |
| - | outputs: [], | + | |
| - | payable: false, | + | |
| - | stateMutability: "nonpayable", | + | |
| - | type: "function" | + | |
| - | }, { | + | |
| - | constant: false, | + | |
| - | inputs: [], | + | |
| - | name: "sayHello", | + | |
| - | outputs: [{...}], | + | |
| - | payable: false, | + | |
| - | stateMutability: "nonpayable", | + | |
| - | type: "function" | + | |
| - | }], | + | |
| - | address: "0xf7b0d913ff63433950b2d7e5ed3280470464487b", | + | |
| - | transactionHash: "0x8bcc6faf16e02bdbb2166d6d2643ccdfa2976ff570c2f88f2f7bc56108684170", | + | |
| - | allEvents: function(), | + | |
| - | sayHello: function(), | + | |
| - | setMessage: function() | + | |
| - | } | + | |
| - | ``` | + | |
| - | + | ||
| - | ### スマートコントラクトの呼び出し | + | |
| - | + | ||
| - | 1. sendTransaction() | + | |
| - | 2. call() | + | |
| - | 3. | + | |
| - | + | ||
| - | ```bash | + | |
| - | > HelloWorld.sayHello.call() | + | |
| - | "" <- Nothing yet | + | |
| - | + | ||
| - | > HelloWorld.setMessage.sendTransaction("fifi hello!", {from:eth.accounts[0]}) | + | |
| - | "0x2640526bf49******2c6eebaa0672ad7dda38ff8fd909306d1dd7f7c4f" | + | |
| - | + | ||
| - | > HelloWorld.sayHello.call() | + | |
| - | "fifi hello!" | + | |
| - | + | ||
| - | ``` | + | |
| - | + | ||
| - | ## 本番ネットへ接続 | + | |
| - | ブロックチェーンをダウンロードしているらしくて容量が2GBでいっぱいになった。 | + | |
| - | ローカルPCでブロックチェーンをすべてダウンロードしてやる。 | + | |
| - | cloud9ではテスト環境で遊ぶだけしかできない。 | + | |
| - | 以上 | + | |