Upgrade to Pro — share decks privately, control downloads, hide ads and more …

How To Write A Smart Contract

How To Write A Smart Contract

This talk covers writing an Ethereum smart contract in Solidity using developer-friendly tools. Followed by a workshop, where we learn, how to actually build a smart contract based dApp using the Truffle Framework, along with Ganache, Metamask and Web3.js.

Usman Bashir

April 28, 2018
Tweet

More Decks by Usman Bashir

Other Decks in Programming

Transcript

  1. WHOAMI? • me@ usmanbashir.com • @ ubax • usmanbashir.com Who

    am I? Software Developer & Technology Consultant
  2. Structs struct Friend { address id; string name; uint8 age;

    bool bestFriend; } Friend newFriend = Friend(0x00, “Name", 42, true);
  3. pragma solidity ^0.4.17; contract SimpleStorage { uint storedData; function set(uint

    _value) { storedData = _value; } function get() public view returns (uint) { return storedData; } }
  4. pragma solidity ^0.4.17; contract SimpleStorage { uint storedData; function set(uint

    _value) { storedData = _value; } function get() public view returns (uint) { return storedData; } } Pragma instructions for compiler
  5. pragma solidity ^0.4.17; contract SimpleStorage { uint storedData; function set(uint

    _value) { storedData = _value; } function get() public view returns (uint) { return storedData; } } Contract collection of code & data
  6. pragma solidity ^0.4.17; contract SimpleStorage { uint storedData; function set(uint

    _value) { storedData = _value; } function get() public view returns (uint) { return storedData; } } State Variable
  7. pragma solidity ^0.4.17; contract SimpleStorage { uint storedData; function set(uint

    _value) public { storedData = _value; } function get() public view returns (uint) { return storedData; } }
  8. pragma solidity ^0.4.17; contract SimpleStorage { uint storedData; function set(uint

    _value) public { storedData = _value; } function get() public view returns (uint) { return storedData; } }
  9. So... 1. Learn more & read Docs 2. Build dApps

    3. … 4. Profit? What's Next?