Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How Do I Even Smart Contracts?

How Do I Even Smart Contracts?

In diesem Talk beleuchten wir alle Facetten der Smart Contracts. Der Schwerpunkt liegt auf Ethereum, der Blockchain, die die ausführbaren Verträge popularisiert hat. Wir schauen uns an, wo sich deren Entwicklungsmethoden vom klassischen Software Engineering abheben. welche Varianten es sonst noch so gibt und wohin zukünftige Entwicklungen geben. Auch ein kurzer Exkurs in die Korrektheit von Smart Contracts darf nicht fehlen.

Lars Hupel

October 15, 2019
Tweet

More Decks by Lars Hupel

Other Decks in Programming

Transcript

  1. H o w D o I E v e n

    S m a r t C o n t r a c t s ? L a r s H u p e l I N N O Q T e c h n o l o g y N i g h t 2 0 1 9 - 1 0 - 1 5
  2. E t h e r e u m • e

    i n e d e r j ü n g e r e n B l o c k c h a i n s • W ä h r u n g : E t h e r ( E T H ) • P l a t z 2 – 3 i n M a r k t k a p i t a l i s i e r u n g • t e c h n i s c h e N e u e r u n g : P l a t t f o r m f ü r D e c e n t r a l i z e d A p p s
  3. D e c e n t r a l i

    z e d A p p s
  4. E t h e r e u m Z w

    e i A r t e n v o n A c c o u n t s : 1 . E x t e r n a l l y O w n e d ( n a t ü r l i c h e P e r s o n ) 2 . S m a r t C o n t r a c t s ( j u r i s t i s c h e P e r s o n )
  5. S m a r t C o n t r

    a c t s . . . s i n d s p e z i e l l e A c c o u n t s m i t e i g e n e r I d e n t i t ä t u n d K o n t o s t a n d
  6. S m a r t C o n t r

    a c t s . . . s i n d s p e z i e l l e A c c o u n t s m i t e i g e n e r I d e n t i t ä t u n d K o n t o s t a n d . . . h a b e n k e i n e O w n e r s h i p
  7. S m a r t C o n t r

    a c t s . . . s i n d s p e z i e l l e A c c o u n t s m i t e i g e n e r I d e n t i t ä t u n d K o n t o s t a n d . . . h a b e n k e i n e O w n e r s h i p . . . e n t h a l t e n S p e i c h e r z e l l e n m i t v e r ä n d e r l i c h e n W e r t e n
  8. S m a r t C o n t r

    a c t s . . . s i n d s p e z i e l l e A c c o u n t s m i t e i g e n e r I d e n t i t ä t u n d K o n t o s t a n d . . . h a b e n k e i n e O w n e r s h i p . . . e n t h a l t e n S p e i c h e r z e l l e n m i t v e r ä n d e r l i c h e n W e r t e n . . . b e s t e h e n a u s u n v e r ä n d e r l i c h e m C o d e
  9. S m a r t C o n t r

    a c t s . . . s i n d s p e z i e l l e A c c o u n t s m i t e i g e n e r I d e n t i t ä t u n d K o n t o s t a n d . . . h a b e n k e i n e O w n e r s h i p . . . e n t h a l t e n S p e i c h e r z e l l e n m i t v e r ä n d e r l i c h e n W e r t e n . . . b e s t e h e n a u s u n v e r ä n d e r l i c h e m C o d e . . . k ö n n e n m i t a n d e r e n C o n t r a c t s i n t e r a g i e r e n , w e r d e n a b e r n i e s e l b s t s t ä n d i g a k t i v
  10. V e r g l e i c h :

    d i g i t a l e r N o t a r • R e c h t e u n d P f l i c h t e n v e r t r a g l i c h f e s t g e l e g t • n e u t r a l e I n s t a n z ü b e r w a c h t A b l a u f • I n t e r a k t i o n m i t d r i t t e n P a r t e i e n
  11. E t h e r e u m V i

    r t u a l M a c h i n e
  12. V i r t u e l l e M

    a s c h i n e n s i n d M i s c h f o r m e n z w i s c h e n I n t e r p r e t e r u n d C o m p i l e r
  13. W a s k a n n d i e

    E V M ? 1 . a r i t h m e t i s c h e O p e r a t i o n e n 2 . b i t w e i s e & l o g i s c h e O p e r a t i o n e n 3 . H a s h e s ( m e i s t S H A - 3 ) 4 . U m g e b u n g s i n f o r m a t i o n ( K o n t o s t a n d , A u f r u f e r , . . . ) 5 . B l o c k i n f o r m a t i o n ( Z e i t s t e m p e l , B l o c k n u m m e r , . . . ) 6 . S t a c k - u n d S p e i c h e r o p e r a t i o n e n 7 . S p r ü n g e 8 . L o g g i n g 9 . K o n t o o p e r a t i o n e n ( E r z e u g u n g , Z a h l u n g , A u f r u f , . . . )
  14. • S m a r t C o n t

    r a c t s w e r d e n v o n a l l e n M i n e r n a u s g e f ü h r t
  15. • S m a r t C o n t

    r a c t s w e r d e n v o n a l l e n M i n e r n a u s g e f ü h r t • B e r e c h n u n g d e r T r a n s a k t i o n s g e b ü h r a n h a n d d e r A u s f ü h r u n g s d a u e r
  16. • S m a r t C o n t

    r a c t s w e r d e n v o n a l l e n M i n e r n a u s g e f ü h r t • B e r e c h n u n g d e r T r a n s a k t i o n s g e b ü h r a n h a n d d e r A u s f ü h r u n g s d a u e r • U s e r m u s s e i n e T a n k g r ö ß e u n d e i n e n S p r i t p r e i s a n g e b e n
  17. • S m a r t C o n t

    r a c t s w e r d e n v o n a l l e n M i n e r n a u s g e f ü h r t • B e r e c h n u n g d e r T r a n s a k t i o n s g e b ü h r a n h a n d d e r A u s f ü h r u n g s d a u e r • U s e r m u s s e i n e T a n k g r ö ß e u n d e i n e n S p r i t p r e i s a n g e b e n • j e d e O p e r a t i o n h a t e i n e n d e f i n i e r t e n V e r b r a u c h
  18. P r o g r a m m i e

    r u n g & T o o l s
  19. E i n e i n f a c h

    e r C o n t r a c t 608060405234801561001057600080fd5b506000808190555033600160006101000a81548173ffff ffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffff ffffffff1602179055506101be806100686000396000f30060806040526004361061004c57600035 7c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063 3ccfd60b146100515780638f9595d414610068575b600080fd5b34801561005d57600080fd5b5061 0066610086565b005b61007061011d565b6040518082815260200191505060405180910390f35b60 0160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffff ffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614 15156100e257600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffff ffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b60006001600090549061 01000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffff ffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017b5760 0080fd5b3460008082825401925050819055506000549050905600a165627a7a72305820b4d2d5a2 acfa0e197908c7c57826d35a987f64b29f8b97020a4ca96f63ce66630029
  20. E i n e i n f a c h

    e r C o n t r a c t 608060405234801561001057600080fd5b506000808190555033600160006101000a81548173ffff ffffffffffffffffffffffffffffffffffff021916908373ffffffffffffffffffffffffffffffff ffffffff1602179055506101be806100686000396000f30060806040526004361061004c57600035 7c0100000000000000000000000000000000000000000000000000000000900463ffffffff168063 3ccfd60b146100515780638f9595d414610068575b600080fd5b34801561005d57600080fd5b5061 0066610086565b005b61007061011d565b6040518082815260200191505060405180910390f35b60 0160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffff ffffffffffffffffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614 15156100e257600080fd5b600160009054906101000a900473ffffffffffffffffffffffffffffff ffffffffff1673ffffffffffffffffffffffffffffffffffffffff16ff5b60006001600090549061 01000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffff ffffffffffffffff163373ffffffffffffffffffffffffffffffffffffffff1614151561017b5760 0080fd5b3460008082825401925050819055506000549050905600a165627a7a72305820b4d2d5a2 acfa0e197908c7c57826d35a987f64b29f8b97020a4ca96f63ce66630029
  21. S o l i d i t y • p

    o p u l ä r s t e H o c h s p r a c h e f ü r E V M - B y t e c o d e • g e t y p t , o b j e k t o r i e n t i e r t • s y n t a k t i s c h a n J a v a s c r i p t a n g e l e h n t
  22. pragma solidity ^0.4.22; contract Wallet { uint256 balance; address owner;

    constructor () public { balance = 0; owner = msg.sender; } function addfund() payable public returns (uint256) { require (msg.sender == owner); balance += msg.value; return balance; } function withdraw() public { require (msg.sender == owner); selfdestruct(owner); } }
  23. pragma solidity ^0.4.22; contract Wallet { uint256 balance; address owner;

    constructor () public { balance = 0; owner = msg.sender; } function addfund() payable public returns (uint256) { require (msg.sender == owner); balance += msg.value; return balance; } function withdraw() public { require (msg.sender == owner); selfdestruct(owner); } }
  24. pragma solidity ^0.4.22; contract Wallet { uint256 balance; address owner;

    constructor () public { balance = 0; owner = msg.sender; } function addfund() payable public returns (uint256) { require (msg.sender == owner); balance += msg.value; return balance; } function withdraw() public { require (msg.sender == owner); selfdestruct(owner); } }
  25. pragma solidity ^0.4.22; contract Wallet { uint256 balance; address owner;

    constructor () public { balance = 0; owner = msg.sender; } function addfund() payable public returns (uint256) { require (msg.sender == owner); balance += msg.value; return balance; } function withdraw() public { require (msg.sender == owner); selfdestruct(owner); } }
  26. pragma solidity ^0.4.22; contract Wallet { uint256 balance; address owner;

    constructor () public { balance = 0; owner = msg.sender; } function addfund() payable public returns (uint256) { require (msg.sender == owner); balance += msg.value; return balance; } function withdraw() public { require (msg.sender == owner); selfdestruct(owner); } }
  27. pragma solidity ^0.4.22; contract Wallet { uint256 balance; address owner;

    constructor () public { balance = 0; owner = msg.sender; } function addfund() payable public returns (uint256) { require (msg.sender == owner); balance += msg.value; return balance; } function withdraw() public { require (msg.sender == owner); selfdestruct(owner); } }
  28. pragma solidity ^0.4.22; contract Wallet { uint256 balance; address owner;

    constructor () public { balance = 0; owner = msg.sender; } function addfund() payable public returns (uint256) { require (msg.sender == owner); balance += msg.value; return balance; } function withdraw() public { require (msg.sender == owner); selfdestruct(owner); } }
  29. pragma solidity ^0.4.22; contract Wallet { uint256 balance; address owner;

    constructor () public { balance = 0; owner = msg.sender; } function addfund() payable public returns (uint256) { require (msg.sender == owner); balance += msg.value; return balance; } function withdraw() public { require (msg.sender == owner); selfdestruct(owner); } }
  30. pragma solidity ^0.4.22; contract Wallet { uint256 balance; address owner;

    constructor () public { balance = 0; owner = msg.sender; } function addfund() payable public returns (uint256) { require (msg.sender == owner); balance += msg.value; return balance; } function withdraw() public { require (msg.sender == owner); selfdestruct(owner); } }
  31. M e t a m a s k • B

    r o w s e r - P l u g i n z u r V e r w a l t u n g v o n E t h e r e u m - A d r e s s e n • k o m m u n z i e r t ü b e r R P C m i t B l o c k c h a i n - K n o t e n • i n t e g r i e r t m i t w e b 3 . j s
  32. B e i s p i e l e •

    M u l t i - S i g n a t u r - W a l l e t s
  33. B e i s p i e l e •

    M u l t i - S i g n a t u r - W a l l e t s • E R C - 2 0 - T o k e n
  34. B e i s p i e l e •

    M u l t i - S i g n a t u r - W a l l e t s • E R C - 2 0 - T o k e n • H a n d e l s b ö r s e n
  35. B e i s p i e l e •

    M u l t i - S i g n a t u r - W a l l e t s • E R C - 2 0 - T o k e n • H a n d e l s b ö r s e n • W e t t e n
  36. B e i s p i e l e •

    M u l t i - S i g n a t u r - W a l l e t s • E R C - 2 0 - T o k e n • H a n d e l s b ö r s e n • W e t t e n • C r y p t o k i t t i e s
  37. K o m p o n e n t e

    n e i n e r D a p p • W e b a p p l i k a t i o n m i t J S ( m e i s t o p e n s o u r c e ) • S m a r t C o n t r a c t ( s ) • B l o c k c h a i n
  38. S o f t w a r e q u

    a l i t ä t
  39. E n t w i c k l u n

    g s - W o r k f l o w
  40. E n t w i c k l u n

    g s - W o r k f l o w 1 . C o n t r a c t i n S o l i d i t y e n t w i c k e l n
  41. E n t w i c k l u n

    g s - W o r k f l o w 1 . C o n t r a c t i n S o l i d i t y e n t w i c k e l n 2 . m i t R e m i x / M e t a m a s k a u s r o l l e n
  42. E n t w i c k l u n

    g s - W o r k f l o w 1 . C o n t r a c t i n S o l i d i t y e n t w i c k e l n 2 . m i t R e m i x / M e t a m a s k a u s r o l l e n 3 . ? ? ?
  43. • S m a r t C o n t

    r a c t s s i n d u n v e r ä n d e r l i c h
  44. • S m a r t C o n t

    r a c t s s i n d u n v e r ä n d e r l i c h • T r a n s a k t i o n e n s i n d e n d g ü l t i g
  45. • S m a r t C o n t

    r a c t s s i n d u n v e r ä n d e r l i c h • T r a n s a k t i o n e n s i n d e n d g ü l t i g • e s g i b t k e i n e K o n t r o l l i n s t a n z *
  46. • S m a r t C o n t

    r a c t s s i n d u n v e r ä n d e r l i c h • T r a n s a k t i o n e n s i n d e n d g ü l t i g • e s g i b t k e i n e K o n t r o l l i n s t a n z * • F e h l e r s i n d n i c h t k o r r i g i e r b a r *
  47. F a t a l e F e h l

    e r T h e D A O ( 2 0 1 6 ) • D e c e n t r a l i z e d A u t o n o m o u s O r g a n i z a t i o n • e i n e A r t d i g i t a l e r G e b e r v o n W a g n i s k a p i t a l • I d e e : I n v e s t o r * i n n e n s t i m m e n ü b e r K a p i t a l n u t z u n g a b • B u g i m C o n t r a c t f ü h r t e z u m A b g r e i f e n v o n 5 0 M i l l i o n e n U S D
  48. F a t a l e F e h l

    e r P a r i t y W a l l e t ( 2 0 1 7 ) • O n l i n e W a l l e t f ü r E t h e r u n d a n d e r e T o k e n • B u g i m C o n t r a c t f ü h r t e z u m A b g r e i f e n v o n 3 0 M i l l i o n e n U S D
  49. F a t a l e F e h l

    e r P a r i t y W a l l e t ( 2 0 1 7 ) • O n l i n e W a l l e t f ü r E t h e r u n d a n d e r e T o k e n • B u g i m C o n t r a c t f ü h r t e z u m A b g r e i f e n v o n 3 0 M i l l i o n e n U S D • w e i t e r e r B u g f ü h r t e z u m T o t a l v e r l u s t v o n 3 6 0 M i l l i o n e n U S D
  50. Q u a l i t ä t s s

    i c h e r u n g T r u f f l e : F r a m e w o r k f ü r d e n g e s a m t e n E n t w i c k l u n g s z y k l u s • T e s t i n g ( S o l i d i t y u n d J a v a S c r i p t ) • D e p l o y m e n t • M i g r a t i o n s
  51. C o d e i s L a w “

    H o w e v e r , t h e s e m o r e c o m p l e x a g r e e m e n t s , w i t h g r e a t e r e n g a g e m e n t w i t h r e a l w o r l d g o o d s a n d s e r v i c e s , h i g h l i g h t t h e n e c e s s i t y o f e f f e c t i v e d i s p u t e r e s o l u t i o n , a s w e l l a s i n d i c a t e a n e c e s s a r y i n t e r r e l a t i o n w i t h t e r r i t o r i a l l e g a l s y s t e m s .
  52. C o d e i s L a w “

    H o w e v e r , t h e s e m o r e c o m p l e x a g r e e m e n t s , w i t h g r e a t e r e n g a g e m e n t w i t h r e a l w o r l d g o o d s a n d s e r v i c e s , h i g h l i g h t t h e n e c e s s i t y o f e f f e c t i v e d i s p u t e r e s o l u t i o n , a s w e l l a s i n d i c a t e a n e c e s s a r y i n t e r r e l a t i o n w i t h t e r r i t o r i a l l e g a l s y s t e m s . C o n t e s t a t i o n m e c h a n i s m s a r e n e c e s s a r y t o ‘ s o f t e n ’ t h e e f f e c t s o f s e l f - e x e c u t i n g ‘ s m a r t c o n t r a c t s ’, a n d m a k e t r a n s a c t i o n s r e v e r s i b l e , a l l o w - i n g t h e o u t c o m e s o f d i s p u t e r e s o l u t i o n t o b e e n f o r c e d . ” G o l d e n f e i n & L a t e r : “ L e g a l E n g i n e e r i n g o n t h e B l o c k c h a i n : ‘ S m a r t C o n t r a c t s ’ a s L e g a l C o n d u c t ” ( 2 0 1 8 )
  53. H ü r d e n f ü r S

    m a r t C o n t r a c t s • b i s h e r k e i n e e t a b l i e r t e n f o r m a l e n M e t h o d e n • u n k l a r e J u r i s d i k t i o n • N a c h v o l l z i e h b a r k e i t d e s C o d e s
  54. S m a r t C o n t r

    a c t s ? “ T h e r e a r e o n l y t w o t h i n g s y o u n e e d t o k n o w a b o u t s m a r t c o n t r a c t s : 1 . T h e y ’ r e n o t s m a r t . 2 . T h e y ’ r e n o t c o n t r a c t s . ” P h i l i p W a d l e r ( a t F u l l S t a c k F e s t : https://twitter.com/steveklabnik/status/1169599735956672513)
  55. R u s t & W e b A s

    s e m b l y
  56. R u s t & W e b A s

    s e m b l y R u s t • m a s c h i n e n n a h e S p r a c h e v o n M o z i l l a • F o k u s a u f S p e i c h e r s i c h e r h e i t • k e i n G C � W e b A s s e m b l y • A s s e m b l e r s p r a c h e f ü r d e n B r o w s e r • l ä u f t i n d e r J S - S a n d b o x • k e i n Z u g r i f f a u f d e n D O M
  57. E W A S M • W e b A

    s s e m b l y a u f d e r E V M : v i e l v e r s p r e c h e n d e E n t w i c k l u n g • d e r z e i t n o c h u n s p e z i f i z i e r t • e x p e r i m e n t e l l e I m p l e m e n t i e r u n g i n P a r i t y
  58. F a z i t • E t h e

    r e u m i s t b i s h e r g r ö ß t e P l a t t f o r m f ü r D a p p s • h o h e E n t w i c k l u n g s g e s c h w i n d i g k e i t • l e i d e t a n m a n g e l h a f t e m S p r a c h d e s i g n • P r o o f o f A u t h o r i t y u n d E W A S M v i e l v e r s p r e c h e n d , a b e r n o c h i n d e n K i n d e r s c h u h e n
  59. Q & A L a r s H u p

    e l � l a r s . h u p e l @ i n n o q . c o m � @ l a r s r _ h w w w . i n n o q . c o m i n n o Q D e u t s c h l a n d G m b H K r i s c h e r s t r . 1 0 0 4 0 7 8 9 M o n h e i m a . R h . G e r m a n y + 4 9 2 1 7 3 3 3 6 6 - 0 O h l a u e r S t r . 4 3 1 0 9 9 9 B e r l i n G e r m a n y L u d w i g s t r . 1 8 0 E 6 3 0 6 7 O f f e n b a c h G e r m a n y K r e u z s t r . 1 6 8 0 3 3 1 M ü n c h e n G e r m a n y c / o W e W o r k H e r m a n n s t r a s s e 1 3 2 0 0 9 5 H a m b u r g G e r m a n y i n n o Q S c h w e i z G m b H G e w e r b e s t r . 1 1 C H - 6 3 3 0 C h a m S w i t z e r l a n d + 4 1 4 1 7 4 3 0 1 1 1 A l b u l a s t r . 5 5 8 0 4 8 Z ü r i c h S w i t z e r l a n d
  60. L A R S H U P E L C

    o n s u l t a n t i n n o Q D e u t s c h l a n d G m b H L a r s e n j o y s p r o g r a m m i n g i n a v a r i e t y o f l a n - g u a g e s , i n c l u d i n g S c a l a , H a s k e l l , a n d R u s t . H e i s k n o w n a s a f r e q u e n t c o n f e r e n c e s p e a k e r a n d o n e o f t h e f o u n d e r s o f t h e T y p e l e v e l i n i t i a t i v e w h i c h i s d e d i c a t e d t o p r o v i d i n g p r i n c i p l e d , t y p e - d r i v e n S c a l a l i b r a r i e s .
  61. B i l d q u e l l e

    n P y r a m i d e : https://pixabay.com/illustrations/pyramid- sky-reflection-ancient-1076828/ D e c e n t r a l i z e d A p p s : https: //medium.com/swlh/understanding-dapps- decentralized-applications-8f3668ebdc9a S m a r t C o n t r a c t : http://instaco.de/, https://www.ethereum.org/token A k t e n : https://pixabay.com/photos/files- ddr-archive-1633406/ E t h e r e u m T r a n s a c t i o n s : https://medium.com/@preethikasireddy/how- does-ethereum-work-anyway-22d1df506369 P l a t i n e : https://commons.wikimedia.org/wiki/File: Computer_Circuit_Board_MOD_45153619.jpg, H a r l a n d Q u a r r i n g t o n , O G L 1 . 0 G a s P u m p : https://commons.wikimedia.org/wiki/File: Antique_yard_vintage_gas_pumps,_Washington_ LCCN2010630650.tif, L i b r a r y o f C o n g r e s s T r e a t y o f R o m e : https://en.wikipedia.org/wiki/File: Treaty_of_Rome.jpg, a u t h o r u n k n o w n S c a r e d c a t : https://pixabay.com/vectors/cat-scared- hunched-spooky-black-30788/ C o i n s : https://pixabay.com/photos/money- coins-euro-coins-currency-515058/ R a t i f i k a t i o n d e s G r u n d g e s e t z e s : https: //de.wikipedia.org/w/index.php?title=Datei: Grundgesetz_Ratifikationsunterschriften. jpg&filetimestamp=20110526174813& N Y S E : https://pixabay.com/photos/stock- exchange-trading-floor-738671/ P o k e r c h i p s : https://pixabay.com/photos/chips-play- poker-casino-gambling-2038348/ C o n t r a c t U M L : https://github.com/Azure- Samples/blockchain/blob/master/ledger/ template/ethereum-on-azure/permissioning- contracts/validation-set/media/contract- uml.png S e r v e r r a c k : https://pixabay.com/photos/server-cloud- development-business-1235959/ L i g h t n i n g : https://pixabay.com/photos/lightning-storm- weather-sky-399853/ F e r r i s t h e C r a b : https://www.rust-lang.org/what/wasm, M I T C o n s t r u c t i o n s i t e : https://pixabay.com/photos/building- construction-site-cranes-768815/ R a i l r o a d : https://pixabay.com/photos/track- railway-line-rail-traffic-3670209/