Ethereum contracts are small pieces of code that can be deployed to the Ethereum blockchain to execute autonomously. They are written in the Solidity language and can store and transfer value and data. To develop contracts, they must be compiled from Solidity to bytecode, deployed to the blockchain, and can then be interacted with by users via transactions that call functions defined in the contract's application binary interface (ABI). Examples of suitable contracts include tokens, crowdfunding, voting systems, and decentralized autonomous organizations.
5. 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.
7. 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.
8. 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.
9. 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.
10. 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! :-)
11. 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;