[Youtube] Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course Lesson2
Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course Lesson2
https://www.youtube.com/watch?v=gyMwXuJrbJQ
Remix IDE
Remix - Ethereum IDE
remix.ethereum.org
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.8; // make sure you put the program version
//pragma solidity 0.8.18; // make sure you put the program version
//pragma solidity ^0.8.7; // any version upper than 0.8.7
//pragma solidity >=0.8.7 <0.9.0; // 0.8.8, 9.8.9 all work
// every line finish by ;
contract SimpleStorage {
//boolean, uint, int, address ,byets
// true or false = booleaen
// uint = only positive , how many bytes you want to assing to this ? you can allcate
// int = negative + positive
// addresss
// bytes
// bool hasFavoriteNumber = true;
// uint256 hasFavoriteNumber = 5; // uint 256 is the default
// int favoriteNumber= 123;
// string facoriteNumberInText= "favorite number in text ";
// int256 facoritNumber = -123;
// address myAddress = 0x10003aa242eE9S3492Df;
// bytes32 favoriteBytes="cat"; // automatically convert to bytes
//bytes2 4 8 16 32
// uint 2 4 8 16 32 64
uint256 public favoriteNumber; // favoriteNumber default = 0 ;
function store(uint256 _favoriteNumber) public{
favoriteNumber = _favoriteNumber;
}
//0xd9145CCE52D386f254917e481eB44e9943F39138
// address of this contract is here
// deploying contract = making transaction
}
public. : visible
private
external : default visibility
private: internal one but not visible
https://docs.soliditylang.org/en/v0.8.19/contracts.html#visibility-and-getters
scope : whatever in the {} inside only
Struct :
how do they know People ? Its defined later than the first ?
same as javascript ?
uint256 public favoriteNumber;
struct People {
uint256 favoriteNumber;
string name;
}
People[] public people; //dynamic array
//People[3] public favoritePeople; // size of 3 fixed
//uint256[] public favoriteNumberList;
function addPerson(string memory _name, uint256 _favoriteNumber) public{
//people.push(People(_favoriteNumber,_name));
People memory newPerson=People({
favoriteNumber:_favoriteNumber,
name:_name});
people.push(newPerson);
}
EVM can access and store information in :
different data storage :
1. stack
2.memory
variable only exist temporarily can modify the variable
ex ) in this function we don't need to use the name in other place so we just put it in the memory.
function addPerson(string memory _name, uint256 _favoriteNumber) public{
_name="cat";
people.push(People(_favoriteNumber, _name));
}
variable only exists even outside of executing function.
the permanent variable can be modified.
4.calldata
variable only exist temporarily can not modify the variable
function addPerson(string cat _name, uint256 _favoriteNumber) public{
//_name="cat"; you can not modify the varibale its calldata
people.push(People(_favoriteNumber, _name));
}
5.code
6.logs
you can deploy in the test net as well .
all the function you have to use metamask to send the gas fee (test net ETH)
and all the view function are free not gonna ask you any meta mask stuff.
https://sepolia.etherscan.io/address/0x795A4B4623E3825dFd118c8E7b4d20802Df3E9da
Solidity :
The EVM : Etheruem Virtual Machine :
EVM competitalbe blockchain : Avalanche, Fantom, Polygon
(you can add in the meat mask -> and deploy in the network)
'IT > Blockchain' 카테고리의 다른 글
[Youtube] Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course Lesson3 (0) | 2023.03.28 |
---|---|
[Youtube] Learn Blockchain, Solidity, and Full Stack Web3 Development with JavaScript – 32-Hour Course (0) | 2023.03.24 |
하이퍼렛져 페브릭 hyper ledger fabric (0) | 2021.09.30 |
Hyperledger fabric based webservice (0) | 2021.09.28 |
[ 블록체인] Crypto Kitty 크립토 키티 #3 마지막 후기 (0) | 2021.03.01 |