SlideShare a Scribd company logo
Blockchain Coding Dojo
Ethereum Smart Contract with Solidity & web3.JS
First Up:
● The Who / The Why / The How / The What
● Short Presentation
○ Example we’re going to build
○ Setup & Tools
○ Solidity crash course
○ Web3.js crash course
● Q & A
Welcome To The Dojo!
● Didi
● Mario
The Who
● Get Programmers more involved in Blockchain technology
○ Get a feeling for what creating DApps is all about
○ Get to know the tools & ecosystem
○ Share experiences & learn
The Why
● Coding Dojo!
○ Split up in N % (3|4) groups
■ (groups of 3 or 4)
○ Driver/Navigator Pair Programming (switch every ~8 Minutes - don’t
hug the keyboard!)
■ Rest of the group contributes via discussion
○ Didi & Mario are available for help (as far as we can (not far! :D))
○ Start Coding!
■ An example including a smart contract and a UI for using it
○ Victory!
■ Deploy the contract to the testchain
■ (If you’re done and still motivated, feel free to experiment with
/ expand the example!)
The How
The What
Winner-Takes-All Crowdfunding on the Ethereum
Blockchain!
Example: Winner-Takes-All Crowdfunding
Basically:
A Crowdfunding System, where people can submit their Projects until a
Deadline, with an entry fee to avoid spam.
After this Deadline, people can “vote” for projects using Ether until a second
Deadline.
After the second Deadline, the Contract can be finished and the project with
the most “votes” (i.e. Ether) wins the WHOLE pot (all entry fees + all pledged
Ether).
Winner-Takes-All Crowdfunding - Tasks
● Create contract with proposal date, campaign date in the future and
minimum entry fee
● People can enter projects (with an initial money transfer of X ether, so
there's no spam)
○ until proposal date
● Now, after proposal date, other people can "vote" with ether for the
projects
● When the target date is here and the contract gets finished, ALL the money
goes to the project with the highest votes (most money contributed)
○ and contract is closed thereafter
Winner-Takes-All Crowdfunding - “Layout”
Setup & Tools
● Repository:
○ https://github.com/zupzup/blockchainhub-solidity-dojo
● Includes:
○ app.js - the UI JavaScript source
○ contract.sol - the smart contract source
○ contract.js - contract in one-line-form for web3.js
○ index.html - the HTML for the UI
○ js/ - static js
○ css/ - static css
○ LICENSE - the license (duh!)
○ README.md - setup & task list
Setup & Tools
● Docker
○ https://www.docker.com/
● Solidity (Solc)
○ https://solidity.readthedocs.io/en/develop/#
○ https://ethereum.github.io/browser-solidity
● testRPC
○ https://github.com/ethereumjs/testrpc
● Web3.JS
○ https://github.com/ethereum/web3.js
○ There are some high-level frameworks as well
■ https://truffle.readthedocs.io/en/latest/
■ https://github.com/iurimatias/embark-framework
■ http://populus.readthedocs.io/en/latest/
■ ...
Setup & Tools
● Bothersome to set up locally, so we’ll use Docker
● TestRPC (our local blockchain, which auto-mines)
○ docker pull harshjv/testrpc
○ docker run -d -p 8545:8545 harshjv/testrpc
● Building (compile and make ready to use with web3.js)
○ docker pull mzupzup/soliditybuilder
○ docker run -v /path/to/this/folder:/sol mzupzup/soliditybuilder
○ OR (on Linux + macOS) with file-watcher
■ docker pull mzupzup/soliditywatcher
■ docker run -v /path/to/this/folder:/sol mzupzup/soliditywatcher
Setup & Tools
● Once testRPC and the build-container are running
○ Open index.html and see what’s what
○ Explore contract.sol and app.js
○ Get to work! :)
● Documentation:
○ Solidity
■ http://solidity.readthedocs.io/en/develop/
○ Web3.JS
■ https://github.com/ethereum/wiki/wiki/JavaScript-API
○ Async.js
■ http://caolan.github.io/async/docs.html
○ jQuery / HTML / CSS / JavaScript
■ https://duckduckgo.com/?q=jquery ;)
Solidity
● High-level language for smart contracts
○ Syntax similar to JavaScript
○ Statically typed, Inheritance, Libraries can be imported
● https://ethereum.github.io/browser-solidity
● Docs:http://solidity.readthedocs.io/en/develop/index.html
● We will use 0.4.6 (0.4.10 now, moves VERY fast)
● Still very much in development, so some random things
just don’t work (yet)
○ http://solidity.readthedocs.io/en/develop/frequently-asked-questions.
html
Solidity - Smart Contracts Basics
● Contract is basically your “backend application”
○ Running on the Blockchain
● Smart Contracts need Gas (i.e.: Money) to run
○ No real money on our testRPC setup of course
○ You can estimate the gas cost via web3 / browser solidity
○ Only state-changing operations consume Gas
■ Just asking for a variable doesn’t
○ Unused Gas is refunded
■ E.g.: you send a transaction and add 10000 Gas.
● The transaction only needs 5000, so you get 5000 back
immediately.
○ Incentive to leave a minimal footprint
Solidity - Structure
Solidity - Types
● Integers
○ uint8 - uint256
○ int8 - int256
● Strings
● Address
○ .balance
○ .send()
● Booleans
● ...
Solidity - Data Structures
● Array (fixed & dynamic)
○ Mostly as one would expect (.length, array[0...N])
● Mapping (similar to hashmap)
○ Can’t iterate over!
● Struct
Solidity - Functions
Solidity - Control Flow
Solidity - Events
Used for debugging only (logs to the blockchain)
Solidity - Special Variables
● Msg.value - value of the transaction
● Msg.sender - address of the transaction’s sender
● http://solidity.readthedocs.io/en/develop/units-and-globa
l-variables.html#block-and-transaction-properties
Solidity - Throw
Reverts transfer, returns “error”
Solidity - Example Contracts
http://solidity.readthedocs.io/en/develop/solidity-by-exampl
e.html
Remember, maybe we can’t use ALL new features of 0.4.10,
because we use the 0.4.6 compiler.
Web3 - the Ethereum JavaScript API
● https://github.com/ethereum/web3.js
● Used for:
○ Connecting to the Blockchain
○ Compiling contracts
○ Instantiating Contracts
○ Calling methods on contracts
○ Retrieve public values from contracts
○ Send Transactions
○ Convert to/from Wei
● Basically a full interface for the Ethereum Blockchain
○ Docs: https://github.com/ethereum/wiki/wiki/JavaScript-API
● Addresses of available accounts:
○ web3.eth.accounts
● Get Balance for an account in Ether:
○ web3.fromWei(web3.toDecimal(web3.eth.getBalance(web3.eth.accounts[0])
), ‘ether’)
● Get a “public” attribute of the contract:
○ contractInstance.{publicAttribute}(function(err, data) { ..callback
function.. })
● Sending a simple transaction:
○ contractInstance.{payableFunction}(function params.., {
from: fromAddress,
value: valueToSendInWei,
gas: gasCostOfTransaction
}, function(err, data) { ..callback function.. })
Web3 - Examples (just to get a feeling for the API)
● Debugging (very important!)
○ Browser Dev Tools
○ Solidity Events
■ Can listen to them in web3.js
■ https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-all
events
■ Logs all events within the contract
Web3
Questions?
These Slides: https://goo.gl/Msofql
https://github.com/zupzup/blockchainhub-solidit
y-dojo
Let’s Roll!

