SlideShare a Scribd company logo
1 of 21
Smart contracts on Ethereum
Getting started
DappsMedia Tomoaki Sato
June 2015
Main source: https://github.com/ethereum/wiki/wiki/Ethereum-Development-Tutorial
~From blockchain installation to make tokenContract ~
What are smart contracts on Ethereum blockchain?
1Source: https://github.com/ethereum/wiki/wiki/White-Paper
Original idea derived from Nick Szabo’s paper in1997.
http://szabo.best.vwh.net/smart_contracts_idea.html
and going to be live by Stateful blockchain with Ethereum virtual machine
What kind of application needs smart contracts ?
2Source: Source
1.Vending machine
2.Asset automated transfer system
• Token Systems
• Financial derivatives
• Identity and Reputation Systems
• Decentralized File Storage
• Decentralized Autonomous
Organizations
• See also
https://docs.google.com/spreads
heets/u/1/d/1VdRMFENPzjL2V-
vZhcc_aa5-
ysf243t5vXlxC2b054g/edit
After blockchain age
Smart contract 4 purposes
3
Smart contract
1. Maintain a data
store contract.
2. Forwarding
contract which
has access policy,
and some
conditions to
send messages.
3. Ongoing
contract such as
escrow,
crowdfunding.
4.Library type
contract which
provides
functions to other
contracts.
Process objectives
Ethereum contracts objectives
Source: https://github.com/ethereum/wiki/wiki/Ethereum-Development-Tutorial
1.Maintain a data store contract
4
Most simple type can be used by Embark (more about the later)
Source: http://jorisbontje.github.io/sleth/#/
# app/contracts/simple_storage.sol
contract SimpleStorage {
uint storedData;
function set(uint x) {
storedData = x * x * x;
}
function get() constant returns (uint retVal)
{
return storedData;
}
}
2.Forwarding contract
5
Sleth is the decentralized slot machine application using forwarding type smart contract.
Currently I can not find the forwarding type contract which can be run on testnet. If you know please comment on.
Source: https://github.com/ethereum/wiki/wiki/Ethereum-Development-Tutorial
When Bob wants to finalize the bet, the following
steps happen:
1. A transaction is sent, triggering a message
from Bob's EOA to Bob's forwarding contract.
2. Bob's forwarding contract sends the hash of
the message and the Lamport signature to a
contract which functions as a Lamport
signature verification library.
3. The Lamport signature verification library sees
that Bob wants a SHA256-based Lamport sig,
so it calls the SHA256 library many times as
needed to verify the signature.
4. Once the Lamport signature verification library
returns 1, signifying that the signature has
been verified, it sends a message to the
contract representing the bet.
5. The bet contract checks the contract providing
the San Francisco temperature to see what the
temperature is.
3.Ongoing contract
6Source: https://github.com/WeiFund/WeiFund/blob/master/WeiFund.sol
Most smart contracts are ongoing type contracts, such as crowdfunding is ongoing contract.
// WeiFund System
// Start, donate, payout and refund crowdfunding campaigns
// @authors:
// Nick Dodson <thenickdodson@gmail.com>
// If goal is not reached and campaign is expired, contributers can get the
refunded individually
// If goal is reached by alloted time, contributions can still be made
contract WeiFundConfig
{
function onContribute(uint cid, address addr, uint amount){}
function onRefund(uint cid, address addr, uint amount){}
function onPayout(uint cid, uint amount){}
}
contract WeiFund
{
struct User
{
uint numCampaigns;
mapping(uint => uint) campaigns;
}
struct Funder
{
address addr;
uint amount;
}
...
4. Library contract
7Source: https://github.com/ethereum/wiki/wiki/Ethereum-Development-Tutorial
Smart contract which provides utility functions.
In the case below, Lamport sig verifier contract is Library type contracts.
The contract will provide a set of function
Structuring every type of smart contract
8
You can make structure by combining different contracts
Source:https://github.com/ethereum/wiki/wiki/Ethereum-Development-Tutorial
LET’S ENJOY ETHEREUM
Next
9
Our goal today
10
Download blockchain, writing smart contracts, publish contract on blockchain, send message to
contracts.
Source: http://jorisbontje.github.io/sleth/#/ http://ethereum.gitbooks.io/frontier-guide/content/contract_coin.html
http://meteor-dapp-cosmo.meteor.com/
Cool!
1. Install Ethereum blockchain 2.writing smart contract
3.Publish contract on blockchain 4.Send message to contracts &
check the result
tokenInstance.getBalance.call(eth.accounts[1])
tokenInstance.sendToken.sendTransaction(et
h.accounts[1], 100, {from: eth.accounts[0]})
1. Install Ethereum blockchain
11
3 ways to install...
Source: http://jorisbontje.github.io/sleth/#/
1. Live Testnet chain https://stats.ethdev.com/
2. Private chain
3. Private chain with framework (Embark framework)
https://github.com/iurimatias/embark-framework
Cool!
1. Install Ethereum blockchain
12Source: http://jorisbontje.github.io/sleth/#/
1. Live Testnet chain we will install this chain. https://stats.ethdev.com/
Cool!
CPP
O △ ☓
1. Install Ethereum blockchain
13Source:
1.Live Testnet chain we will install this chain. https://stats.ethdev.com/
June, 2015
Go-Ethereum = Geth !
1. installation of geth
https://github.com/ethereum/go-ethereum/releases/tag/v0.9.20
2. geth account new
http://ethereum.gitbooks.io/frontier-guide/content/creating_accounts.html
3. Do mining & should wait until the Blocknumber on stats (roughly 4 ~6 hours )
https://stats.ethdev.com/
1. Install Ethereum blockchain
14
2.Private chain is private blockchain just for you. No network, your own blockchain.
Source:https://github.com/ethereum/go-ethereum/wiki/Setting-up-private-network-or-local-cluster
Currently Ethereum using blockchain,
You can run multiple chains locally to do this,
1. Each instance has separate data dir
2. Each instance runs on a different port ( both eth and rpc. )
3. The instances know about each other
You can run multiple chains locally
1st chain
// create dir for blockchain
$ mkdir /tmp/eth/60/01
// run private chain
$ geth –datadir=“/tmp/eth/60/01” –
verbosity 6 –port 30301 –rpcport 8101
console 2>> /tmp/eth/60/01.log
// mining start
$ admin.miner.start()
You can run multiple chains locally
2nd chain but for my env doesn’t work.
// create dir for blockchain
$ mkdir /tmp/eth/61/01
// run private chain
$ geth –datadir=“/tmp/eth/61/01” –
verbosity 6 –port 30302 –rpcport 8102
console 2>> /tmp/eth/61/01.log
// mining start
$ admin.miner.start()
1. Install Ethereum blockchain
15
3. Embark Framework for Ethereum DApps. https://iurimatias.github.io/embark-framework/
Source: https://iurimatias.github.io/embark-framework/
I feel
1. Easy to upload contracts you write to private blockchain
2. If you don’t know about How to use
3. Fast demo – Simple storage application using private chain is buildin demo.
$ npm install -g embark-framework grunt-cli
$ embark demo
$ cd embark_demo
$ embark blockchain
$ embark run
2. Write smart contract after $ geth console
16
1. Write Token contract you can publish your own token. After $ geth console
### coin contract from console
var tokenSource = 'contract token { mapping (address => uint) balances; function token() { balances[msg.sender]
= 10000; } function sendToken(address receiver, uint amount) returns(bool sufficient) { if
(balances[msg.sender] < amount) return false; balances[msg.sender] -= amount; balances[receiver] +=
amount; return true; } function getBalance(address account) returns(uint balance){ return
balances[account]; } }'
var tokenCompiled = eth.compile.solidity(tokenSource).token
var tokenAddress = eth.sendTransaction({data: tokenCompiled.code, from: eth.accounts[0], gas:1000000});
admin.miner.start()
admin.miner.stop()
eth.getCode(tokenAddress)
tokenContract = eth.contract(tokenCompiled.info.abiDefinition)
tokenInstance = tokenContract.at(tokenAddress);
> tokenInstance
{
address: '0xf95ff51f532bd6821b98f312e876e1e2213f3e36',
sendToken: [Function],
getBalance: [Function]
}
tokenInstance.getBalance.call(eth.accounts[0])
tokenInstance.sendToken.sendTransaction(eth.accounts[1], 100, {from: eth.accounts[0]})
admin.miner.start()
admin.miner.stop()
tokenInstance.getBalance.call(eth.accounts[0])
> tokenInstance.getBalance.call(eth.accounts[0])
'9900'
3.Publish contract
17
This phrase is uploading the contract onto blockchain.
### coin contract from console
var tokenSource = 'contract token { mapping (address => uint) balances; function token() { balances[msg.sender]
= 10000; } function sendToken(address receiver, uint amount) returns(bool sufficient) { if
(balances[msg.sender] < amount) return false; balances[msg.sender] -= amount; balances[receiver] +=
amount; return true; } function getBalance(address account) returns(uint balance){ return
balances[account]; } }'
var tokenCompiled = eth.compile.solidity(tokenSource).token
var tokenAddress = eth.sendTransaction({data: tokenCompiled.code, from:
eth.accounts[0], gas:1000000});
admin.miner.start()
admin.miner.stop()
eth.getCode(tokenAddress)
tokenContract = eth.contract(tokenCompiled.info.abiDefinition)
tokenInstance = tokenContract.at(tokenAddress);
> tokenInstance
{
address: '0xf95ff51f532bd6821b98f312e876e1e2213f3e36',
sendToken: [Function],
getBalance: [Function]
}
tokenInstance.getBalance.call(eth.accounts[0])
tokenInstance.sendToken.sendTransaction(eth.accounts[1], 100, {from: eth.accounts[0]})
admin.miner.start()
admin.miner.stop()
tokenInstance.getBalance.call(eth.accounts[0])
> tokenInstance.getBalance.call(eth.accounts[0])
'9900'
4.Send message to the contract and check the result
18
This phrase is sending message to the contract on blockchain.
### coin contract from console
var tokenSource = 'contract token { mapping (address => uint) balances; function token() { balances[msg.sender]
= 10000; } function sendToken(address receiver, uint amount) returns(bool sufficient) { if
(balances[msg.sender] < amount) return false; balances[msg.sender] -= amount; balances[receiver] +=
amount; return true; } function getBalance(address account) returns(uint balance){ return
balances[account]; } }'
var tokenCompiled = eth.compile.solidity(tokenSource).token
var tokenAddress = eth.sendTransaction({data: tokenCompiled.code, from: eth.accounts[0], gas:1000000});
admin.miner.start()
admin.miner.stop()
eth.getCode(tokenAddress)
tokenContract = eth.contract(tokenCompiled.info.abiDefinition)
tokenInstance = tokenContract.at(tokenAddress);
> tokenInstance
{
address: '0xf95ff51f532bd6821b98f312e876e1e2213f3e36',
sendToken: [Function],
getBalance: [Function]
}
tokenInstance.getBalance.call(eth.accounts[0])
tokenInstance.sendToken.sendTransaction(eth.accounts[1], 100, {from:
eth.accounts[0]})
admin.miner.start()
admin.miner.stop()
tokenInstance.getBalance.call(eth.accounts[0])
> tokenInstance.getBalance.call(eth.accounts[0])
'9900'
Miscellaneous
19
Ethereum frontier guide
Solidty online compiler
https://chriseth.github.io/cpp-ethereum/
Geth(go-ethereum)
https://github.com/ethereum/go-ethereum/releases/tag/v0.9.20
State of the DApps spreadsheet
https://docs.google.com/spreadsheets/d/1VdRMFENPzjL2V-vZhcc_aa5-
ysf243t5vXlxC2b054g/edit#gid=0
Ethereum forum
https://forum.ethereum.org/categories/services-and-decentralized-applications
Solidity presentation
https://www.youtube.com/watch?v=DIqGDNPO5YM
http://ethereum.gitbooks.io/frontier-guide/content/creating_accounts.html
20
Decentralization is just beginning.
We hope you start to be involved in!
Do you have interested in the DAppsMedia also ?
If you have, contract us from here!

