SlideShare a Scribd company logo
WEB3 - Solidity -
How to write a
smart contract
Whoami
My name Yossi Gruner
● I am a solidity and blockchain
developer since 2017
● Sirin Labs
● Finger Foods
● Unity
2
▪ ICO
▪ ERC20
▪ ERC721
▪ ERC1155
▪ Multisig
▪ Voting
▪ TokenTimelock
▪ Marketplace (NFTs)
▪ Games
▫ Lottery
▫ Price Prediction
▪ Donation Coin
Examples
3
▪ A smart contract is a computer program or a transaction protocol that is intended to
automatically execute, control or document events and actions according to the terms of a
contract or an agreement
What is a smart contract?
4
▪ Solidity is a contract-oriented, high-level language for implementing smart
contracts
▪ It was influenced by C++, Python and JavaScript and is designed to target the
Ethereum Virtual Machine (EVM)
▪ Solidity is statically typed, and supports inheritance, libraries and complex defined
types among other features
▪ The code is written in .sol files
5
Solidity - Language to write a smart
contract
▪ Contract
▪ Solidity compiler - scol
▪ Bytecode - binary
output
▪ ABI - Application binary
interface
6
Solidity - Compiler scol
▪ Remix Web tool - Web browser based IDE
▪ Truffle
▪ Hardhat
In all development environments we can
▪ Write solidity smart contracts
▪ Test smart contracts
▪ Deploy smart contracts
▪ RunPlay with smart contracts
7
Development environment write smart contract
Hardahat
Ethereum development environment for professionals
▪ Single-line comment - //
▪ Multiline comments /* and */
▪ Natspec - ///
9
Solidity Basic - Comments
▪ Import <FILE_NAME_LOCATION>
10
Solidity Basic - Impots
▪ Import variables in programming refer to a storage location that
contains values. These values can be changed during runtime
▪ State variables that are permanently stored in the ethereum ledger
by minders
▪ Stage variables store the current values of the smart contract
▪ The allocated memory for a state variable is statically assigned and it
cannot change (the size of the memory allocated) during the lifetime
of the contract
11
Solidity Basic - State variables
▪ Internal - this variable can only be used within the current contact
functions and any contact that inherits from them
int internal StateVariable;
▪ private
int private StateVariable;
▪ constant - the qualifier makes state variables immutable
bool constant NFT_PRICE=1;
12
Solidity Basic - State variables access
▪ Bool
▪ unit/int
▪ Bytes
▪ Address
▪ Mapping
▫ Key-value table (based on keccak256 hash)
▪ Enum
▪ Struct
▪ Bytes/String
13
Solidity Basic - Data types
14
Solidity Basic - Functions
▪ public - Anyone can call this function
▪ private - Only this contact can call this function
▪ view/constant - This function will returns data and does not modify
the contract data or state
▪ pure - ensure that they not read or modify the state
▪ payable - when someone call this function they must send ether
along
15
Solidity Basic - Function Types
▪ Solidity support declaring a constructor within a contract.
▪ Constructors are optional in solidity and the compile induces a
defaulting contractor when no contact is explicitly defined
▪ The contractor is executed once while deploying the contract
16
Solidity Basic - Constructors
▪ In Solidity, a modifier is always associated with a function
▪ A modifier in programming language refers to a construct that
changes the behaviour of the executing code and validates the state
17
Solidity Basic - Modifiers
▪ If else
▪ while
▪ do while
▪ for
18
Solidity Basic - Conditions & Loops
▪ Solidity supports inheritance between smart contracts
▪ Inheritance is the process of defining multiple contracts that are
related to each other through a parent-child relationship
▪ Solidity support multiple types of inheritance including multiple
inheritances
19
Solidity Basic - Inheritance
▪ You can have multiple from of functions
20
Solidity Basic - Polymorphism
Let's do some coding
21
▪ Write some code
▪ Compile it
▪ Deploy it
▪ Verify it
▪ Play with it
22
What we are going to do
Hello World
“
24
“
25
Yossi Gruner
We are using
openzeppelin
Ethereum development environment for professionals
ERC-20 - Token
▪ Ethereum Request for Comment 20 (ERC-20) is the implemented
standard for fungible tokens created using the Ethereum blockchain.
▪ in other words, they have a property that makes each Token be
exactly the same (in type and value) as another Token. For example,
an ERC-20 Token acts just like the ETH, meaning that 1 Token is and
will always be equal to all the other Tokens.
28
What is ERC-20
Let's do some coding
29
ERC-721 - NFT
▪ Ethereum Request for Comments (ERC) 721 is a data standard for
creating non fungible tokens, meaning each token is unique and
cannot be divided or directly exchanged for another ERC-721 token.
▪ The ERC-721 standard allows creators to issue unique crypto assets
like NFTs via smart contracts.
31
What is ERC-721
Let's do some coding
32
▪ Pow Vs Pos
▪ Ethereum internals
▪ Uniswap
▪ SubGraph
▪ ChainLink
▫ Random
▫ Data Provider
▫ Jobs
▪ Testing
▫ Code Coverage
▫ Logging
▪ Web3 Application
▪ Tenderly
=
More Topics for next session
33
▪ ERC-1155
▪ Opensea
▪ IPFS
▪ Proxy smart contracts
▪ Marike tree
▪ Metamask
▪ Wallets
▫ Cold vs Hot
THANKS!
Any questions?
You can find me at:
yossigruner@gmail.com
https://github.com/yossigruner/Solidity101
34

More Related Content

Similar to Web3 - Solidity - 101.pptx

Algorand Technical Workshop 2021
Algorand Technical Workshop 2021Algorand Technical Workshop 2021
Algorand Technical Workshop 2021
DanielBohnemann
 
Best practices to build secure smart contracts
Best practices to build secure smart contractsBest practices to build secure smart contracts
Best practices to build secure smart contracts
Gautam Anand
 
Blockchain Technology
Blockchain TechnologyBlockchain Technology
Blockchain Technology
Publicmediasolution
 
Introduction to Ethereum Smart Contracts
Introduction to Ethereum Smart Contracts Introduction to Ethereum Smart Contracts
Introduction to Ethereum Smart Contracts
ArcBlock
 
The Decentralized Developer Toolbox by Petros Ring
The Decentralized Developer Toolbox by Petros RingThe Decentralized Developer Toolbox by Petros Ring
The Decentralized Developer Toolbox by Petros Ring
Block 16
 
DeFi Series – Webinar 2- DeFi Primitives
DeFi Series – Webinar 2- DeFi PrimitivesDeFi Series – Webinar 2- DeFi Primitives
DeFi Series – Webinar 2- DeFi Primitives
Zeeve
 
From Crypto Kitties to non fungible token to ERC721 standard
From Crypto Kitties to non fungible token to ERC721 standardFrom Crypto Kitties to non fungible token to ERC721 standard
From Crypto Kitties to non fungible token to ERC721 standard
maeste
 
Webinar: From Crypto Kitties to non fungible token to ERC721 standard - Stefa...
Webinar: From Crypto Kitties to non fungible token to ERC721 standard - Stefa...Webinar: From Crypto Kitties to non fungible token to ERC721 standard - Stefa...
Webinar: From Crypto Kitties to non fungible token to ERC721 standard - Stefa...
Codemotion
 
Blockchain Experiments 1-11.pptx
Blockchain Experiments 1-11.pptxBlockchain Experiments 1-11.pptx
Blockchain Experiments 1-11.pptx
saiproject
 
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
Simone Onofri
 
Smart contracts in Solidity
Smart contracts in SoliditySmart contracts in Solidity
Smart contracts in Solidity
Felix Crisan
 
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Codemotion
 
Developing Non-Fungible Tokens using Ethereum Smart Contract
Developing Non-Fungible Tokens using Ethereum Smart ContractDeveloping Non-Fungible Tokens using Ethereum Smart Contract
Developing Non-Fungible Tokens using Ethereum Smart Contract
NUS-ISS
 
Ethereum
EthereumEthereum
Creating Smart Contract
Creating Smart ContractCreating Smart Contract
Creating Smart Contract
Deepak Aryal
 
Introducing r3 corda™ a distributed ledger designed for financial services
Introducing r3 corda™  a distributed ledger designed for financial servicesIntroducing r3 corda™  a distributed ledger designed for financial services
Introducing r3 corda™ a distributed ledger designed for financial services
Razi Rais
 