More Related Content

PPTX
Solidity Simple Tutorial EN
PPTX
Solidity
PDF
Ethereum Contracts - Coinfest 2015
PDF
Smart contract and Solidity
PDF
Smart contracts in Solidity
PPTX
Hands on with Smart Contracts session #3
PPTX
Hello world contract
PPTX
Hands on with smart contracts
Solidity Simple Tutorial EN
Solidity
Ethereum Contracts - Coinfest 2015
Smart contract and Solidity
Smart contracts in Solidity
Hands on with Smart Contracts session #3
Hello world contract
Hands on with smart contracts

What's hot (20)

PPTX
Blockchain and smart contracts day 2
PDF
Libbitcoin slides
PPTX
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
PPTX
Codable routing
PPTX
Accessing decentralized finance on Ethereum blockchain
PDF
Meteor and Bitcoin (Lightning Talk)
PDF
How to be a smart contract engineer
PDF
“Create your own cryptocurrency in an hour” - Sandip Pandey
PPTX
Smart Contracts with Solidity hands-on training session
PPTX
Dex and Uniswap
PPTX
Smart Contract programming 101 with Solidity #PizzaHackathon
PPT
PDF
ERC20 Token Contract
PPTX
Solidity Security and Best Coding Practices
PPTX
Oracles
PPTX
Blockchain and Smart Contracts
DOCX
Oop lab report
PDF
"Programming Smart Contracts on Ethereum" by Anatoly Ressin from AssistUnion ...
PDF
PDF
Js interpreter interpreted
Blockchain and smart contracts day 2
Libbitcoin slides
Hands on with smart contracts 2. Presentation for the Blockchain Applications...
Codable routing
Accessing decentralized finance on Ethereum blockchain
Meteor and Bitcoin (Lightning Talk)
How to be a smart contract engineer
“Create your own cryptocurrency in an hour” - Sandip Pandey
Smart Contracts with Solidity hands-on training session
Dex and Uniswap
Smart Contract programming 101 with Solidity #PizzaHackathon
ERC20 Token Contract
Solidity Security and Best Coding Practices
Oracles
Blockchain and Smart Contracts
Oop lab report
"Programming Smart Contracts on Ethereum" by Anatoly Ressin from AssistUnion ...
Js interpreter interpreted
Ad

Similar to Blockchain Coding Dojo - BlockchainHub Graz (20)

PDF
Smart contracts using web3.js
PDF
Javascript toolset for Ethereum Smart Contract development
PDF
The JavaScript toolset for development on Ethereum
PPTX
The Ethereum Blockchain - Introduction to Smart Contracts and Decentralized A...
PPTX
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
DOCX
PPTX
Web3 - Solidity - 101.pptx
PDF
DevEx in Ethereum - a look at the developer stack
PDF
Introduction to Ethereum Smart Contracts
PDF
Blockchain Programming
PDF
Web3-Guide.pdf
ODP
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
PPTX
The Foundation of Smart Contract Development on Ethereum
PPTX
PPTX
Introduction to Ethereum
PPTX
Blockchain for Developers
PDF
Part 4: Understanding the working of Smart Contracts
PDF
Ivy Block - technicals.pdf
PDF
Handson Smart Contract Development With Solidity And Ethereum From Fundamenta...
PDF
Developing Blockchain Applications
Smart contracts using web3.js
Javascript toolset for Ethereum Smart Contract development
The JavaScript toolset for development on Ethereum
The Ethereum Blockchain - Introduction to Smart Contracts and Decentralized A...
Dappsmedia smartcontract _write_smartcontracts_on_console_ethereum
Web3 - Solidity - 101.pptx
DevEx in Ethereum - a look at the developer stack
Introduction to Ethereum Smart Contracts
Blockchain Programming
Web3-Guide.pdf
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
The Foundation of Smart Contract Development on Ethereum
Introduction to Ethereum
Blockchain for Developers
Part 4: Understanding the working of Smart Contracts
Ivy Block - technicals.pdf
Handson Smart Contract Development With Solidity And Ethereum From Fundamenta...
Developing Blockchain Applications
Ad

More from BlockchainHub Graz (20)

