Basic Structure for NFT Market App
**Front-end Application: ** receive token urls point to metadata
NFT Market(smart contract): generate token id based on token uri and owner and the token
**Pinata: **Stores metadata for tokens
Add Ethereum to global window type
**Access it in browser: **
Solidity Version
Exact version 0.8.7
Any version of 0.8.7 and above is ok about the contract
version range
Types in Solidity
bool(boolean)
uinit
int
address
bytes
solidity initialize int value into 0
Visibility
default visibility is internal
for each public variable would a getter
function would be automatically generated
View and Pure
function with **view and pure ** does not cost gas when it is executed
- view: function could not modify block chain state, but could read
- pure: disallow both read and write
**Exception: ** calling view and pure functions inside a function that costs gas would lead to extra gas:
struct
Data Location
Data location could only be given for array, struct, mapping types(string is array)
- Memory: variable erased after used by functions, stored in memory
- Storage: would be permanently stored in block-chain
- calldata: immutable, could only be used for function parameters, same as Memory in lifespan
default type of variable is Storage
Data location could only be given to the array(string is array), strcut or mapping types
in Solidity, uint = uint256
in Solidity, size of array could be fixed or not fixed
Require
in Solidity
in Solidity Require
works as if....throw
: