Try   HackMD

What is Smart Contract

NCKU GDSC Smart Contact study group ( Week 1 )

reference : 「在 2022 年,我們該如何寫智能合約」 on iThome

D1 - D10

Introduction to blockchain ( Ethereum )

D1 : What is block and chain

  • Feature :

    • can't by modify
    • decentralized
  • Block :

    • Transaction :
      A block contains many transaction . Transaction can be classcify by Create and Execute .
      • Action :
        • Create :
          Deployment of Smart Contract
        • Execute :
          • Recieving Ether
          • Interact with Samrt Contract
      • Properties :
        • Recipient :
          • Address ( The address of recipient )
          • Value
        • Nonce :
          • Counter
        • Signature :
          Sign by private key of sender
        • Value :
          amount of Ether
        • data
          • The most important , send data to contract
        • Gas Limit
        • maxPriorityFeePerGas
        • maxFeePerGas
  • Chain :

    • The order of Transaction
      • if the
    • Connecting the block
  • Gas :

    • Why :
      Every transaction require computation resources . Base on Fee-For-Service System , the sender account has to pay the fee.
    • Gas ? :
      the Unit that describe computation resources ( describe the any operation cost running on EVM (Ethereum Virtual Machine) )
    • GasLimit :
      The max amount of gas that sender can pay in this transaction . ( Note that , if the GasLimit < the gas that the transaction needs , the transaction will fail( revert ) )
  • Fee :

    • BaseFee :
    • Prioroty Fee :
    • Max Fee:
      • Max Fee = Fee per Gas
      • Fee per Gas = BaseFee + Priority Fee
      • The transaction tool will calculate itself
    • Total Fee :
      • Total Fee = Max Fee * Used Gas
  • Account :

    • Balance
    • Call
      • can interact with Smart Contract
    • EOA ( Externally-owned account ) :
      • just like our personal acount
      • Balance
      • Nonce
      • Is able to :
        • recive/sende Ether :
        • interact with Contract Account
    • Contract Account :
      • Balance
      • Nonce
      • Codehash
      • storageRoot / storageHash
      • Is able to :
        • recive/send Ether :
        • will only start by EOA
  • NetWork :

    • Chain ID :
      • equivalent to Network ID
    • MainNet
    • TestNet :
      • Goerli
      • Sepolia
  • Consensus :

    • Miner / Validator :

    • PoW :

    • PoS :

  • Intro to Ethereum Stack :

  • EIP ( Ethereum Improvement Proposals ) :

    • document that
    • ERC
  • ERC ( Ethereum Request for Comments )

    • software interface standard

    • ERC-20

      • Properties :
        • name
        • symbol ( optional )
        • decimals
          • Smaller Unit
          • no float/double in solidity
        • totalSupply
        • balanceOf
          • balance of an address
        • transfer
        • transferFrom
        • approve
        • allowance
      • Events :
        • Transfer
        • Approval
      • Eg :
        • Stable Current : every coin has same value
        • BTC , ETH , USDT
        • Stock
    • ERC-721

      • Non Fungible Token
      • Properites & Events :
        • unique TokenID
      • Metadata Extension :
        • encode json by base64
      • enumeration extension :
        • for other functionalties
      • ERC-721A :
        • a new way to store tokenId and address
        • don't store the same owner name ( if continue )
      • ERC-721R :
        • with time limit
    • ERC-1155 :

      • ERC-1155 = ERC-20 + ERC-721
        • ERC-20 :
          • tokenId = 0 , amount = N
        • ERC-721:
          • tokenID = 1 , amount = 1 ; tokenID = 2 , amount = 1 ;
  • Example of Smart Contract