PDF
BlockchainHub Graz Meetup #27 - Krypto-Assets & Steuern - Natalie Enzinger
PPTX
BlockchainHub Graz Meetup #25 - ELASTOS - Semir Ramovic
PDF
BlockchainHub Graz Meetup #24 - Self-Sovereign Identity - Andreas Abraham
PDF
BlockchainHub Graz Meetup #23 - State Channels - Ralph Pichler
PDF
BlockchainHub Graz Meetup #22 - Atomic Swaps - Johannes Zweng
PDF
BCHGraz - Meetup #16 - Blockchain Real Life Usecases - Dr. Peter Teufl
PDF
BCHGraz - Meetup #15 - Blockchain in Real Estate - Walter Strametz
PDF
BCHGraz - Meetup #14 - Seratio Token - Prof. Olinga Ta'eed
PDF
BCHGraz - Meetup #12 - ICO Rechtliche Grundlagen - Oliver Völkel
PDF
BCHGraz - Meetup #12 - ICO Basics
PDF
BCHGraz - Meetup #11 - Bitsquare DAO by Manfred Karrer
PDF
BCHGraz - Meetup #10 - DASH (digital cash) by Valentin Kalinov
PDF
BCHGraz - Meetup #9 - Monero by Justin Ehrenhofer
PDF
BCHGraz - Meetup #8 - Intro & Ethereum
PDF
BCHGraz - Meetup #7 - Intro
PDF
Ripple - the good, the bad and the ugly
PPTX
BCHGraz - NEM Blockchain Tech - Intro
PPTX
BCHGraz - Apostille - NEM Blockchain Tech
PDF
IOTA Presentation - BlockchainHub Graz Meetup #5
PDF
RSK (Rootstock) - Smarter Bitcoin
BlockchainHub Graz Meetup #27 - Krypto-Assets & Steuern - Natalie Enzinger
BlockchainHub Graz Meetup #25 - ELASTOS - Semir Ramovic
BlockchainHub Graz Meetup #24 - Self-Sovereign Identity - Andreas Abraham
BlockchainHub Graz Meetup #23 - State Channels - Ralph Pichler
BlockchainHub Graz Meetup #22 - Atomic Swaps - Johannes Zweng
BCHGraz - Meetup #16 - Blockchain Real Life Usecases - Dr. Peter Teufl
BCHGraz - Meetup #15 - Blockchain in Real Estate - Walter Strametz
BCHGraz - Meetup #14 - Seratio Token - Prof. Olinga Ta'eed
BCHGraz - Meetup #12 - ICO Rechtliche Grundlagen - Oliver Völkel
BCHGraz - Meetup #12 - ICO Basics
BCHGraz - Meetup #11 - Bitsquare DAO by Manfred Karrer
BCHGraz - Meetup #10 - DASH (digital cash) by Valentin Kalinov
BCHGraz - Meetup #9 - Monero by Justin Ehrenhofer
BCHGraz - Meetup #8 - Intro & Ethereum
BCHGraz - Meetup #7 - Intro
Ripple - the good, the bad and the ugly
BCHGraz - NEM Blockchain Tech - Intro
BCHGraz - Apostille - NEM Blockchain Tech
IOTA Presentation - BlockchainHub Graz Meetup #5
RSK (Rootstock) - Smarter Bitcoin

Recently uploaded (20)

PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PDF
Spectral efficient network and resource selection model in 5G networks
PPT
Teaching material agriculture food technology
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PPTX
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
PDF
NewMind AI Monthly Chronicles - July 2025
PDF
Diabetes mellitus diagnosis method based random forest with bat algorithm
PDF
Encapsulation theory and applications.pdf
PDF
CIFDAQ's Market Insight: SEC Turns Pro Crypto
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Reach Out and Touch Someone: Haptics and Empathic Computing
PDF
Approach and Philosophy of On baking technology
PDF
Electronic commerce courselecture one. Pdf
Dropbox Q2 2025 Financial Results & Investor Presentation
Detection-First SIEM: Rule Types, Dashboards, and Threat-Informed Strategy
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
Spectral efficient network and resource selection model in 5G networks
Teaching material agriculture food technology
NewMind AI Weekly Chronicles - August'25 Week I
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Architecting across the Boundaries of two Complex Domains - Healthcare & Tech...
PA Analog/Digital System: The Backbone of Modern Surveillance and Communication
NewMind AI Monthly Chronicles - July 2025
Diabetes mellitus diagnosis method based random forest with bat algorithm
Encapsulation theory and applications.pdf
CIFDAQ's Market Insight: SEC Turns Pro Crypto
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
The AUB Centre for AI in Media Proposal.docx
Machine learning based COVID-19 study performance prediction
Reach Out and Touch Someone: Haptics and Empathic Computing
Approach and Philosophy of On baking technology
Electronic commerce courselecture one. Pdf

