9. Ethereum Transactions and Smart Contract

2023. 11. 29. 03:06· CS/블록체인응용
목차
  1. Ethereum Account
  2. Two Types of Account
  3. Ethereum Transactions
  4. Transactions
  5. Types of Transactions
  6. Gas
  7. Smart Contract
  8. Smart Contract
  9. Properties of Smart Contracts
  10. Use cases of Smart contract
  11. Smart Contracts Language

Overview

  • Data such as account balances aare not stored directly in the blocks of the Ethereum blockchain. Only the relevant hash values are stored directly in the blockchain.
  • Ethereum use the Account/Balance Model
    • Simplicity: more intuitive - smart contract keep track of states to perform different tasks
      • UTXO's stateless model force transactions to include state information so that complicates the design of the contracts
    • Efficiency: only needs to validate that sending account has enough balance

 

Ethereum Account

Ethereum Account

  • Account is made of a cryptographic pair of keys: public & private
    • help prove that a tx was actually signed by the sender
  • Private key is used to sign tx
  • User hold private keys - the funds are always on Ethereum's ledger

 

Two Types of Account

EOA (Externally-owned account)

  • controlled by anyone with the private keys
  • creating account costs nothing
  • can initiate transactions
  • tx btw EOA can only be ETH/token transfers
  • made up of a cryptographic pair of keys: public and private keys that control account

Contract Account

  • a smart contract deployed to the network, controlled by code
  • creating a contract has a cost because it's using network storage
  • can only send tx in response to receiving a tx
  • tx from EOA to contract account can trigger code which can execute different actions
  • don't have private keys. instead, controlled by the logic of the smart contract code
Both account types have the ability to
- recieve, hold, send ETH & tokens
- interact with deployed smart contracts

Ethereum Transactions

Transactions

  • cryptographically signed instructions from accounts.
    • account will initiate a tx to update the state of the Ethereum network.
    • the simplest tx = transferring ETH from one account to another
  • refers to an action initiated by an EOA
  • Tx which change the state of the EVM need to be boadcast to the whole network.
  • Any node can broadcast a request for a tx to be executed on the EVM
    • after this, validator will execute the tx and propagate the resulting state change to the rest of the network.

Information included in Tx

  • recipient: receivng address
    • if EOA: transfer value / if contract account: execute the contract code
  • signature: identifier of the sender
  • nonce: sequencially incrementing couter which indicates the tx # of the account !== nonce in PoW
  • value: amount of ETH to transfer (in Wei: 10^9 wei = 1 ETH)
  • data: optional field to include arbitrary data
  • gasLimit: maximum amount of gas units that can be consumed by the tx
  • maxPriorityFeePerGas: maximum amount of gas to be included as a tip to the validator
  • maxFeePerGas: maximum amount of gas willing to be paid for the tx
    • inclusive of baseFeePerGas and maxPriorityFeePerGas

 

Types of Transactions

Regular Transactions

  • Transaction from one account to another

Contract deployment transactions

  • Transaction without a 'to' address, where the data field is used for the contract code

Executioin of a contact

  • Transaction that interacts with a deployed smart contract
  • 'to' address is the smart contract address

 

Gas

Transactions cost gas to execute

  • simple transfer tx = require 21000 units of gas
  • Gas = Gas Fee * Gas amount = (baseFeePerGas + maxPriorityFeePerGas) * gas amount
    • base fee will be burned to manage supply for price (to avoid over-supply)
    • validator keeps the tip

Smart Contract

Smart Contract

  • computer programs stored on the blockchain
  • terms of an agreement into computer code that automatically executes when the contract terms are met.

 

Properties of Smart Contracts

Automatic execution

  • outcome is automatically executed when the conditiosn are met -> no need to wait for a human to execute
  • 👉 Smart contracts remove the need for trust.

Predictable outcomes

  • human can interpret a traditional contract in different ways -> lead to failure
  • Smart contracts remove the possibility of different interpretations
    • execute precisel based on the conditions written within the contract's code
  • given the same circumstances, the smart contract will produce the same result

Public record

  • Smart contract is useful for audits and tracking because they're on a public blockchain
  • anyone can instantly track asset transfers and other related information.

