Doing Smart-Contracts with Ethereum
Ethereum
An open software platform based on blockchain technology that enables developers to build and deploy decentralized applications.
Blockchain blocks
There are two types of accounts in Ethereum
- EOA: An account controlled by a private key that has the ability to send ether and message from it.
- Smart contract: An account that has its own code, and is controlled by code.
What are Smart-Contracts?
Exchange money, property, shares, or anything of value in a transparent, conflict-free way while avoiding the services of a middleman
What are the Advantages?
- Accuracy
- Transparency
- Clear Communication
- Speed
- Security
- Efficiency
- Paper Free
- Savings (no intermediaries)
- Trust
Smart Contracts and Blockchain Nodes
What's executed and when?!
Every node has to verify the results of a transaction which invokes a smart contract. The result is that at least every full node will execute the code.
When a node gets a transaction, it only does a few basic checks first, such as:
- 1) is the signature valid?
- 2) does the sending account have enough Ether to pay for the gas?
- 3) is the gas below the block gas limit?
Solidity
Solidity is a contract-oriented programming language for writing smart contracts.
Which is like JavaScript and has .sol as a file extension
Truffle
Development framework for Ethereum.
Genach
Local blockchain for development.
Metamask
Browser plugin: Brings Ethereum to your browser
Action: Smart-Contracts Labs
- 1) Debugging a smart contract
- 2) Pet-shop Dapp
- 3) Robust smart contracts with Openzeppelin - Protocol standard ERC20 (bonus)
What is the difference between smart contracts and dApps?
- dApps (Decentralized apps) are basically blockchain enabled websites/platforms.
- Smart contracts act like a logic brick that empowers dApps to connect with Blockchain.
Dapp diagram
Lab 1: smart contract
http://truffleframework.com/tutorials/debugging-a-smart-contract
Lab 2: our first dApp
http://truffleframework.com/tutorials/pet-shop
Lab 3: bonus
http://truffleframework.com/tutorials/robust-smart-contracts-with-openzeppelin