Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Ethereum Solidity Fundamentals


Published on

Basics you need to know about Solidity and how it works. Learn the simple way of building a smart contract in Solidity. Tools that can be used with Solidity.

Published in: Technology
  • Be the first to comment

Ethereum Solidity Fundamentals

  1. 1. Eno Bassey Presentation By: Ethereum: Solidity - Basics and Fundamentals
  2. 2. @ennytwit - Senior Consultant @ Andela - Php, C#, Python, Ruby & Solidity - Drama Director - Anime Lover - BasketBaller - Football Analyst
  3. 3. Contents What can you do today with Ethereum Understanding Dapp Web Applications vs Dapp Ethereum Nodes Ether and its denominations Using MetaMask Smart Contract - Writing Code with Remix Smart Contract - Same Contract with Editor
  4. 4. More about Ethereum
  5. 5. What you can do today with Ethereum and Dapps? - The Ethereum Blockchain can be used as a public blockchain and - A protocol for the creation of many blockchains (Private blockchain) What can be done in both? - Send and Receive Ether - Write Smart Contracts - Create provable fair applications - Launch your own token based on ether - The promise of Decentralized Databases
  6. 6. Understanding Dapp What is a Dapp? It is a Decentralized application - It is a peer to peer solution 
 - Data is shared 
 - Code is shared
  7. 7. Web Applications vs Dapp
  8. 8. Ethereum Nodes Kenya Ethereum Virtual Machines: Mining Nodes: Think of EVM as the execution runtime for Ethereum network. EVM’s main function is to provide a runtime where all smart contracts code are executed.
 EVM are the execution component in Ethereum. The purpose of EVM is to execute the code in smart contract line by line. Mining Nodes refers the nodes that belong to Miners. These nodes are part of the same network where EVM is hosted. At some point of time, the miners would create a new Block, collect all transaction from transaction pool and adds them to the newly created block. Finally, this Block is added to the chain
  9. 9. Working with the Ethereum Network
  10. 10. Types of Transactions in Ethereum 1. Transfer of Ether from one account to another 2. Deployment of Smart contract . 3. Using or invoking a function within a contract Each of the above requires an amount of Ether to execute
  11. 11. Components of a Transaction in Ethereum Component Description From It denotes the account originating the transaction To It denotes the account receiving the ethers or benefits of the transaction Value The value of the ether being transferred or executed BlockHash The Hash of the block this transaction belongs to Block Number Block the transaction belongs to GasPrice The price per gas the sender is willing to pay in Wei Gas Amount of gas supplied by the sender which is executing this transaction Hash Hash of the transaction Nonce How many times the sender has sent a transactions prior to this one TransactionIndex Serial Number of Transaction in block V This is the digital signature and signing of the transaction in cryptographic pieces of dataR S
  12. 12. Components of a Block in Ethereum Component Description Difficulty It determines the complexity of the puzzle/challenge given to the miners for this block GasLimit It determines the maximum gas allowed. GasUsed The actual gas used for this block for executing all transactions in it. Miner The account identifier of miner also known as coinbase or Etherbase Number The sequential number of this block on the chain ParentHash The parents blocks hash ReceiptsRoot, StateRoot and transactionRoot Refers to Merkel trees discussed during mining process. Hash Hash of the transaction Nonce How many times the sender has sent a transactions prior to this one Transactions The array of transactions that are part of this block. TotalDifficulty The total difficulty of the chain until this block
  13. 13. The Ether Ether is the currency of Ethereum. 
 Every activity on Ethereum that modifies its state costs Ether as fee and miners who are successful in generating and writing a block in chain are also rewards Ether
  14. 14. Denominations of Ether Conversion Tool Fig 1.0 Units of Ether
  15. 15. Gas Costs Ether is the currency of Ethereum. 
 Every activity on Ethereum that modifies its state costs Ether as fee and miners who are successful in generating and writing a block in chain are also rewards Ether
  16. 16. Writing Solidity
  17. 17. Writing Smart Contracts with Solidity Versioning : Every smart contract in Solidity is tied to a version and must run on the version to work effectively. pragma solidity ^ 0.4.0; contract Conditional { uint refVal = 10; uint limit = 20; function isGreaterEqualUnderLimit(uint testVal) view public returns(bool) { if (testVal >= refVal && testVal < limit) { return true; } } }
  18. 18. How smart contracts are deployed ABI (Application Binary Interface): This is an interface consisting of all external and public function declarations along with their parameters and return types. All smart contracts are compiled into two components: ByteCode : represents the contract and is deployed in Ethereum ecosystem. An easy simple tool to compile code is REMIX.
  19. 19. How smart contracts are deployed
  20. 20. How smart contracts are deployed
  21. 21. Basic Solidity Types Basic Types Name Description Examples string Sequence of characters [Hi there] [I am here!!!] bool Boolean Value true or false int Integer, positive or negative. Has no decimal 0 -3000 59158 uint Unsigned’ integer, positive integer. Has no decimal 0 3000 80158 fixed/ufixed Fixed’ point number. Number with a decimal after it 24.56. -54.678 3.14 Address Has methods tied to it for sending money 0x18bae199c8dbae199c8d
  22. 22. Function Types Common Function Types public Anyone can call this function private Only this contract can call this function view This function returns data and does not modify the contracts data constant This function returns data and does not modify the contract’s data pure This function will not modify or even read the contracts data payable When this function is called some amount of ether will be ‘charged’
  23. 23. Processing Contract Functions Process Tips ‘Calling’ a Function Sending a Transaction to a Function Cannot modify contract’s data Can modify a contract’s data Can return data Returns the transaction hast Runs instantly Takes Time to execute Free to do or use Cost Money/Gas
  24. 24. Tools to use for Solidity Development Node Truffle Ganache MetaMask (extension for chrome) IDEs e.g Atom, VSCode etc Syntax Highlighting for your IDE Remix
  25. 25. Remix What is Remix? Remix is an online solidity IDE that is used for writing and testing smart contracts Location: Documentation:
  26. 26. Workshop 1 Solidity 1: Simple Message Contract
  27. 27. Solidity with Javascript using IDEs
  28. 28. Syntax highlighting for IDEs Atom - Open the package installation manager in atom and search for 'language-ethereum'. 
 After installing the package, you might have to manually change the highlighter in the .sol file. Look for the selector at the bottom right of your editor window.
 Sublime -
 VSCode -
 Webstorm -
 VIM -
  29. 29. Folder Structure
  30. 30. Our Local Deployment
  31. 31. Deploy to the Network
  32. 32. Deploy to the Network
  33. 33. S Workshop 2 Solidity 2: Simple Voting Contract Using Truffle
  34. 34. Thank You
  35. 35. Questions