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
スマートコントラクトプログラミング (3) イーサリアム実習 I / Ethereum Pra...
Search
Kenji Saito
PRO
May 24, 2017
Technology
1
450
スマートコントラクトプログラミング (3) イーサリアム実習 I / Ethereum Practice I
ブロックチェーンハブ主催で開催している (第2期) スマートコントラクトプログラミング講義 (3) 「イーサリアム実習 I」のスライドです。2017年5月24日(水) に使用しました。
Kenji Saito
PRO
May 24, 2017
Tweet
Share
More Decks by Kenji Saito
See All by Kenji Saito
デジタルトランスフォーメーションと民主主義 / Digital Transformation and Democracy
ks91
PRO
0
5
We Never Took the Kobayashi Maru Test Until Now. What Do You Think of Our Solutions? — Journeys of the Mind Through a No-Win Game
ks91
PRO
0
17
思いつきが武器になる:研究というゲームを始めよう / Ideas Are Your Equipments : Let the Game of Research Begin!
ks91
PRO
0
75
ロボットを雰囲気(ヴァイブ)でプログラミングするこどもたち / Children Vibe-Programming Robots
ks91
PRO
0
21
アカデミーキャンプ 2025 SuuuuuuMMeR「燃えろ!!ロボコン」 / Academy Camp 2025 SuuuuuuMMeR "Burn the Spirit, Robocon!!" DAY 3
ks91
PRO
0
31
アカデミーキャンプ 2025 SuuuuuuMMeR「燃えろ!!ロボコン」 / Academy Camp 2025 SuuuuuuMMeR "Burn the Spirit, Robocon!!" DAY 2
ks91
PRO
0
33
アカデミーキャンプ 2025 SuuuuuuMMeR「燃えろ!!ロボコン」 / Academy Camp 2025 SuuuuuuMMeR "Burn the Spirit, Robocon!!" DAY 1
ks91
PRO
0
160
未来へのフォワードキャスト / Forward Cast to the Future
ks91
PRO
0
87
発表と総括 / Presentations and Summary
ks91
PRO
0
62
Other Decks in Technology
See All in Technology
MCPで変わる Amebaデザインシステム「Spindle」の開発
spindle
PRO
3
3.2k
Agile PBL at New Grads Trainings
kawaguti
PRO
1
420
大「個人開発サービス」時代に僕たちはどう生きるか
sotarok
20
9.9k
LLMを搭載したプロダクトの品質保証の模索と学び
qa
0
1k
なぜスクラムはこうなったのか?歴史が教えてくれたこと/Shall we explore the roots of Scrum
sanogemaru
5
1.6k
Rustから学ぶ 非同期処理の仕組み
skanehira
1
130
Android Audio: Beyond Winning On It
atsushieno
0
110
[ JAWS-UG 東京 CommunityBuilders Night #2 ]SlackとAmazon Q Developerで 運用効率化を模索する
sh_fk2
3
400
Snowflake Intelligenceにはこうやって立ち向かう!クラシルが考えるAI Readyなデータ基盤と活用のためのDataOps
gappy50
0
180
ZOZOマッチのアーキテクチャと技術構成
zozotech
PRO
3
1.5k
下手な強制、ダメ!絶対! 「ガードレール」を「檻」にさせない"ガバナンス"の取り方とは?
tsukaman
2
440
DDD集約とサービスコンテキスト境界との関係性
pandayumi
3
280
Featured
See All Featured
Sharpening the Axe: The Primacy of Toolmaking
bcantrill
44
2.5k
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
34
6k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
229
22k
The MySQL Ecosystem @ GitHub 2015
samlambert
251
13k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
31
2.5k
Thoughts on Productivity
jonyablonski
70
4.8k
YesSQL, Process and Tooling at Scale
rocio
173
14k
A Tale of Four Properties
chriscoyier
160
23k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.9k
Dealing with People You Can't Stand - Big Design 2015
cassininazir
367
27k
Faster Mobile Websites
deanohume
309
31k
Why Our Code Smells
bkeepers
PRO
339
57k
Transcript
I (3) CSO / SFC
[email protected]
I – (3) –
2017-05-24 – p.1/37
1. 2. 3. 4. 5. I – (3) – 2017-05-24
– p.2/37
1. : 2. ∼ ∼ I – (3) – 2017-05-24
– p.3/37
1. : I – (3) – 2017-05-24 – p.4/37
BcH-smart-contract-programming.zip contracts tests I – (3) – 2017-05-24 – p.5/37
Solidity JavaScript ( , ) (constructor) ( ) ( )
Ether I – (3) – 2017-05-24 – p.6/37
pragma solidity ˆ0.4.8; contract MyToken { ( ) : (EVM
) : function MyToken(...) { /* */ : } : } function C (/* */ // ) I – (3) – 2017-05-24 – p.7/37
MyToken string public name; string public symbol; uint8 public decimals;
mapping (address => uint256) public balanceOf; name, symbol decimals : 2 100 1.00 mapping balanceOf I – (3) – 2017-05-24 – p.8/37
MyToken event Transfer(address indexed from, address indexed to, uint256 value);
indexed (3 ) MyToken function Transfer() Ethereum-Wallet I – (3) – 2017-05-24 – p.9/37
MyToken function MyToken(uint256 _supply, string _name, string _symbol, uint8 _decimals)
{ if (_supply == 0) { _supply = 1000000; /* _supply 1,000,000 */ } balanceOf[msg.sender] = _supply; name = _name; symbol = _symbol; decimals = _decimals; } msg.sender _supply C++ _ I – (3) – 2017-05-24 – p.10/37
MyToken getBalanceOf() function getBalanceOf(address _addr) returns (uint256 balance) { return
(balanceOf[_addr]); } I – (3) – 2017-05-24 – p.11/37
MyToken transfer() function transfer(address _to, uint256 _value) { if (balanceOf[msg.sender]
< _value) { /* */ throw; } if (balanceOf[_to] + _value < balanceOf[_to]) { /* */ throw; } balanceOf[msg.sender] -= _value; balanceOf[_to] += _value; Transfer(msg.sender, _to, _value); } throw (function ) catch I – (3) – 2017-05-24 – p.12/37
(1) import pytest @pytest.fixture() def token_contract(chain): TokenFactory = chain.get_contract_factory(’MyToken’) deploy_txid
= TokenFactory.deploy(args=[ 0, "BcH Coin", "BcH", 0, ]) contract_address = chain.wait.for_contract_address(deploy_txid) return TokenFactory(address=contract_address) populus I – (3) – 2017-05-24 – p.13/37
(2) def test_my_token(token_contract, chain): account0 = chain.web3.eth.accounts[0] account1 = chain.web3.eth.accounts[1]
assert token_contract.call().getBalanceOf(account0) == 1000000 assert token_contract.call().getBalanceOf(account1) == 0 txid = token_contract.transact().transfer(account1, 10) chain.wait.for_receipt(txid) assert token_contract.call().getBalanceOf(account0) == 999990 assert token_contract.call().getBalanceOf(account1) == 10 account0 coinbase account1 account0 account1 10BcH I – (3) – 2017-05-24 – p.14/37
$ py.test tests/test_my_token.py I – (3) – 2017-05-24 – p.15/37
2. ∼ ∼ I – (3) – 2017-05-24 – p.16/37
A, B A-B m A B A B A B
. . . I – (3) – 2017-05-24 – p.17/37
1. X 2. X C 3. C 1. 2. 3.
reliable multicast I – (3) – 2017-05-24 – p.18/37
: I – (3) – 2017-05-24 – p.19/37
(safety) (liveness) ( ) ( = ) I – (3)
– 2017-05-24 – p.20/37
→ / (benign) → (Byzantine) (malicious) I – (3) –
2017-05-24 – p.21/37
FLP Fischer, Lynch, Paterson I – (3) – 2017-05-24 –
p.22/37
CAP Consistency ( ) Availability ( ) Partition tolerance (
) ⇒ 3 C Eventual consistency ( ) . . . I – (3) – 2017-05-24 – p.23/37
Consistency ( ) Strong consistency ( ) (safety) Eventual consistency
( ) (liveness) ↑ Weak consistency ( ) ↑ ( ) I – (3) – 2017-05-24 – p.24/37
n = f ( ) ⇒ I – (3) –
2017-05-24 – p.25/37
(1) 1 1, 2 n ≤ 3f I – (3)
– 2017-05-24 – p.26/37
(2) I – (3) – 2017-05-24 – p.27/37
CS1 : CS2 : CS3 : CL1 : CL2 :
: : (e.g. ) I – (3) – 2017-05-24 – p.28/37
(B)FT-CUP (Consensus with Unknown Participants) ( / ) : FT
(Fault-Tolerant) : BFT (Byzantine Fault-Tolerant) P2P n FT/BFT I – (3) – 2017-05-24 – p.29/37
State Machine Replication ( ) (by ) (since 1984) (
) ( ) . . . ( ) I – (3) – 2017-05-24 – p.30/37
( ) ( ) ( ) ( ) (by )
⇒ ( ) I – (3) – 2017-05-24 – p.31/37
P2P : P2P 3 3 ( ) strategyproof group strategyproof
I – (3) – 2017-05-24 – p.32/37
(Sybil) 16 I – (3) – 2017-05-24 – p.33/37
again n > 3f R F R > 2F ⇒
I – (3) – 2017-05-24 – p.34/37
( ) f = 1 ⇒ R I – (3)
– 2017-05-24 – p.35/37
(centralized) (decentralized) (distributed) Paul Baran, “On Distributed Communications Networks”, 1964
(C) (A) I – (3) – 2017-05-24 – p.36/37
II Hyperledger I – (3) – 2017-05-24 – p.37/37