More Related Content

What's hot

Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...Simplilearn
 
Ethereum introduction
Ethereum introductionEthereum introduction
Ethereum introductionkesavan N B
 
Bitcoin, Ethereum, Smart Contract & Blockchain
Bitcoin, Ethereum, Smart Contract & BlockchainBitcoin, Ethereum, Smart Contract & Blockchain
Bitcoin, Ethereum, Smart Contract & BlockchainJitendra Chittoda
 
The Blockchain and JavaScript
The Blockchain and JavaScriptThe Blockchain and JavaScript
The Blockchain and JavaScriptPortia Burton
 
Introduction to Ethereum
Introduction to EthereumIntroduction to Ethereum
Introduction to EthereumTerek Judi
 
Building Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart ContractBuilding Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart ContractVaideeswaran Sethuraman
 
BCHGraz - Meetup #8 - Intro & Ethereum
 BCHGraz - Meetup #8 - Intro & Ethereum BCHGraz - Meetup #8 - Intro & Ethereum
BCHGraz - Meetup #8 - Intro & EthereumBlockchainHub Graz
 
Blockchain, Ethereum and ConsenSys
Blockchain, Ethereum and ConsenSysBlockchain, Ethereum and ConsenSys
Blockchain, Ethereum and ConsenSysWithTheBest
 
