FiFiWiki2

FiFiWikiの第2版

ユーザ用ツール

サイト用ツール


ethereum

差分

この文書の現在のバージョンと選択したバージョンの差分を表示します。

この比較画面にリンクする

両方とも前のリビジョン 前のリビジョン
次のリビジョン
前のリビジョン
ethereum [2017/10/14 21:40]
fifi
ethereum [2017/10/15 00:19] (現在)
fifi
ライン 1: ライン 1:
- +# Ethereum
-[[:​ethereum:​チュートリアル]] +
- +
-イーサリアムチュートリアル +
- +
- - [Ethereum ​スマートコントラクト入門:geth のインストールから Hello World まで](https://​qiita.com/​amachino/​items/​b59ec8e46863ce2ebd4a) +
- +
- +
-## geth のインストール +
- +
-Ubuntu の場合 +
- +
-```bash +
-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 +
-``` +
- +
-# スマートコントラクト +
- +
-```solidity +
-contract SingleNumRegister { +
-    uint storedData;​ +
-    function set(uint x) { +
-        storedData = x; +
-    } +
-    function get() constant returns (uint retVal) { +
-    return storedData;​ +
-    } +
-+
-``` +
- +
-コンパイル +
-```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ではテスト環境で遊ぶだけしかできない。 +
-以上+
  
  
 +### 備忘録
  
 +[[:​ethereum:​チュートリアル]]
  
-## memo+[[:​ethereum:​コントラクト送信失敗対策]]
  
-```bash +### Tools
-1 ether = 10^3 finney +
-1 ether = 10^6 szabo +
-1 ether = 10^18 wei +
-```+
  
 +[Browser-Solidity Remix](https://​ethereum.github.io/​browser-solidity/​)
ethereum.1508017206.txt.gz · 最終更新: 2017/10/14 21:40 by fifi