Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
スマートコントラクトプログラミング (4) イーサリアム実習 II / Ethereum Pr...
Search
Kenji Saito
PRO
May 31, 2017
Technology
1
280
スマートコントラクトプログラミング (4) イーサリアム実習 II / Ethereum Practice II
ブロックチェーンハブ主催で開催している (第2期) スマートコントラクトプログラミング講義 (4) 「イーサリアム実習 II」のスライドです。2017年5月31日(水) に使用しました。
Kenji Saito
PRO
May 31, 2017
Tweet
Share
More Decks by Kenji Saito
See All by Kenji Saito
P 値と有意差/分散分析 / P-value, Significant Difference and Analysis of Variance
ks91
PRO
0
17
関連2群のt検定/独立2群のt検定 / Related 2-group t-test and independent 2-group t-test
ks91
PRO
0
47
A Guide to Paper Writing Support with Generative AI - A Joint Zemi
ks91
PRO
0
9
正規分布と簡単な統計理論/t分布と信頼区間 / Normal distribution, simple statistical theory, t-distribution and confidence intervals
ks91
PRO
0
42
じわじわ迫ってきている自動化社会 (その先にメタ・ネイチャー) / The Slowly Approaching Automated Society (and its beyond: Meta-Nature)
ks91
PRO
0
6
起こりうる誤った推論/平均・分散・標準偏差・自由度 / Possible false inferences, means, variances, standard deviations and degrees of freedom
ks91
PRO
0
57
LaTeX と Overleaf によるショートペーパー作成 / Short paper writing with LaTeX and Overleaf
ks91
PRO
0
23
R を用いた検定(補講) (1) — Welch 検定 / Tests using R (supplementary) (1) - Welch test
ks91
PRO
0
12
R を用いた検定(補講) (2) — カイ二乗検定 / Tests using R (supplementary) (2) - Chi-squared test
ks91
PRO
0
13
Other Decks in Technology
See All in Technology
怖くない!ゼロから始めるPHPソースコードコンパイル入門
colopl
0
200
Zero Data Loss Autonomous Recovery Service サービス概要
oracle4engineer
PRO
1
4.8k
MasterMemory v3 最速確認会
yucchiy
0
250
組織に自動テストを書く文化を根付かせる戦略(2024冬版) / Building Automated Test Culture 2024 Winter Edition
twada
PRO
21
6.3k
ISUCON、今年も参加してみた / ISUCON, I challenged it again this year.
dero1to
0
110
re:Invent をおうちで楽しんでみた ~CloudWatch のオブザーバビリティ機能がスゴい!/ Enjoyed AWS re:Invent from Home and CloudWatch Observability Feature is Amazing!
yuj1osm
0
140
10年もののバグを退治した話
n_seki
0
110
UI State設計とテスト方針
rmakiyama
4
890
サービスでLLMを採用したばっかりに振り回され続けたこの一年のあれやこれや
segavvy
2
640
スケールし続ける事業とサービスを支える組織とアーキテクチャの生き残り戦略 / The survival strategy for Money Forward’s engineering.
moneyforward
0
140
Oracle Cloud Infrastructure:2024年12月度サービス・アップデート
oracle4engineer
PRO
1
360
DUSt3R, MASt3R, MASt3R-SfM にみる3D基盤モデル
spatial_ai_network
3
370
Featured
See All Featured
Fantastic passwords and where to find them - at NoRuKo
philnash
50
2.9k
No one is an island. Learnings from fostering a developers community.
thoeni
19
3k
Building an army of robots
kneath
302
44k
How to Think Like a Performance Engineer
csswizardry
22
1.2k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
230
52k
Documentation Writing (for coders)
carmenintech
67
4.5k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
507
140k
Automating Front-end Workflow
addyosmani
1366
200k
Fireside Chat
paigeccino
34
3.1k
The Cult of Friendly URLs
andyhume
78
6.1k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
29
2k
Testing 201, or: Great Expectations
jmmastey
41
7.2k
Transcript
II (4) CSO / SFC
[email protected]
II – (4) –
2017-05-31 – p.1/45
1. : 2. ∼ ∼ II – (4) – 2017-05-31
– p.2/45
1. : 2. : 3. / II – (4) –
2017-05-31 – p.3/45
1. II – (4) – 2017-05-31 – p.4/45
(m2 ) 1 1 II – (4) – 2017-05-31 –
p.5/45
IndivisibleAsset string public _name; string public _symbol; uint256 public _quantity;
address public _owner; _name ( ) _symbol _quantity (m2 ) _owner _ Solidity . . . II – (4) – 2017-05-31 – p.6/45
IndivisibleAsset event Transfer(address indexed from, address indexed to); from to
II – (4) – 2017-05-31 – p.7/45
IndivisibleAsset function IndivisibleAsset(string name, string symbol, uint256 quantity) { _name
= name; _symbol = symbol; _quantity = quantity; _owner = msg.sender; } II – (4) – 2017-05-31 – p.8/45
IndivisibleAsset getOwner() function getOwner() returns (address owner) { return (_owner);
} II – (4) – 2017-05-31 – p.9/45
IndivisibleAsset transfer() function transfer(address to) { if (_owner != msg.sender)
{ throw; } _owner = to; Transfer(msg.sender, to); } ( / ) $ populus compile II – (4) – 2017-05-31 – p.10/45
(1) import pytest @pytest.fixture() def asset_contract(chain): AssetFactory = chain.get_contract_factory(’IndivisibleAsset’) deploy_txid
= AssetFactory.deploy(args=[ "5322 Endo, Fujisawa", "mˆ2", 300, ]) contract_address = chain.wait.for_contract_address(deploy_txid) return AssetFactory(address=contract_address) SFC (300m2 ) II – (4) – 2017-05-31 – p.11/45
(2) def test_indivisible_assset(asset_contract, chain): account0 = chain.web3.eth.accounts[0] account1 = chain.web3.eth.accounts[1]
assert asset_contract.call().getOwner() == account0 txid = asset_contract.transact().transfer(account1) chain.wait.for_receipt(txid) assert asset_contract.call().getOwner() == account1 account0 account1 II – (4) – 2017-05-31 – p.12/45
$ py.test tests/test_indivisible_asset.py II – (4) – 2017-05-31 – p.13/45
2. II – (4) – 2017-05-31 – p.14/45
transfer settle, retrieve asset, retrieve token 3 II – (4)
– 2017-05-31 – p.15/45
1. ( ) 2. ( ) 3. ( ) II
– (4) – 2017-05-31 – p.16/45
OneTimeEscrow settle() function settle() { address addr = this; /*
this */ if (_token.getBalanceOf(this) < _price || _asset.getOwner() != addr) { throw; } _token.transfer(_seller , _price); _asset.transfer(_buyer); Settled(); /* */ } settle() transfer ( / ) $ populus compile II – (4) – 2017-05-31 – p.17/45
(1) import pytest @pytest.fixture() def token_contract(chain): . . . @pytest.fixture()
def asset_contract(chain): . . . II – (4) – 2017-05-31 – p.18/45
(2) def test_one_time_escrow(token_contract, asset_contract, chain): account0 = chain.web3.eth.accounts[0] account1 =
chain.web3.eth.accounts[1] txid = chain.web3.eth.sendTransaction({ ’from’: account0, ’to’: account1, ’value’: chain.web3.toWei(1, "ether") }) chain.wait.for_receipt(txid) txid = token_contract.transact().transfer(account1, 300) chain.wait.for_receipt(txid) account0 account1 1Ether 300BcH 300BcH TX II – (4) – 2017-05-31 – p.19/45
(3) EscrowFactory = chain.get_contract_factory(’OneTimeEscrow’) txid = EscrowFactory.deploy(args=[ token_contract.address, account1, asset_contract.address,
account0, 300, ]) contract_address = chain.wait.for_contract_address(txid) EscrowFactory.address = contract_address; account1 account0 300BcH II – (4) – 2017-05-31 – p.20/45
(4) txid = token_contract.transact({ ’from’: account1 }).transfer(contract_address, 300) chain.wait.for_receipt(txid) txid
= asset_contract.transact().transfer(contract_address) chain.wait.for_receipt(txid) assert token_contract.call().getBalanceOf(account0) == 999700 assert token_contract.call().getBalanceOf(account1) == 0 assert token_contract.call().getBalanceOf(contract_address) == 300 assert asset_contract.call().getOwner() == contract_address account1 300BcH account0 II – (4) – 2017-05-31 – p.21/45
(5) txid = EscrowFactory.transact().settle(); chain.wait.for_receipt(txid) assert token_contract.call().getBalanceOf(account0) == 1000000 assert
token_contract.call().getBalanceOf(account1) == 0 assert token_contract.call().getBalanceOf(contract_address) == 0 assert asset_contract.call().getOwner() == account1 settle() II – (4) – 2017-05-31 – p.22/45
$ py.test tests/test_one_time_escrow.py : settle() II – (4) – 2017-05-31
– p.23/45
3. / Hyperledger (Fabric, Sawtooth, Iroha, Burrow) R3 Corda Enterprise
Ethereum Alliance II – (4) – 2017-05-31 – p.24/45
(Hyperledger ) ( ) ( ) ( ) IoT /
/ II – (4) – 2017-05-31 – p.25/45
( ) ( ) ← II – (4) – 2017-05-31
– p.26/45
(Linux Foundation) https://www.hyperledger.org Apache License, Version 2.0 II – (4)
– 2017-05-31 – p.27/45
/ : Proposal → Incubation → Active → Deprecated →
End of Life II – (4) – 2017-05-31 – p.28/45
: https://www.hyperledger.org/about/members II – (4) – 2017-05-31 – p.29/45
Fabric (IBM) IBM Digital Asset Holdings http://hyperledger-fabric.readthedocs.io/en/latest/ State : Active
II – (4) – 2017-05-31 – p.30/45
( ) II – (4) – 2017-05-31 – p.31/45
II – (4) – 2017-05-31 – p.32/45
(Docker) (chaincode) PBFT (Practical BFT) RocksDB CA PKI v1.0 DB
CA II – (4) – 2017-05-31 – p.33/45
Sawtooth (Intel) https://github.com/hyperledger/sawtooth-core State : Active II – (4) –
2017-05-31 – p.34/45
( ) (permissioned) (permissionless) Proof of Elapsed Time (PoET) Proof
of Work ( ) (Intel ) Transaction Families II – (4) – 2017-05-31 – p.35/45
(transaction families) (PoET ) PoET ( ) (transaction families) II
– (4) – 2017-05-31 – p.36/45
Iroha ( ) https://github.com/hyperledger/iroha State : Active II – (4)
– 2017-05-31 – p.37/45
( ) DLT : C++ Sumeragi Whitepaper : https://github.com/hyperledger/iroha/blob/master/docs/iroha_whitepaper.md II
– (4) – 2017-05-31 – p.38/45
JVM (chaincode) Sumeragi (BFT) II – (4) – 2017-05-31 –
p.39/45
Corda (R3) R3 https://github.com/corda/corda II – (4) – 2017-05-31 –
p.40/45
R3 R3CEV 77 (2017 2 ) 3 SBI , R3Net(
) Corda II – (4) – 2017-05-31 – p.41/45
Corda Corda : : II – (4) – 2017-05-31 –
p.42/45
+ CAP II – (4) – 2017-05-31 – p.43/45
JVM ( ) (Uniqueness Services) UTXO X.509 PKI ( )
II – (4) – 2017-05-31 – p.44/45
⇒ ⇒ II – (4) – 2017-05-31 – p.45/45