Write smart contract with solidity on Ethereum
Write smart contract with solidity on EthereumWrite smart contract with solidity on Ethereum
Write smart contract with solidity on Ethereum
Murughan Palaniachari
 
Building Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart ContractBuilding Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart Contract
Vaideeswaran Sethuraman
 
Blockchain Basics
Blockchain BasicsBlockchain Basics
Blockchain Basics
Ali Ayyash
 
Ivy Block - technicals.pdf
Ivy Block - technicals.pdfIvy Block - technicals.pdf
Ivy Block - technicals.pdf
TheBlockchainTeam
 

Similar to Web3 - Solidity - 101.pptx (20)

Algorand Technical Workshop 2021
Algorand Technical Workshop 2021Algorand Technical Workshop 2021
Algorand Technical Workshop 2021
 
Best practices to build secure smart contracts
Best practices to build secure smart contractsBest practices to build secure smart contracts
Best practices to build secure smart contracts
 
Blockchain Technology
Blockchain TechnologyBlockchain Technology
Blockchain Technology
 
Introduction to Ethereum Smart Contracts
Introduction to Ethereum Smart Contracts Introduction to Ethereum Smart Contracts
Introduction to Ethereum Smart Contracts
 
The Decentralized Developer Toolbox by Petros Ring
The Decentralized Developer Toolbox by Petros RingThe Decentralized Developer Toolbox by Petros Ring
The Decentralized Developer Toolbox by Petros Ring
 
DeFi Series – Webinar 2- DeFi Primitives
DeFi Series – Webinar 2- DeFi PrimitivesDeFi Series – Webinar 2- DeFi Primitives
DeFi Series – Webinar 2- DeFi Primitives
 
From Crypto Kitties to non fungible token to ERC721 standard
From Crypto Kitties to non fungible token to ERC721 standardFrom Crypto Kitties to non fungible token to ERC721 standard
From Crypto Kitties to non fungible token to ERC721 standard
 
Webinar: From Crypto Kitties to non fungible token to ERC721 standard - Stefa...
Webinar: From Crypto Kitties to non fungible token to ERC721 standard - Stefa...Webinar: From Crypto Kitties to non fungible token to ERC721 standard - Stefa...
Webinar: From Crypto Kitties to non fungible token to ERC721 standard - Stefa...
 
Blockchain Experiments 1-11.pptx
Blockchain Experiments 1-11.pptxBlockchain Experiments 1-11.pptx
Blockchain Experiments 1-11.pptx
 
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
Attacking and Exploiting Ethereum Smart Contracts: Auditing 101
 
Smart contracts in Solidity
Smart contracts in SoliditySmart contracts in Solidity
Smart contracts in Solidity
 
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
Stefano Maestri - Blockchain and smart contracts, what they are and why you s...
 
Developing Non-Fungible Tokens using Ethereum Smart Contract
Developing Non-Fungible Tokens using Ethereum Smart ContractDeveloping Non-Fungible Tokens using Ethereum Smart Contract
Developing Non-Fungible Tokens using Ethereum Smart Contract
 
Ethereum
EthereumEthereum
Ethereum
 
Creating Smart Contract
Creating Smart ContractCreating Smart Contract
Creating Smart Contract
 
Introducing r3 corda™ a distributed ledger designed for financial services
Introducing r3 corda™  a distributed ledger designed for financial servicesIntroducing r3 corda™  a distributed ledger designed for financial services
Introducing r3 corda™ a distributed ledger designed for financial services
 
Write smart contract with solidity on Ethereum
Write smart contract with solidity on EthereumWrite smart contract with solidity on Ethereum
Write smart contract with solidity on Ethereum
 
Building Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart ContractBuilding Apps with Ethereum Smart Contract
Building Apps with Ethereum Smart Contract
 
Blockchain Basics
Blockchain BasicsBlockchain Basics
Blockchain Basics
 
Ivy Block - technicals.pdf
Ivy Block - technicals.pdfIvy Block - technicals.pdf
Ivy Block - technicals.pdf
 