Eclipsecon Europe: Blockchain, Ethereum and Business Applications
Eclipsecon Europe: Blockchain, Ethereum and Business ApplicationsEclipsecon Europe: Blockchain, Ethereum and Business Applications
Eclipsecon Europe: Blockchain, Ethereum and Business ApplicationsMatthias Zimmermann
 
Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)Tomoaki Sato
 
The Ethereum Experience
The Ethereum ExperienceThe Ethereum Experience
The Ethereum ExperienceEthereum
 
Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20Truong Nguyen
 
gething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang clientgething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang clientSathish VJ
 
Every thing bitcoin in baby language
Every thing bitcoin in baby languageEvery thing bitcoin in baby language
Every thing bitcoin in baby languageOssai Nduka
 
Bitcoin and Ethereum
Bitcoin and EthereumBitcoin and Ethereum
Bitcoin and EthereumJongseok Choi
 
Smart contractjp smartcontract_about
Smart contractjp smartcontract_aboutSmart contractjp smartcontract_about
Smart contractjp smartcontract_aboutTomoaki Sato
 
Blockchain Programming
Blockchain ProgrammingBlockchain Programming
Blockchain ProgrammingRhea Myers
 
Bitcoin in a Nutshell
Bitcoin in a NutshellBitcoin in a Nutshell
Bitcoin in a NutshellDaniel Chan
 
create your own cryptocurrency
create your own cryptocurrencycreate your own cryptocurrency
create your own cryptocurrencyBellaj Badr
 

What's hot (20)

Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
Ethereum Tutorial - Ethereum Explained | What is Ethereum? | Ethereum Explain...
 
Ethereum introduction
Ethereum introductionEthereum introduction
Ethereum introduction
 
Ethereum
EthereumEthereum
Ethereum
 
Bitcoin, Ethereum, Smart Contract & Blockchain
Bitcoin, Ethereum, Smart Contract & BlockchainBitcoin, Ethereum, Smart Contract & Blockchain
Bitcoin, Ethereum, Smart Contract & Blockchain
 
The Blockchain and JavaScript
The Blockchain and JavaScriptThe Blockchain and JavaScript
The Blockchain and JavaScript
 
Introduction to Ethereum
Introduction to EthereumIntroduction to Ethereum
Introduction to Ethereum
 
Building Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart ContractBuilding Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart Contract
 
BCHGraz - Meetup #8 - Intro & Ethereum
 BCHGraz - Meetup #8 - Intro & Ethereum BCHGraz - Meetup #8 - Intro & Ethereum
BCHGraz - Meetup #8 - Intro & Ethereum
 
Blockchain, Ethereum and ConsenSys
Blockchain, Ethereum and ConsenSysBlockchain, Ethereum and ConsenSys
Blockchain, Ethereum and ConsenSys
 
Eclipsecon Europe: Blockchain, Ethereum and Business Applications
Eclipsecon Europe: Blockchain, Ethereum and Business ApplicationsEclipsecon Europe: Blockchain, Ethereum and Business Applications
Eclipsecon Europe: Blockchain, Ethereum and Business Applications
 
Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)Ethereum Devcon1 Report (summary writing)
Ethereum Devcon1 Report (summary writing)
 
The Ethereum Experience
The Ethereum ExperienceThe Ethereum Experience
The Ethereum Experience
 
Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20Ethereum Blockchain with Smart contract and ERC20
Ethereum Blockchain with Smart contract and ERC20
 
