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 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
4. 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
6. 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.
8. 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
11. 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