Privacy protection

  • Smart contract can protect your privacy
  • Ethereum is a pseudonymous network = tx are tied to a unique cryptographic address, not your identity

Visible terms

  • You can check what's in a smart contract before you sign it.
  • public transparency of the terms in the contract means that anyone can scrutinize it

 

Use cases of Smart contract

Smart contracts can do essentially anothing that other computer programs do.

  • stablecoins, NFT, currency exchange, decentralized gaming ...

 

Smart Contracts Language

  • Ethereum Smart contracts can be programmed using relatively developer-friendly languages

Solidity

  • Object-oriented, high-level language for implementing smart contracts
  • similar with C++
  • Statically typed (the type of a variable is known at compile time)
  • Supports: Inheritance, Libraries, Complex user-defined types

Vyper

  • similar with Python
  • Stroing typing
  • Small and understandable compiler code
  • Efficient bytecode generation
  • Has less features than Solidity with the aim of making contracts more secure and easier to audit.

Remix

  • Remix IDE allows developing, deploying, and administering smarts contracts
저작자표시 (새창열림)

'CS > 블록체인응용' 카테고리의 다른 글

11. Private blockchain and Dapp  (0) 2023.12.03
10. NFT  (0) 2023.12.01
8. Ethereum Proof-of-Stake  (1) 2023.11.28
Lec 7-2: Proof-of-Stake  (0) 2023.10.20
Lec 7-1: Ethereum  (0) 2023.10.20
  1. Ethereum Account
  2. Two Types of Account
  3. Ethereum Transactions
  4. Transactions
  5. Types of Transactions
  6. Gas
  7. Smart Contract
  8. Smart Contract
  9. Properties of Smart Contracts
  10. Use cases of Smart contract
  11. Smart Contracts Language
'CS/블록체인응용' 카테고리의 다른 글
  • 11. Private blockchain and Dapp
  • 10. NFT
  • 8. Ethereum Proof-of-Stake
  • Lec 7-2: Proof-of-Stake
호프
호프
호프
Untitled
호프
전체
오늘
어제
  • 분류 전체보기 (341)
    • 오류😬 (4)
    • 스터디📖 (96)
      • 웹 개발 기초 (8)
      • Spring (20)
      • ML, DL (30)
      • Node.js (22)
      • React (0)
      • 블록체인 (12)
      • Go (3)
      • Javascript (1)
    • 알고리즘💻 (153)
      • 그리디 (23)
      • Bruteforce&Backtracking (16)
      • DP (17)
      • 이분탐색&정렬&분할정복 (17)
      • 누적합&투포인터 (6)
      • 스택&큐&덱 (19)
      • 그래프(DFS&BFS) (19)
      • 트리 (7)
      • 우선순위큐&다익스트라 (11)
      • 벨만포드&플로이드와샬 (8)
      • map&set&number theory (5)
      • 기타 (5)
    • 프로젝트 (3)
      • 캡스톤 디자인 프로젝트 (3)
    • 블록체인🔗 (3)
      • Solana (2)
      • 개발 (0)
      • Harmony (1)
    • ASC (6)
    • CS (73)
      • 데이터베이스 (12)
      • 클라우드컴퓨팅 (21)
      • 운영체제 (11)
      • 컴퓨터네트워크 (14)
      • 블록체인응용 (15)

블로그 메뉴

  • 홈
  • 태그
  • 방명록

공지사항

인기 글

태그

  • 복습

최근 댓글

최근 글

hELLO · Designed By 정상우.v4.2.1
호프
9. Ethereum Transactions and Smart Contract
상단으로

티스토리툴바

단축키

내 블로그

내 블로그 - 관리자 홈 전환
Q
Q
새 글 쓰기
W
W

블로그 게시글

글 수정 (권한 있는 경우)
E
E
댓글 영역으로 이동
C
C

모든 영역

이 페이지의 URL 복사
S
S
맨 위로 이동
T
T
티스토리 홈 이동
H
H
단축키 안내
Shift + /
⇧ + /

* 단축키는 한글/영문 대소문자로 이용 가능하며, 티스토리 기본 도메인에서만 동작합니다.