gething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang clientgething started - ethereum & using the geth golang client
gething started - ethereum & using the geth golang client
 
Every thing bitcoin in baby language
Every thing bitcoin in baby languageEvery thing bitcoin in baby language
Every thing bitcoin in baby language
 
Bitcoin and Ethereum
Bitcoin and EthereumBitcoin and Ethereum
Bitcoin and Ethereum
 
Smart contractjp smartcontract_about
Smart contractjp smartcontract_aboutSmart contractjp smartcontract_about
Smart contractjp smartcontract_about
 
Blockchain Programming
Blockchain ProgrammingBlockchain Programming
Blockchain Programming
 
Bitcoin in a Nutshell
Bitcoin in a NutshellBitcoin in a Nutshell
Bitcoin in a Nutshell
 
create your own cryptocurrency
create your own cryptocurrencycreate your own cryptocurrency
create your own cryptocurrency
 

Viewers also liked

The Ethereum Geth Client
The Ethereum Geth ClientThe Ethereum Geth Client
The Ethereum Geth ClientArnold Pham
 
Technological Unemployment and the Robo-Economy
Technological Unemployment and the Robo-EconomyTechnological Unemployment and the Robo-Economy
Technological Unemployment and the Robo-EconomyMelanie Swan
 
Dapps for Web Developers Aberdeen Techmeetup
Dapps for Web Developers Aberdeen TechmeetupDapps for Web Developers Aberdeen Techmeetup
Dapps for Web Developers Aberdeen TechmeetupJames Littlejohn
 
日本のIT市場のトピックス
日本のIT市場のトピックス日本のIT市場のトピックス
日本のIT市場のトピックスHiroyasu NOHATA
 
Etherem ~ agvm
Etherem ~ agvmEtherem ~ agvm
Etherem ~ agvmgha sshee
 
Vision for a health blockchain
Vision for a health blockchainVision for a health blockchain
Vision for a health blockchainJames Littlejohn
 
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter..."Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...Khaled Ben Driss
 
Etherisc Versicherung neu erfinden
Etherisc Versicherung neu erfindenEtherisc Versicherung neu erfinden
Etherisc Versicherung neu erfindenStephan Karpischek
 
The Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: MixThe Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: Mixgavofyork
 
NodeJS Blockchain.info Wallet
NodeJS Blockchain.info WalletNodeJS Blockchain.info Wallet
NodeJS Blockchain.info WalletSjors Provoost
 
Learning Solidity
Learning SolidityLearning Solidity
Learning SolidityArnold Pham
 
Ingredients for creating dapps
Ingredients for creating dappsIngredients for creating dapps
Ingredients for creating dappsStefaan Ponnet
 
Chatbots et assistants virtuels : l'automatisation du poste de travail
Chatbots et assistants virtuels : l'automatisation du poste de travailChatbots et assistants virtuels : l'automatisation du poste de travail
Chatbots et assistants virtuels : l'automatisation du poste de travailH2 University
 
Ethereum Madrid - Blockchain for dummies
Ethereum Madrid - Blockchain for dummiesEthereum Madrid - Blockchain for dummies
Ethereum Madrid - Blockchain for dummiesEthereum Madrid
 
Ethereum Madrid - Cambio de paradigma en el sector energético
Ethereum Madrid - Cambio de paradigma en el sector energéticoEthereum Madrid - Cambio de paradigma en el sector energético
Ethereum Madrid - Cambio de paradigma en el sector energéticoEthereum Madrid
 

Viewers also liked (19)

The Ethereum Geth Client
The Ethereum Geth ClientThe Ethereum Geth Client
The Ethereum Geth Client
 
Technological Unemployment and the Robo-Economy
Technological Unemployment and the Robo-EconomyTechnological Unemployment and the Robo-Economy
Technological Unemployment and the Robo-Economy
 
Dapps for Web Developers Aberdeen Techmeetup
Dapps for Web Developers Aberdeen TechmeetupDapps for Web Developers Aberdeen Techmeetup
Dapps for Web Developers Aberdeen Techmeetup
 
日本のIT市場のトピックス
日本のIT市場のトピックス日本のIT市場のトピックス
日本のIT市場のトピックス
 
Ethereum @ descon 2016
Ethereum @ descon 2016Ethereum @ descon 2016
Ethereum @ descon 2016
 
Etherem ~ agvm
Etherem ~ agvmEtherem ~ agvm
Etherem ~ agvm
 
Vision for a health blockchain
Vision for a health blockchainVision for a health blockchain
Vision for a health blockchain
 
Introduction to Idea
Introduction to IdeaIntroduction to Idea
Introduction to Idea
 
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter..."Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
"Performance Analysis of In-Network Caching in Content-Centric Advanced Meter...
 
Solidity intro
Solidity introSolidity intro
Solidity intro
 
Etherisc Versicherung neu erfinden
Etherisc Versicherung neu erfindenEtherisc Versicherung neu erfinden
Etherisc Versicherung neu erfinden
 
The Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: MixThe Ethereum ÐApp IDE: Mix
The Ethereum ÐApp IDE: Mix
 
NodeJS Blockchain.info Wallet
NodeJS Blockchain.info WalletNodeJS Blockchain.info Wallet
NodeJS Blockchain.info Wallet
 
Learning Solidity
Learning SolidityLearning Solidity
Learning Solidity
 
Ingredients for creating dapps
Ingredients for creating dappsIngredients for creating dapps
Ingredients for creating dapps
 
V-Pesa
V-PesaV-Pesa
V-Pesa
 
