Dapps 101
Katarzyna Jagieła & Maciej Bembenista
Agenda
— Ethereum, Solidity
— Introduction to Ethereum
— What are smart contracts?
— Example contract
— Web3
— Transactions in ETH
— Using Metamask
— Interacting with smart contract
What’s Ethereum all about?
- distributed public blockchain network
- different in purpose and capability from Bitcoin, but based on similar principles
- focuses on running decentralized applications
- runs smart contract code in a built-in EVM (Ethereum Virtual Machine)
- it uses Ether - native currency of the Ethereum blockchain
- gas - a special unit on Ethereum, used to calculate the amount of fees that we pay the miners for including our
transactions in their blocks
Smart Contracts
- they allow you to exchange money (Ether) or content such as tokens in a trustless way
- each contract has its own address on the blockchain
- are deployed to the blockchain and all code execution happens on the EVM during mining
- are not editable - you can change properties of the contract through its code, but you can’t upload code changes
or fixes - you need to get it right the first time or deploy a new contract
Contract example
What’s the cost of a transaction?
- Ethereum uses a unit called gas to determine the fee for the miner that will mine your
transaction
- Each operation in Ethereum has a set gas amount that it costs - for example, assembler
instruction that’s used to create a contract costs 32000 gas to run.
- You can set how much you’d like to pay per single gas unit used up to mine your transaction
- You can also set a gas limit in order to avoid paying for a transaction if it could use too much
gas.
How to communicate with Ethereum?
Web3 - a nice abstraction for JSON RPC
communication with Ethereum
- It’s available for JavaScript and Python - more languages are coming
- Provides a set of useful helpers for dealing with Ether units (wei, gwei etc.)
- Allows us to deploy contracts, interact with them, check their state
- Allows us to send Ether transactions
- Of course, anything that’s accomplished by Web3 can be done without it - it’ll just be harder to
implement
Web3.js - fetching an account’s balance
Web3py - fetching an account’s balance
How to create a Web Dapp
- Problem: Ethereum is based on public / private keys - we don’t want users to provide their
private keys to the application
- Problem: Users can sign their transactions offline, but that requires them to use a wallet
separate from our web Dapp - UX would suffer
- Solution: Use a browser-based wallet that allows us to interact with user’s private key if he
allows us to, without accessing them directly
Metamask - Ethereum wallet for the browser
Web3.js - sending a transaction through Metamask
Web3py - sending a transaction
Interacting with smart contracts
- ABI - methods and variables available on the contract
- Address - address of the deployed contract
Web3py / Web3.js - calling contract methods
Web3py - sending contract transactions
Web3.js - sending contract transactions
Questions?
Thanks!

Dapps 101

  • 1.
    Dapps 101 Katarzyna Jagieła& Maciej Bembenista
  • 2.
    Agenda — Ethereum, Solidity —Introduction to Ethereum — What are smart contracts? — Example contract — Web3 — Transactions in ETH — Using Metamask — Interacting with smart contract
  • 3.
    What’s Ethereum allabout? - distributed public blockchain network - different in purpose and capability from Bitcoin, but based on similar principles - focuses on running decentralized applications - runs smart contract code in a built-in EVM (Ethereum Virtual Machine) - it uses Ether - native currency of the Ethereum blockchain - gas - a special unit on Ethereum, used to calculate the amount of fees that we pay the miners for including our transactions in their blocks
  • 4.
    Smart Contracts - theyallow you to exchange money (Ether) or content such as tokens in a trustless way - each contract has its own address on the blockchain - are deployed to the blockchain and all code execution happens on the EVM during mining - are not editable - you can change properties of the contract through its code, but you can’t upload code changes or fixes - you need to get it right the first time or deploy a new contract
  • 5.
  • 6.
    What’s the costof a transaction? - Ethereum uses a unit called gas to determine the fee for the miner that will mine your transaction - Each operation in Ethereum has a set gas amount that it costs - for example, assembler instruction that’s used to create a contract costs 32000 gas to run. - You can set how much you’d like to pay per single gas unit used up to mine your transaction - You can also set a gas limit in order to avoid paying for a transaction if it could use too much gas.
  • 7.
    How to communicatewith Ethereum?
  • 8.
    Web3 - anice abstraction for JSON RPC communication with Ethereum - It’s available for JavaScript and Python - more languages are coming - Provides a set of useful helpers for dealing with Ether units (wei, gwei etc.) - Allows us to deploy contracts, interact with them, check their state - Allows us to send Ether transactions - Of course, anything that’s accomplished by Web3 can be done without it - it’ll just be harder to implement
  • 9.
    Web3.js - fetchingan account’s balance
  • 10.
    Web3py - fetchingan account’s balance
  • 11.
    How to createa Web Dapp - Problem: Ethereum is based on public / private keys - we don’t want users to provide their private keys to the application - Problem: Users can sign their transactions offline, but that requires them to use a wallet separate from our web Dapp - UX would suffer - Solution: Use a browser-based wallet that allows us to interact with user’s private key if he allows us to, without accessing them directly
  • 12.
    Metamask - Ethereumwallet for the browser
  • 13.
    Web3.js - sendinga transaction through Metamask
  • 14.
    Web3py - sendinga transaction
  • 15.
    Interacting with smartcontracts - ABI - methods and variables available on the contract - Address - address of the deployed contract
  • 16.
    Web3py / Web3.js- calling contract methods
  • 17.
    Web3py - sendingcontract transactions
  • 18.
    Web3.js - sendingcontract transactions
  • 19.
  • 20.