Recently uploaded

Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
JoytuBarua2
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
MLILAB
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
Jayaprasanna4
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
ViniHema
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
Neometrix_Engineering_Pvt_Ltd
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
zwunae
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
FluxPrime1
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Teleport Manpower Consultant
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
bakpo1
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
fxintegritypublishin
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
BrazilAccount1
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
BrazilAccount1
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
gerogepatton
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
Kamal Acharya
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
SupreethSP4
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
Pratik Pawar
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
obonagu
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
Pipe Restoration Solutions
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
thanhdowork
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
SamSarthak3
 

Recently uploaded (20)

Planning Of Procurement o different goods and services
Planning Of Procurement o different goods and servicesPlanning Of Procurement o different goods and services
Planning Of Procurement o different goods and services
 
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
H.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdfH.Seo,  ICLR 2024, MLILAB,  KAIST AI.pdf
H.Seo, ICLR 2024, MLILAB, KAIST AI.pdf
 
ethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.pptethical hacking-mobile hacking methods.ppt
ethical hacking-mobile hacking methods.ppt
 
power quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptxpower quality voltage fluctuation UNIT - I.pptx
power quality voltage fluctuation UNIT - I.pptx
 
Standard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - NeometrixStandard Reomte Control Interface - Neometrix
Standard Reomte Control Interface - Neometrix
 
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
一比一原版(IIT毕业证)伊利诺伊理工大学毕业证成绩单专业办理
 
DESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docxDESIGN A COTTON SEED SEPARATION MACHINE.docx
DESIGN A COTTON SEED SEPARATION MACHINE.docx
 
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdfTop 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
Top 10 Oil and Gas Projects in Saudi Arabia 2024.pdf
 
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
一比一原版(SFU毕业证)西蒙菲莎大学毕业证成绩单如何办理
 
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdfHybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
Hybrid optimization of pumped hydro system and solar- Engr. Abdul-Azeez.pdf
 
English lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdfEnglish lab ppt no titlespecENG PPTt.pdf
English lab ppt no titlespecENG PPTt.pdf
 
AP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specificAP LAB PPT.pdf ap lab ppt no title specific
AP LAB PPT.pdf ap lab ppt no title specific
 
Immunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary AttacksImmunizing Image Classifiers Against Localized Adversary Attacks
Immunizing Image Classifiers Against Localized Adversary Attacks
 
Student information management system project report ii.pdf
Student information management system project report ii.pdfStudent information management system project report ii.pdf
Student information management system project report ii.pdf
 
Runway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptxRunway Orientation Based on the Wind Rose Diagram.pptx
Runway Orientation Based on the Wind Rose Diagram.pptx
 
weather web application report.pdf
weather web application report.pdfweather web application report.pdf
weather web application report.pdf
 
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
在线办理(ANU毕业证书)澳洲国立大学毕业证录取通知书一模一样
 
The Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdfThe Benefits and Techniques of Trenchless Pipe Repair.pdf
The Benefits and Techniques of Trenchless Pipe Repair.pdf
 
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
RAT: Retrieval Augmented Thoughts Elicit Context-Aware Reasoning in Long-Hori...
 
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdfAKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
AKS UNIVERSITY Satna Final Year Project By OM Hardaha.pdf
 

