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.
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.
Writing Contracts
● Write contracts in the Solidity language.
● Create the UI for contracts in HTML/JS.
● AlethZero is a good place to start.
● solc / eth / Chrome is the cutting edge.
● Mix IDE & Mist browser are the future.
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 uses too much processor time,
storage, or secrecy.
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! :-)
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;