Chatbots et assistants virtuels : l'automatisation du poste de travail
Chatbots et assistants virtuels : l'automatisation du poste de travailChatbots et assistants virtuels : l'automatisation du poste de travail
Chatbots et assistants virtuels : l'automatisation du poste de travail
 
Ethereum Madrid - Blockchain for dummies
Ethereum Madrid - Blockchain for dummiesEthereum Madrid - Blockchain for dummies
Ethereum Madrid - Blockchain for dummies
 
Ethereum Madrid - Cambio de paradigma en el sector energético
Ethereum Madrid - Cambio de paradigma en el sector energéticoEthereum Madrid - Cambio de paradigma en el sector energético
Ethereum Madrid - Cambio de paradigma en el sector energético
 

Similar to Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum

Blockchain, Ethereum and Business Applications
Blockchain, Ethereum and Business ApplicationsBlockchain, Ethereum and Business Applications
Blockchain, Ethereum and Business ApplicationsMatthias Zimmermann
 
Kriptovaluták, hashbányászat és okoscicák
Kriptovaluták, hashbányászat és okoscicákKriptovaluták, hashbányászat és okoscicák
Kriptovaluták, hashbányászat és okoscicákhackersuli
 
Blockchain School 2019 - Security of Smart Contracts.pdf
Blockchain School 2019 - Security of Smart Contracts.pdfBlockchain School 2019 - Security of Smart Contracts.pdf
Blockchain School 2019 - Security of Smart Contracts.pdfDavide Carboni
 
Build on Streakk Chain - Blockchain
Build on Streakk Chain - BlockchainBuild on Streakk Chain - Blockchain
Build on Streakk Chain - BlockchainEarn.World
 
Blockchain Chapter #4.pdf
Blockchain Chapter #4.pdfBlockchain Chapter #4.pdf
Blockchain Chapter #4.pdfssuser79c46d1
 
Ethereum Solidity Fundamentals
Ethereum Solidity FundamentalsEthereum Solidity Fundamentals
Ethereum Solidity FundamentalsEno Bassey
 
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018Svetlin Nakov
 
Blockchain for Developers
Blockchain for DevelopersBlockchain for Developers
Blockchain for DevelopersShimi Bandiel
 
Understanding blockchain
Understanding blockchainUnderstanding blockchain
Understanding blockchainPriyab Satoshi
 
EthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptxEthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptxWijdenBenothmen1
 
Ethereum Block Chain
Ethereum Block ChainEthereum Block Chain
Ethereum Block ChainSanatPandoh
 
Explain Ethereum smart contract hacking like i am a five
Explain Ethereum smart contract hacking like i am a fiveExplain Ethereum smart contract hacking like i am a five
Explain Ethereum smart contract hacking like i am a fiveZoltan Balazs
 
Zoltán Balázs - Ethereum Smart Contract Hacking Explained like I’m Five
Zoltán Balázs - Ethereum Smart Contract Hacking Explained like I’m FiveZoltán Balázs - Ethereum Smart Contract Hacking Explained like I’m Five
Zoltán Balázs - Ethereum Smart Contract Hacking Explained like I’m Fivehacktivity
 
Building a NFT Marketplace DApp
Building a NFT Marketplace DAppBuilding a NFT Marketplace DApp
Building a NFT Marketplace DAppThanh Nguyen
 
Building Java and Android apps on the blockchain
Building Java and Android apps on the blockchain Building Java and Android apps on the blockchain
Building Java and Android apps on the blockchain Conor Svensson
 

Similar to Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum (20)

Blockchain, Ethereum and Business Applications
Blockchain, Ethereum and Business ApplicationsBlockchain, Ethereum and Business Applications
Blockchain, Ethereum and Business Applications
 
Kriptovaluták, hashbányászat és okoscicák
Kriptovaluták, hashbányászat és okoscicákKriptovaluták, hashbányászat és okoscicák
Kriptovaluták, hashbányászat és okoscicák
 
Ethereum bxl
Ethereum bxlEthereum bxl
Ethereum bxl
 
Blockchain School 2019 - Security of Smart Contracts.pdf
Blockchain School 2019 - Security of Smart Contracts.pdfBlockchain School 2019 - Security of Smart Contracts.pdf
Blockchain School 2019 - Security of Smart Contracts.pdf
 
Build on Streakk Chain - Blockchain
Build on Streakk Chain - BlockchainBuild on Streakk Chain - Blockchain
Build on Streakk Chain - Blockchain
 
Blockchain Chapter #4.pdf
Blockchain Chapter #4.pdfBlockchain Chapter #4.pdf
Blockchain Chapter #4.pdf
 
Ethereum Solidity Fundamentals
Ethereum Solidity FundamentalsEthereum Solidity Fundamentals
Ethereum Solidity Fundamentals
 
Blockchain
BlockchainBlockchain
Blockchain
 
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
Multi-Signature Crypto-Wallets: Nakov at Blockchain Berlin 2018
 
Blockchain for Developers
Blockchain for DevelopersBlockchain for Developers
Blockchain for Developers
 
Understanding blockchain
Understanding blockchainUnderstanding blockchain
Understanding blockchain
 
EthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptxEthereumBlockchainMarch3 (1).pptx
EthereumBlockchainMarch3 (1).pptx
 
Ethereum Block Chain
Ethereum Block ChainEthereum Block Chain
Ethereum Block Chain
 
bitcoin_presentation
bitcoin_presentationbitcoin_presentation
bitcoin_presentation
 
BlockChain Public
BlockChain PublicBlockChain Public
BlockChain Public
 
Bitcoin
BitcoinBitcoin
Bitcoin
 