Web3 - Solidity - 101.pptx

  • 1. WEB3 - Solidity - How to write a smart contract
  • 2. Whoami My name Yossi Gruner ● I am a solidity and blockchain developer since 2017 ● Sirin Labs ● Finger Foods ● Unity 2
  • 3. ▪ ICO ▪ ERC20 ▪ ERC721 ▪ ERC1155 ▪ Multisig ▪ Voting ▪ TokenTimelock ▪ Marketplace (NFTs) ▪ Games ▫ Lottery ▫ Price Prediction ▪ Donation Coin Examples 3
  • 4. ▪ A smart contract is a computer program or a transaction protocol that is intended to automatically execute, control or document events and actions according to the terms of a contract or an agreement What is a smart contract? 4
  • 5. ▪ Solidity is a contract-oriented, high-level language for implementing smart contracts ▪ It was influenced by C++, Python and JavaScript and is designed to target the Ethereum Virtual Machine (EVM) ▪ Solidity is statically typed, and supports inheritance, libraries and complex defined types among other features ▪ The code is written in .sol files 5 Solidity - Language to write a smart contract
  • 6. ▪ Contract ▪ Solidity compiler - scol ▪ Bytecode - binary output ▪ ABI - Application binary interface 6 Solidity - Compiler scol
  • 7. ▪ Remix Web tool - Web browser based IDE ▪ Truffle ▪ Hardhat In all development environments we can ▪ Write solidity smart contracts ▪ Test smart contracts ▪ Deploy smart contracts ▪ RunPlay with smart contracts 7 Development environment write smart contract
  • 9. ▪ Single-line comment - // ▪ Multiline comments /* and */ ▪ Natspec - /// 9 Solidity Basic - Comments
  • 11. ▪ Import variables in programming refer to a storage location that contains values. These values can be changed during runtime ▪ State variables that are permanently stored in the ethereum ledger by minders ▪ Stage variables store the current values of the smart contract ▪ The allocated memory for a state variable is statically assigned and it cannot change (the size of the memory allocated) during the lifetime of the contract 11 Solidity Basic - State variables
  • 12. ▪ Internal - this variable can only be used within the current contact functions and any contact that inherits from them int internal StateVariable; ▪ private int private StateVariable; ▪ constant - the qualifier makes state variables immutable bool constant NFT_PRICE=1; 12 Solidity Basic - State variables access
  • 13. ▪ Bool ▪ unit/int ▪ Bytes ▪ Address ▪ Mapping ▫ Key-value table (based on keccak256 hash) ▪ Enum ▪ Struct ▪ Bytes/String 13 Solidity Basic - Data types
  • 14. 14 Solidity Basic - Functions
  • 15. ▪ public - Anyone can call this function ▪ private - Only this contact can call this function ▪ view/constant - This function will returns data and does not modify the contract data or state ▪ pure - ensure that they not read or modify the state ▪ payable - when someone call this function they must send ether along 15 Solidity Basic - Function Types
  • 16. ▪ Solidity support declaring a constructor within a contract. ▪ Constructors are optional in solidity and the compile induces a defaulting contractor when no contact is explicitly defined ▪ The contractor is executed once while deploying the contract 16 Solidity Basic - Constructors
  • 17. ▪ In Solidity, a modifier is always associated with a function ▪ A modifier in programming language refers to a construct that changes the behaviour of the executing code and validates the state 17 Solidity Basic - Modifiers
  • 18. ▪ If else ▪ while ▪ do while ▪ for 18 Solidity Basic - Conditions & Loops
  • 19. ▪ Solidity supports inheritance between smart contracts ▪ Inheritance is the process of defining multiple contracts that are related to each other through a parent-child relationship ▪ Solidity support multiple types of inheritance including multiple inheritances 19 Solidity Basic - Inheritance
  • 20. ▪ You can have multiple from of functions 20 Solidity Basic - Polymorphism
  • 21. Let's do some coding 21
  • 22. ▪ Write some code ▪ Compile it ▪ Deploy it ▪ Verify it ▪ Play with it 22 What we are going to do
  • 26. We are using openzeppelin Ethereum development environment for professionals
  • 28. ▪ Ethereum Request for Comment 20 (ERC-20) is the implemented standard for fungible tokens created using the Ethereum blockchain. ▪ in other words, they have a property that makes each Token be exactly the same (in type and value) as another Token. For example, an ERC-20 Token acts just like the ETH, meaning that 1 Token is and will always be equal to all the other Tokens. 28 What is ERC-20
  • 29. Let's do some coding 29
  • 31. ▪ Ethereum Request for Comments (ERC) 721 is a data standard for creating non fungible tokens, meaning each token is unique and cannot be divided or directly exchanged for another ERC-721 token. ▪ The ERC-721 standard allows creators to issue unique crypto assets like NFTs via smart contracts. 31 What is ERC-721
  • 32. Let's do some coding 32
  • 33. ▪ Pow Vs Pos ▪ Ethereum internals ▪ Uniswap ▪ SubGraph ▪ ChainLink ▫ Random ▫ Data Provider ▫ Jobs ▪ Testing ▫ Code Coverage ▫ Logging ▪ Web3 Application ▪ Tenderly = More Topics for next session 33 ▪ ERC-1155 ▪ Opensea ▪ IPFS ▪ Proxy smart contracts ▪ Marike tree ▪ Metamask ▪ Wallets ▫ Cold vs Hot
  • 34. THANKS! Any questions? You can find me at: yossigruner@gmail.com https://github.com/yossigruner/Solidity101 34