Blockchain Coding Dojo - BlockchainHub Graz

  • 1. Blockchain Coding Dojo Ethereum Smart Contract with Solidity & web3.JS
  • 2. First Up: ● The Who / The Why / The How / The What ● Short Presentation ○ Example we’re going to build ○ Setup & Tools ○ Solidity crash course ○ Web3.js crash course ● Q & A Welcome To The Dojo!
  • 4. ● Get Programmers more involved in Blockchain technology ○ Get a feeling for what creating DApps is all about ○ Get to know the tools & ecosystem ○ Share experiences & learn The Why
  • 5. ● Coding Dojo! ○ Split up in N % (3|4) groups ■ (groups of 3 or 4) ○ Driver/Navigator Pair Programming (switch every ~8 Minutes - don’t hug the keyboard!) ■ Rest of the group contributes via discussion ○ Didi & Mario are available for help (as far as we can (not far! :D)) ○ Start Coding! ■ An example including a smart contract and a UI for using it ○ Victory! ■ Deploy the contract to the testchain ■ (If you’re done and still motivated, feel free to experiment with / expand the example!) The How
  • 6. The What Winner-Takes-All Crowdfunding on the Ethereum Blockchain!
  • 7. Example: Winner-Takes-All Crowdfunding Basically: A Crowdfunding System, where people can submit their Projects until a Deadline, with an entry fee to avoid spam. After this Deadline, people can “vote” for projects using Ether until a second Deadline. After the second Deadline, the Contract can be finished and the project with the most “votes” (i.e. Ether) wins the WHOLE pot (all entry fees + all pledged Ether).
  • 8. Winner-Takes-All Crowdfunding - Tasks ● Create contract with proposal date, campaign date in the future and minimum entry fee ● People can enter projects (with an initial money transfer of X ether, so there's no spam) ○ until proposal date ● Now, after proposal date, other people can "vote" with ether for the projects ● When the target date is here and the contract gets finished, ALL the money goes to the project with the highest votes (most money contributed) ○ and contract is closed thereafter
  • 10. Setup & Tools ● Repository: ○ https://github.com/zupzup/blockchainhub-solidity-dojo ● Includes: ○ app.js - the UI JavaScript source ○ contract.sol - the smart contract source ○ contract.js - contract in one-line-form for web3.js ○ index.html - the HTML for the UI ○ js/ - static js ○ css/ - static css ○ LICENSE - the license (duh!) ○ README.md - setup & task list
  • 11. Setup & Tools ● Docker ○ https://www.docker.com/ ● Solidity (Solc) ○ https://solidity.readthedocs.io/en/develop/# ○ https://ethereum.github.io/browser-solidity ● testRPC ○ https://github.com/ethereumjs/testrpc ● Web3.JS ○ https://github.com/ethereum/web3.js ○ There are some high-level frameworks as well ■ https://truffle.readthedocs.io/en/latest/ ■ https://github.com/iurimatias/embark-framework ■ http://populus.readthedocs.io/en/latest/ ■ ...
  • 12. Setup & Tools ● Bothersome to set up locally, so we’ll use Docker ● TestRPC (our local blockchain, which auto-mines) ○ docker pull harshjv/testrpc ○ docker run -d -p 8545:8545 harshjv/testrpc ● Building (compile and make ready to use with web3.js) ○ docker pull mzupzup/soliditybuilder ○ docker run -v /path/to/this/folder:/sol mzupzup/soliditybuilder ○ OR (on Linux + macOS) with file-watcher ■ docker pull mzupzup/soliditywatcher ■ docker run -v /path/to/this/folder:/sol mzupzup/soliditywatcher
  • 13. Setup & Tools ● Once testRPC and the build-container are running ○ Open index.html and see what’s what ○ Explore contract.sol and app.js ○ Get to work! :) ● Documentation: ○ Solidity ■ http://solidity.readthedocs.io/en/develop/ ○ Web3.JS ■ https://github.com/ethereum/wiki/wiki/JavaScript-API ○ Async.js ■ http://caolan.github.io/async/docs.html ○ jQuery / HTML / CSS / JavaScript ■ https://duckduckgo.com/?q=jquery ;)
  • 14. Solidity ● High-level language for smart contracts ○ Syntax similar to JavaScript ○ Statically typed, Inheritance, Libraries can be imported ● https://ethereum.github.io/browser-solidity ● Docs:http://solidity.readthedocs.io/en/develop/index.html ● We will use 0.4.6 (0.4.10 now, moves VERY fast) ● Still very much in development, so some random things just don’t work (yet) ○ http://solidity.readthedocs.io/en/develop/frequently-asked-questions. html
  • 15. Solidity - Smart Contracts Basics ● Contract is basically your “backend application” ○ Running on the Blockchain ● Smart Contracts need Gas (i.e.: Money) to run ○ No real money on our testRPC setup of course ○ You can estimate the gas cost via web3 / browser solidity ○ Only state-changing operations consume Gas ■ Just asking for a variable doesn’t ○ Unused Gas is refunded ■ E.g.: you send a transaction and add 10000 Gas. ● The transaction only needs 5000, so you get 5000 back immediately. ○ Incentive to leave a minimal footprint
  • 17. Solidity - Types ● Integers ○ uint8 - uint256 ○ int8 - int256 ● Strings ● Address ○ .balance ○ .send() ● Booleans ● ...
  • 18. Solidity - Data Structures ● Array (fixed & dynamic) ○ Mostly as one would expect (.length, array[0...N]) ● Mapping (similar to hashmap) ○ Can’t iterate over! ● Struct
  • 21. Solidity - Events Used for debugging only (logs to the blockchain)
  • 22. Solidity - Special Variables ● Msg.value - value of the transaction ● Msg.sender - address of the transaction’s sender ● http://solidity.readthedocs.io/en/develop/units-and-globa l-variables.html#block-and-transaction-properties
  • 23. Solidity - Throw Reverts transfer, returns “error”
  • 24. Solidity - Example Contracts http://solidity.readthedocs.io/en/develop/solidity-by-exampl e.html Remember, maybe we can’t use ALL new features of 0.4.10, because we use the 0.4.6 compiler.
  • 25. Web3 - the Ethereum JavaScript API ● https://github.com/ethereum/web3.js ● Used for: ○ Connecting to the Blockchain ○ Compiling contracts ○ Instantiating Contracts ○ Calling methods on contracts ○ Retrieve public values from contracts ○ Send Transactions ○ Convert to/from Wei ● Basically a full interface for the Ethereum Blockchain ○ Docs: https://github.com/ethereum/wiki/wiki/JavaScript-API
  • 26. ● Addresses of available accounts: ○ web3.eth.accounts ● Get Balance for an account in Ether: ○ web3.fromWei(web3.toDecimal(web3.eth.getBalance(web3.eth.accounts[0]) ), ‘ether’) ● Get a “public” attribute of the contract: ○ contractInstance.{publicAttribute}(function(err, data) { ..callback function.. }) ● Sending a simple transaction: ○ contractInstance.{payableFunction}(function params.., { from: fromAddress, value: valueToSendInWei, gas: gasCostOfTransaction }, function(err, data) { ..callback function.. }) Web3 - Examples (just to get a feeling for the API)
  • 27. ● Debugging (very important!) ○ Browser Dev Tools ○ Solidity Events ■ Can listen to them in web3.js ■ https://github.com/ethereum/wiki/wiki/JavaScript-API#contract-all events ■ Logs all events within the contract Web3