25
Write Your Own Contracts Joris Bontje @mids106 ethereum

Ethereum: Write your own contracts

  • Upload
    mids106

  • View
    841

  • Download
    5

Embed Size (px)

DESCRIPTION

Write your own Ethereum Contracts. Presentation given at the Ethereum Meetup Amsterdam by Joris Bontje / @mids106

Citation preview

Page 1: Ethereum: Write your own contracts

Write Your Own Contracts

Joris Bontje!@mids106

ethereum

Page 2: Ethereum: Write your own contracts

What can you do with them?

Page 3: Ethereum: Write your own contracts
Page 4: Ethereum: Write your own contracts

Platform

Page 5: Ethereum: Write your own contracts

Contracts lives on the Ethereum block chain

Have own Ethereum address and balance

Can send and receive transactions

“Activated” when you send a transaction to it

Page 6: Ethereum: Write your own contracts

Turing complete language

Fee per CPU step (extra for storage, tx, crypto)

2^256 Storage entries

Scripts can modify their own code(!)

Page 7: Ethereum: Write your own contracts

Available languages

Page 8: Ethereum: Write your own contracts

EtherScriptTXVALUE PUSH 25 PUSH 10 PUSH 18 EXP MUL LE NOT PUSH 34 JMPI STOP PUSH 34 JMP PUSH 0 TXDATA SLOAD NOT PUSH 0 TXDATA PUSH 1000 LT NOT MUL NOT NOT PUSH 34 JMPI STOP PUSH 1 TXDATA PUSH 0 TXDATA SSTORE

Page 9: Ethereum: Write your own contracts

CLL: C-Like Language

if tx.value <= 25 * 10^18: stop elif contract.storage[tx.data[0]] or tx.data[0] < 1000: stop contract.storage[tx.data[0]] = tx.data[1]

Page 10: Ethereum: Write your own contracts

LLL: Lisp-Like Language

(seq (unless (>= (txvalue) (* 20 (basefee))) (stop)) (if (txdatan) (seq (sstore (txsender) (- (sload (txsender)) (txdata 0))) (mktx (txsender) (txdata 0) 0) ) (sstore (txsender) (+ (sload (txsender)) (- (txvalue) (* 20 (basefee))) ) ) ) )

Page 11: Ethereum: Write your own contracts

Contract Walkthrough

Page 12: Ethereum: Write your own contracts

sub-currency.cll

Page 13: Ethereum: Write your own contracts

namecoin.cll

Page 14: Ethereum: Write your own contracts

NameReg in Action

Page 15: Ethereum: Write your own contracts

Scary Screenshot

AlethZero v0.3.4 - 2014-02-14

Page 16: Ethereum: Write your own contracts

Future Contract Editor?

Page 17: Ethereum: Write your own contracts

Simulation

Page 18: Ethereum: Write your own contracts
Page 19: Ethereum: Write your own contracts
Page 20: Ethereum: Write your own contracts
Page 21: Ethereum: Write your own contracts
Page 22: Ethereum: Write your own contracts

Resources

Page 23: Ethereum: Write your own contracts

Ethereum whitepaper https://github.com/ethereum/wiki/wiki/%5BEnglish%5D-White-Paper

Code examples & Simulators https://github.com/jorisbontje/cll-sim/https://github.com/k1n0k0/ethereum-simulator/

CLLhttps://github.com/ethereum/wiki/wiki/%5BEnglish%5D-CLL

LLLhttps://github.com/ethereum/cpp-ethereum/wiki/LLL%20Tutorialhttps://github.com/ethereum/cpp-ethereum/wiki/LLL%20Examples

Page 24: Ethereum: Write your own contracts

http://youtu.be/BSEJEanSvUU

Page 25: Ethereum: Write your own contracts

Questions?!@mids106