Lecture 5
Lecture 5
generation
blockchain
(Ethereum) 2
Hamza Salem - Innopolis University
Topics
● EVM Explained
● Solidity
● Smart Contract Examples ..
● ICO initial coin offering
● ERC-20 Token.
Meme Review
Solidity
❏ Solidity is an object-oriented, high-level language for
implementing smart contracts.
❏ Smart contracts are programs which govern the behaviour of
accounts within the Ethereum state. Solidity is a curly-bracket
language designed to target the Ethereum Virtual Machine (EVM).
❏ It is influenced by C++, Python and JavaScript. Solidity is
statically typed, supports inheritance, libraries and complex
user-defined types among other features.
❏ With Solidity you can create contracts for uses such as voting,
crowdfunding, blind auctions, and multi-signature wallets.
Let Me Explain ..
❏ Accounts vs Smart Contract
❏ External Contract vs contracts Account
❏ Storage, Memory and the Stack (Memory in Solidity is a temporary place to store data whereas
Storage holds data between function calls)
Let us try ..
https://docs.soliditylang.org/en/v0.8.21/
Coin Contract
❏ Simplest form of a cryptocurrency. The contract allows only its
creator to create new coins.
Example 1: Lottery Smart
Contract ● https://github.com/phillipdodd
/solidity-lottery/blob/master/c
ontracts/Lottery.sol
Example 2: ERC-20 Token Smart
Contract
- One of the most significant Ethereum tokens is known as ERC-20.
ERC-20 has emerged as the technical standard; it is used for all
smart contracts on the Ethereum blockchain for token
implementation and provides a list of rules that all Ethereum-based
tokens must follow.
- ERC-20 is similar, in some respects, to bitcoin, Litecoin, and any
other cryptocurrency; ERC-20 tokens are blockchain-based assets
that have value and can be sent and received. The primary
difference is that instead of running on their own blockchain, ERC-
20 tokens are issued on the Ethereum network.
- Check Notes of the slides.
Exercise 1: Lottery
Decentralized app
● Make UI for Example 1 lottery.
● Modify the contract to make any address started with 0xDXXXXXX or
0xFXXXXXX to win and if both participated to be random again.
Exercise 2: ERC-20
● Create Your own Token with 10,000,000 total supply.
○ Name: Innopolis Email ex: h.salem
○ Symbol: YOUR FIRST NAME
● Make UI for Execution Your Contract (Total Supply, Name,Symbol).
● Make simple UI For transferring tokens between users & show how
many users and how much their own from the tokens.
● Modify send function to send 50 Token to this address
0xD8C7978Be2A06F5752cB727fB3B7831B70bF394d every time any transfer happen.
● Deploy your Dapp on any web hosting platform and add links to the
main repo
Useful links
● https://www.toptal.com/ethereum/create-erc20-token-tutorial
● https://ethereum.stackexchange.com/questions/50310/how-to-pass-
the-value-in-bytes32-array
● https://github.com/phillipdodd/solidity-lottery/blob/master/contracts/
Lottery.sol
● https://docs.soliditylang.org/en/v0.8.21/introduction-to-smart-contra
cts.html#simple-smart-contract
● https://docs.soliditylang.org/en/v0.8.21/grammar.html