Explain Ethereum smart contract hacking like i am a five
Explain Ethereum smart contract hacking like i am a fiveExplain Ethereum smart contract hacking like i am a five
Explain Ethereum smart contract hacking like i am a five
 
Zoltán Balázs - Ethereum Smart Contract Hacking Explained like I’m Five
Zoltán Balázs - Ethereum Smart Contract Hacking Explained like I’m FiveZoltán Balázs - Ethereum Smart Contract Hacking Explained like I’m Five
Zoltán Balázs - Ethereum Smart Contract Hacking Explained like I’m Five
 
Building a NFT Marketplace DApp
Building a NFT Marketplace DAppBuilding a NFT Marketplace DApp
Building a NFT Marketplace DApp
 
Building Java and Android apps on the blockchain
Building Java and Android apps on the blockchain Building Java and Android apps on the blockchain
Building Java and Android apps on the blockchain
 

More from Tomoaki Sato

DAO, Starbase - 4th Blockchain research lab at Digital Hollywood University
DAO, Starbase - 4th Blockchain research lab at Digital Hollywood UniversityDAO, Starbase - 4th Blockchain research lab at Digital Hollywood University
DAO, Starbase - 4th Blockchain research lab at Digital Hollywood UniversityTomoaki Sato
 
Restribute ~ Wealth re-distirbution by blockchain hardfork ~
Restribute ~ Wealth re-distirbution by blockchain hardfork ~ Restribute ~ Wealth re-distirbution by blockchain hardfork ~
Restribute ~ Wealth re-distirbution by blockchain hardfork ~ Tomoaki Sato
 
デジタルハリウッド大学院 ブロックチェーン研究会第三回 2016年8月25日
デジタルハリウッド大学院 ブロックチェーン研究会第三回 2016年8月25日デジタルハリウッド大学院 ブロックチェーン研究会第三回 2016年8月25日
デジタルハリウッド大学院 ブロックチェーン研究会第三回 2016年8月25日Tomoaki Sato
 
約束としてのスマートコントラクト (Smart contract as a way of promise) 
約束としてのスマートコントラクト (Smart contract as a way of promise) 約束としてのスマートコントラクト (Smart contract as a way of promise) 
約束としてのスマートコントラクト (Smart contract as a way of promise) Tomoaki Sato
 
Localfacts smartcontractjp
Localfacts smartcontractjpLocalfacts smartcontractjp
Localfacts smartcontractjpTomoaki Sato
 
State Of Smart Contract Platforms from Smart Contract JP
State Of Smart Contract Platforms from Smart Contract JP State Of Smart Contract Platforms from Smart Contract JP
State Of Smart Contract Platforms from Smart Contract JP Tomoaki Sato
 
Smart Contractjp 1st section about
Smart Contractjp 1st section aboutSmart Contractjp 1st section about
Smart Contractjp 1st section aboutTomoaki Sato
 

More from Tomoaki Sato (7)

DAO, Starbase - 4th Blockchain research lab at Digital Hollywood University
DAO, Starbase - 4th Blockchain research lab at Digital Hollywood UniversityDAO, Starbase - 4th Blockchain research lab at Digital Hollywood University
DAO, Starbase - 4th Blockchain research lab at Digital Hollywood University
 
Restribute ~ Wealth re-distirbution by blockchain hardfork ~
Restribute ~ Wealth re-distirbution by blockchain hardfork ~ Restribute ~ Wealth re-distirbution by blockchain hardfork ~
Restribute ~ Wealth re-distirbution by blockchain hardfork ~
 
デジタルハリウッド大学院 ブロックチェーン研究会第三回 2016年8月25日
デジタルハリウッド大学院 ブロックチェーン研究会第三回 2016年8月25日デジタルハリウッド大学院 ブロックチェーン研究会第三回 2016年8月25日
デジタルハリウッド大学院 ブロックチェーン研究会第三回 2016年8月25日
 
約束としてのスマートコントラクト (Smart contract as a way of promise) 
約束としてのスマートコントラクト (Smart contract as a way of promise) 約束としてのスマートコントラクト (Smart contract as a way of promise) 
約束としてのスマートコントラクト (Smart contract as a way of promise) 
 
Localfacts smartcontractjp
Localfacts smartcontractjpLocalfacts smartcontractjp
Localfacts smartcontractjp
 
State Of Smart Contract Platforms from Smart Contract JP
State Of Smart Contract Platforms from Smart Contract JP State Of Smart Contract Platforms from Smart Contract JP
State Of Smart Contract Platforms from Smart Contract JP
 
Smart Contractjp 1st section about
Smart Contractjp 1st section aboutSmart Contractjp 1st section about
Smart Contractjp 1st section about
 

