Link
Embed
Share
Beginning
This slide
Copy link URL
Copy link URL
Copy iframe embed code
Copy iframe embed code
Copy javascript embed code
Copy javascript embed code
Share
Tweet
Share
Tweet
Slide 1
Slide 1 text
Usman Bashir Developer Circle Lead How To Write A Smart Contract
Slide 2
Slide 2 text
WHOAMI? • me@ usmanbashir.com • @ ubax • usmanbashir.com Who am I? Software Developer & Technology Consultant
Slide 3
Slide 3 text
What is Solidity?
Slide 4
Slide 4 text
Solidity high level JavaScript-like language compiles to Ethereum VM code
Slide 5
Slide 5 text
Solidity is a statically typed language
Slide 6
Slide 6 text
Data Types bool int / uint address bytes / string struct / enums / arrays
Slide 7
Slide 7 text
Arrays address[] public friends; address[5] internal bestFriends;
Slide 8
Slide 8 text
Structs struct Friend { address id; string name; uint8 age; bool bestFriend; }
Slide 9
Slide 9 text
Structs struct Friend { address id; string name; uint8 age; bool bestFriend; } Friend newFriend = Friend(0x00, “Name", 42, true);
Slide 10
Slide 10 text
Function Structure function () {internal|external} [pure|constant|view|payable] [returns ()]
Slide 11
Slide 11 text
Function Types internal private public external
Slide 12
Slide 12 text
Internal (default) visible inside the contract context, including derived contracts
Slide 13
Slide 13 text
Private - only visible in the contract they are declared - and not in any derived contracts
Slide 14
Slide 14 text
Public can be called by you or anyone on the blockchain
Slide 15
Slide 15 text
External similar to public, but only someone from outside can call it
Slide 16
Slide 16 text
Function Types Cont’d pure view constant payable
Slide 17
Slide 17 text
Special Variable msg.sender address of the agent sending message
Slide 18
Slide 18 text
Trial by Fire
Slide 19
Slide 19 text
pragma solidity ^0.4.17; contract SimpleStorage { uint storedData; function set(uint _value) { storedData = _value; } function get() public view returns (uint) { return storedData; } }
Slide 20
Slide 20 text
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
Slide 21
Slide 21 text
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
Slide 22
Slide 22 text
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
Slide 23
Slide 23 text
pragma solidity ^0.4.17; contract SimpleStorage { uint storedData; function set(uint _value) public { storedData = _value; } function get() public view returns (uint) { return storedData; } }
Slide 24
Slide 24 text
pragma solidity ^0.4.17; contract SimpleStorage { uint storedData; function set(uint _value) public { storedData = _value; } function get() public view returns (uint) { return storedData; } }
Slide 25
Slide 25 text
Developer Tools
Slide 26
Slide 26 text
Truffle http://truffleframework.com
Slide 27
Slide 27 text
Ganache http://truffleframework.com/ganache/
Slide 28
Slide 28 text
METAMASK https://metamask.io
Slide 29
Slide 29 text
Web3.js https://github.com/ethereum/web3.js/
Slide 30
Slide 30 text
EthFiddle https://ethfiddle.com
Slide 31
Slide 31 text
Usman Bashir Developer Circle Lead Workshop
Slide 32
Slide 32 text
Fill-In Code http://bit.ly/BlockSC
Slide 33
Slide 33 text
So... 1. Learn more & read Docs 2. Build dApps 3. … 4. Profit? What's Next?
Slide 34
Slide 34 text
So... Contact me! • @ ubax • me@ usmanbashir.com • usmanbashir.com Need MORE help?
Slide 35
Slide 35 text
Thank You