2. Implementations Of Ethereum
● go-ethereum
● cpp-ethereum
● pyethereum
● ethereumj (java)
● node-ethereum (client)
All implement the same VM / network.
Docker images are available.
8. What Is A Contract?
● A small piece of code.
● A self-contained piece of code.
● A small amount of data.
● A public body of data.
● A small amount of Ether.
10. So How Do We Get External State?
● Direct user input
● Oracles
● Transactions / feeds from trusted parties
● SchellingCoins
● By hash...
11. What Is A Transaction?
● How we communicate with contracts.
● Data and Ether can be sent via transactions.
● Sent from the JS API or other contracts.
● Transactions cost "gas", the sender pays.
● JavaScript API can use accessors instead.
12. Transaction Costs
“usually, a computational step costs 1 gas, but
some operations cost higher amounts of gas
because they are more computationally
expensive, or increase the amount of data that
must be stored as part of the state. There is
also a fee of 5 gas for every byte in the
transaction data.” - The Whitepaper.
13. Bad Ideas For Contracts
● Doom on the EVM (too much processing).
● Video on the blockchain (too much storage).
● Ethereum web server (no network access).
● Blockchain DRM (blockchain is public).
● Anything that needs too much processor
time, storage, or secrecy.
14. Good Ideas For Contracts
● Altcoins, tokens, assets.
● Crowdfunding, fan incentive schemes.
● Voting systems, prediction markets, lotteries.
● Access control - sites, games, doors, cars.
● DAOs - Organizations on the blockchain.
● Use your imagination! :-)
15. Writing Contracts
● Write contracts in the Solidity language.
● Create the UI for contracts in HTML/JS.
● AlethZero is a good development system.
● solc / eth / Chrome is the cutting edge.
● Test on a private chain.
● Mix IDE & Mist browser are the future.
16. Solidity
● C-ish syntax() {;}
● Statically typed
● Types for hashes, addresses, memory cells
● Structs, mappings, events
● Support for invariants & other conditions
● Provably correct subset
17. A Solidity Contract
contract Coin {
address minter;
mapping (address => uint) balances;
function Coin() {
minter = msg.sender;
}
function mint(address owner, uint amount) {
if (msg.sender != minter) return;
balances[owner] += amount;
}
function send(address receiver, uint amount) {
if (balances[msg.sender] < amount) return;
balances[msg.sender] -= amount;
balances[receiver] += amount;
18. Compiling The Contract
$ solc --binary file --json-abi file Coin.sol
(Or paste it into AlethZero...)