@PatrickAlphaC SOLIDITY β¨
- It is a programming language developed by Ethereum developers. π
- Helps build smart contracts that run on Ethereum blockchain.
@PatrickAlphaC REMIX IDE π»
- It is a desktop application that allows developing and deploying smart contracts easily. βοΈ remix.ethereum.org
@PatrickAlphaC Topics covered ππ½
β Licence Identifier
β Solidity Version
β Contract
β Data Types
β Variable Declaration
β Functions
β Function Visibility Specifiers
β Deploy and Run Transaction
@PatrickAlphaC 1. LICENCE IDENTIFIER (optional) ποΈ
- This line is optional in most cases and is commented out.
- We use:
//SPDX-Licence-Identifier: MIT
@PatrickAlphaC 2. SOLIDITY VERSION π
- We begin by mentioning the version of the solidity language used.
- The caret symbol represents that any version above that mentioned is acceptable. β
pragma solidity ^0.8.7;
NOTE: The semicolon is MANDATORY at the end of each line.
@PatrickAlphaC 3. CONTRACT π
- The "contract" keyword is used to define contracts in Solidity.
- The keyword is followed by the name of the contract.
contract SimpleStorage{
}
- Contents of the contract are enclosed within the curly brackets {}.
@PatrickAlphaC 4. DATA TYPES β¨οΈ
- Some of the data types available are:
-> uint256 - unsigned integer (i.e., whole nos) represented using 256 bits.
-> int256 - integers (i.e., +ve and -ve nos) represented using 256bits.
-> bool - boolean values such as True and False.
-> address
- When not initialized, the variable is set to 0 by default.
- If visibility is not mentioned, it is considered to be "internal" by default (more of that is discussed below)
@PatrickAlphaC 6. FUNCTIONS π‘
- Functions help us execute a subset of code when called.
- The "function" keyword is used to declare a function.
- Syntax:
function functionName (parameterType parameter) visibility {
//type here
}
- Ex:
function store (unit favNum) public{
}
@PatrickAlphaC 7. FUNCTION VISIBILITY SPECIFIERS ποΈ
- public: visible externally and internally; creates a getter function
- private: only visible in the current contract
- internal: only visible to the current contract and its children
- external: only visible externally
@PatrickAlphaC 8. DEPLOY AND RUN TRANSACTION β
- After compiling the code, set the Environment to Javascript VM (London)
- It is a fake local blockchain where we can simulate our transactions without having the need to wait for them to go through on a testnet.
- Deploy. π₯³
@PatrickAlphaC π¨ Note 1
Every smart contract has an address.
π¨ Note 2
-Deploying a smart contract is the same as sending a transaction. Therefore some gas is used.
- Sending ETH requires 21,000 gas units.
- Complex transactions consume more gas.
@PatrickAlphaC That was 30 minutes of the course summarized for you. π
@PatrickAlphaC If you're a web3 enthusiast, wanting to explore, learn and grow as a developer, do watch this video and learn along with me.
@PatrickAlphaC Digest 7 (summarizing the next few minutes of the course) coming soon... π
If you liked this thread, retweet, like, and share the tweet below. π
@PatrickAlphaC πIn this lesson we see how to withdraw the deposited funds from our contract. π€
We cover:
- for loop
- ways to transfer eth
- constructors
- modifiers