Ethereum: Write your own contracts

Preview:

DESCRIPTION

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

Citation preview

Write Your Own Contracts

Joris Bontje!@mids106

ethereum

What can you do with them?

Platform

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

Turing complete language

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

2^256 Storage entries

Scripts can modify their own code(!)

Available languages

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

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]

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))) ) ) ) )

Contract Walkthrough

sub-currency.cll

namecoin.cll

NameReg in Action

Scary Screenshot

AlethZero v0.3.4 - 2014-02-14

Future Contract Editor?

Simulation

Resources

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

http://youtu.be/BSEJEanSvUU

Questions?!@mids106

Recommended