Recently uploaded

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Igalia
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhisoniya singh
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
Raspberry Pi 5: Challenges and Solutions in Bringing up an OpenGL/Vulkan Driv...
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | DelhiFULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
FULL ENJOY 🔝 8264348440 🔝 Call Girls in Diplomatic Enclave | Delhi
 

Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum

  • 1. Smart contracts on Ethereum Getting started DappsMedia Tomoaki Sato June 2015 Main source: https://github.com/ethereum/wiki/wiki/Ethereum-Development-Tutorial ~From blockchain installation to make tokenContract ~
  • 2. What are smart contracts on Ethereum blockchain? 1Source: https://github.com/ethereum/wiki/wiki/White-Paper Original idea derived from Nick Szabo’s paper in1997. http://szabo.best.vwh.net/smart_contracts_idea.html and going to be live by Stateful blockchain with Ethereum virtual machine
  • 3. What kind of application needs smart contracts ? 2Source: Source 1.Vending machine 2.Asset automated transfer system • Token Systems • Financial derivatives • Identity and Reputation Systems • Decentralized File Storage • Decentralized Autonomous Organizations • See also https://docs.google.com/spreads heets/u/1/d/1VdRMFENPzjL2V- vZhcc_aa5- ysf243t5vXlxC2b054g/edit After blockchain age
  • 4. Smart contract 4 purposes 3 Smart contract 1. Maintain a data store contract. 2. Forwarding contract which has access policy, and some conditions to send messages. 3. Ongoing contract such as escrow, crowdfunding. 4.Library type contract which provides functions to other contracts. Process objectives Ethereum contracts objectives Source: https://github.com/ethereum/wiki/wiki/Ethereum-Development-Tutorial
  • 5. 1.Maintain a data store contract 4 Most simple type can be used by Embark (more about the later) Source: http://jorisbontje.github.io/sleth/#/ # app/contracts/simple_storage.sol contract SimpleStorage { uint storedData; function set(uint x) { storedData = x * x * x; } function get() constant returns (uint retVal) { return storedData; } }
  • 6. 2.Forwarding contract 5 Sleth is the decentralized slot machine application using forwarding type smart contract. Currently I can not find the forwarding type contract which can be run on testnet. If you know please comment on. Source: https://github.com/ethereum/wiki/wiki/Ethereum-Development-Tutorial When Bob wants to finalize the bet, the following steps happen: 1. A transaction is sent, triggering a message from Bob's EOA to Bob's forwarding contract. 2. Bob's forwarding contract sends the hash of the message and the Lamport signature to a contract which functions as a Lamport signature verification library. 3. The Lamport signature verification library sees that Bob wants a SHA256-based Lamport sig, so it calls the SHA256 library many times as needed to verify the signature. 4. Once the Lamport signature verification library returns 1, signifying that the signature has been verified, it sends a message to the contract representing the bet. 5. The bet contract checks the contract providing the San Francisco temperature to see what the temperature is.
  • 7. 3.Ongoing contract 6Source: https://github.com/WeiFund/WeiFund/blob/master/WeiFund.sol Most smart contracts are ongoing type contracts, such as crowdfunding is ongoing contract. // WeiFund System // Start, donate, payout and refund crowdfunding campaigns // @authors: // Nick Dodson <thenickdodson@gmail.com> // If goal is not reached and campaign is expired, contributers can get the refunded individually // If goal is reached by alloted time, contributions can still be made contract WeiFundConfig { function onContribute(uint cid, address addr, uint amount){} function onRefund(uint cid, address addr, uint amount){} function onPayout(uint cid, uint amount){} } contract WeiFund { struct User { uint numCampaigns; mapping(uint => uint) campaigns; } struct Funder { address addr; uint amount; } ...
  • 8. 4. Library contract 7Source: https://github.com/ethereum/wiki/wiki/Ethereum-Development-Tutorial Smart contract which provides utility functions. In the case below, Lamport sig verifier contract is Library type contracts. The contract will provide a set of function
  • 9. Structuring every type of smart contract 8 You can make structure by combining different contracts Source:https://github.com/ethereum/wiki/wiki/Ethereum-Development-Tutorial
  • 11. Our goal today 10 Download blockchain, writing smart contracts, publish contract on blockchain, send message to contracts. Source: http://jorisbontje.github.io/sleth/#/ http://ethereum.gitbooks.io/frontier-guide/content/contract_coin.html http://meteor-dapp-cosmo.meteor.com/ Cool! 1. Install Ethereum blockchain 2.writing smart contract 3.Publish contract on blockchain 4.Send message to contracts & check the result tokenInstance.getBalance.call(eth.accounts[1]) tokenInstance.sendToken.sendTransaction(et h.accounts[1], 100, {from: eth.accounts[0]})
  • 12. 1. Install Ethereum blockchain 11 3 ways to install... Source: http://jorisbontje.github.io/sleth/#/ 1. Live Testnet chain https://stats.ethdev.com/ 2. Private chain 3. Private chain with framework (Embark framework) https://github.com/iurimatias/embark-framework Cool!
  • 13. 1. Install Ethereum blockchain 12Source: http://jorisbontje.github.io/sleth/#/ 1. Live Testnet chain we will install this chain. https://stats.ethdev.com/ Cool! CPP O △ ☓
  • 14. 1. Install Ethereum blockchain 13Source: 1.Live Testnet chain we will install this chain. https://stats.ethdev.com/ June, 2015 Go-Ethereum = Geth ! 1. installation of geth https://github.com/ethereum/go-ethereum/releases/tag/v0.9.20 2. geth account new http://ethereum.gitbooks.io/frontier-guide/content/creating_accounts.html 3. Do mining & should wait until the Blocknumber on stats (roughly 4 ~6 hours ) https://stats.ethdev.com/
  • 15. 1. Install Ethereum blockchain 14 2.Private chain is private blockchain just for you. No network, your own blockchain. Source:https://github.com/ethereum/go-ethereum/wiki/Setting-up-private-network-or-local-cluster Currently Ethereum using blockchain, You can run multiple chains locally to do this, 1. Each instance has separate data dir 2. Each instance runs on a different port ( both eth and rpc. ) 3. The instances know about each other You can run multiple chains locally 1st chain // create dir for blockchain $ mkdir /tmp/eth/60/01 // run private chain $ geth –datadir=“/tmp/eth/60/01” – verbosity 6 –port 30301 –rpcport 8101 console 2>> /tmp/eth/60/01.log // mining start $ admin.miner.start() You can run multiple chains locally 2nd chain but for my env doesn’t work. // create dir for blockchain $ mkdir /tmp/eth/61/01 // run private chain $ geth –datadir=“/tmp/eth/61/01” – verbosity 6 –port 30302 –rpcport 8102 console 2>> /tmp/eth/61/01.log // mining start $ admin.miner.start()
  • 16. 1. Install Ethereum blockchain 15 3. Embark Framework for Ethereum DApps. https://iurimatias.github.io/embark-framework/ Source: https://iurimatias.github.io/embark-framework/ I feel 1. Easy to upload contracts you write to private blockchain 2. If you don’t know about How to use 3. Fast demo – Simple storage application using private chain is buildin demo. $ npm install -g embark-framework grunt-cli $ embark demo $ cd embark_demo $ embark blockchain $ embark run
  • 17. 2. Write smart contract after $ geth console 16 1. Write Token contract you can publish your own token. After $ geth console ### coin contract from console var tokenSource = 'contract token { mapping (address => uint) balances; function token() { balances[msg.sender] = 10000; } function sendToken(address receiver, uint amount) returns(bool sufficient) { if (balances[msg.sender] < amount) return false; balances[msg.sender] -= amount; balances[receiver] += amount; return true; } function getBalance(address account) returns(uint balance){ return balances[account]; } }' var tokenCompiled = eth.compile.solidity(tokenSource).token var tokenAddress = eth.sendTransaction({data: tokenCompiled.code, from: eth.accounts[0], gas:1000000}); admin.miner.start() admin.miner.stop() eth.getCode(tokenAddress) tokenContract = eth.contract(tokenCompiled.info.abiDefinition) tokenInstance = tokenContract.at(tokenAddress); > tokenInstance { address: '0xf95ff51f532bd6821b98f312e876e1e2213f3e36', sendToken: [Function], getBalance: [Function] } tokenInstance.getBalance.call(eth.accounts[0]) tokenInstance.sendToken.sendTransaction(eth.accounts[1], 100, {from: eth.accounts[0]}) admin.miner.start() admin.miner.stop() tokenInstance.getBalance.call(eth.accounts[0]) > tokenInstance.getBalance.call(eth.accounts[0]) '9900'
  • 18. 3.Publish contract 17 This phrase is uploading the contract onto blockchain. ### coin contract from console var tokenSource = 'contract token { mapping (address => uint) balances; function token() { balances[msg.sender] = 10000; } function sendToken(address receiver, uint amount) returns(bool sufficient) { if (balances[msg.sender] < amount) return false; balances[msg.sender] -= amount; balances[receiver] += amount; return true; } function getBalance(address account) returns(uint balance){ return balances[account]; } }' var tokenCompiled = eth.compile.solidity(tokenSource).token var tokenAddress = eth.sendTransaction({data: tokenCompiled.code, from: eth.accounts[0], gas:1000000}); admin.miner.start() admin.miner.stop() eth.getCode(tokenAddress) tokenContract = eth.contract(tokenCompiled.info.abiDefinition) tokenInstance = tokenContract.at(tokenAddress); > tokenInstance { address: '0xf95ff51f532bd6821b98f312e876e1e2213f3e36', sendToken: [Function], getBalance: [Function] } tokenInstance.getBalance.call(eth.accounts[0]) tokenInstance.sendToken.sendTransaction(eth.accounts[1], 100, {from: eth.accounts[0]}) admin.miner.start() admin.miner.stop() tokenInstance.getBalance.call(eth.accounts[0]) > tokenInstance.getBalance.call(eth.accounts[0]) '9900'
  • 19. 4.Send message to the contract and check the result 18 This phrase is sending message to the contract on blockchain. ### coin contract from console var tokenSource = 'contract token { mapping (address => uint) balances; function token() { balances[msg.sender] = 10000; } function sendToken(address receiver, uint amount) returns(bool sufficient) { if (balances[msg.sender] < amount) return false; balances[msg.sender] -= amount; balances[receiver] += amount; return true; } function getBalance(address account) returns(uint balance){ return balances[account]; } }' var tokenCompiled = eth.compile.solidity(tokenSource).token var tokenAddress = eth.sendTransaction({data: tokenCompiled.code, from: eth.accounts[0], gas:1000000}); admin.miner.start() admin.miner.stop() eth.getCode(tokenAddress) tokenContract = eth.contract(tokenCompiled.info.abiDefinition) tokenInstance = tokenContract.at(tokenAddress); > tokenInstance { address: '0xf95ff51f532bd6821b98f312e876e1e2213f3e36', sendToken: [Function], getBalance: [Function] } tokenInstance.getBalance.call(eth.accounts[0]) tokenInstance.sendToken.sendTransaction(eth.accounts[1], 100, {from: eth.accounts[0]}) admin.miner.start() admin.miner.stop() tokenInstance.getBalance.call(eth.accounts[0]) > tokenInstance.getBalance.call(eth.accounts[0]) '9900'
  • 20. Miscellaneous 19 Ethereum frontier guide Solidty online compiler https://chriseth.github.io/cpp-ethereum/ Geth(go-ethereum) https://github.com/ethereum/go-ethereum/releases/tag/v0.9.20 State of the DApps spreadsheet https://docs.google.com/spreadsheets/d/1VdRMFENPzjL2V-vZhcc_aa5- ysf243t5vXlxC2b054g/edit#gid=0 Ethereum forum https://forum.ethereum.org/categories/services-and-decentralized-applications Solidity presentation https://www.youtube.com/watch?v=DIqGDNPO5YM http://ethereum.gitbooks.io/frontier-guide/content/creating_accounts.html
  • 21. 20 Decentralization is just beginning. We hope you start to be involved in! Do you have interested in the DAppsMedia also ? If you have, contract us from here!