EVM 및 가스 작동 원리
스마트 계약의 실행 환경인 Ethereum 가상 머신(EVM)과 트랜잭션 수수료에 사용되는 가스의 개념을 이해합니다.
EVM 및 가스 작동 원리은(는) CoddyKit의 무료 Web3 & DApp Development Fundamentals 강의입니다. 이것은 3개 중 3번째 강의입니다. 아래에서 전체 강의를 무료로 읽을 수 있으며, 내장 코드 에디터와 24/7 AI 튜터와 함께 브라우저에서 직접 실습할 수 있습니다. 이 강의는 Web3 & DApp Development Fundamentals 학습 경로의 일부이며, 진행 상황이 웹과 CoddyKit 앱에 동기화됩니다. Web3 & DApp Development Fundamentals 강의에는 총 3개의 강의가 포함되어 있습니다.
이 강의의 일부는 아직 번역되지 않았으며 영어로 표시됩니다.
The Brain of Ethereum
Ethereum isn't just a ledger; it's a decentralized computer! This "computer" is called the Ethereum Virtual Machine (EVM).
Think of the EVM as a global, single-instance computer that runs all smart contracts and updates the state of the blockchain.
Every node in the Ethereum network runs the EVM, ensuring everyone agrees on the exact state of the network.
A Deterministic State Machine
The EVM is a deterministic state machine. This means that given the same starting state and the same transaction, it will always produce the same output state.
It processes transactions, executes smart contract code, and updates the blockchain's state (account balances, contract storage, etc.) accordingly.
This determinism is crucial for a decentralized network, as it allows all participants to independently verify the blockchain's integrity.
EVM Opcodes: Machine Language
Smart contracts, written in languages like Solidity, are compiled into EVM bytecode. This bytecode consists of low-level instructions called opcodes.
Each opcode performs a specific task, such as adding two numbers, pushing data onto the stack, or storing data in memory.
The EVM executes these opcodes sequentially, processing the logic defined by the smart contract.
Why Do We Need Gas?
Running computations on a global, decentralized computer isn't free. This is where Gas comes in.
Gas is a unit of computational effort required to perform operations on the Ethereum network.
It's used to:
- Prevent infinite loops in smart contracts.
- Compensate miners/validators for their computational resources.
- Prioritize transactions based on the fee offered.
Gas Limit: Your Transaction's Budget
When you send a transaction, you specify a Gas Limit. This is the maximum amount of gas you're willing to spend on that transaction.
It acts as a safety mechanism. If the transaction requires more gas than the limit, it will revert (fail), but you still pay for the gas used up to that point.
A standard Ether transfer typically costs 21,000 gas units. Smart contract interactions can cost much more depending on their complexity.
Gas Price: Cost Per Unit
While Gas Limit is the quantity, Gas Price is the cost per unit of gas. It's typically denominated in Gwei.
1 Gwei = 0.000000001 Ether. So, 1 Ether = 1,000,000,000 Gwei.
You can set a higher Gas Price to incentivize miners/validators to include your transaction in a block sooner, especially during network congestion.
Calculating Transaction Fees
The total transaction fee you pay is calculated as:
Gas Units Used * Gas Price
For example, if a transaction uses 21,000 gas units and the gas price is 50 Gwei:
- Fee = 21,000 * 50 Gwei = 1,050,000 Gwei
- Which is 0.00105 Ether
Remember, you only pay for the gas actually used, up to your Gas Limit.
The 'Out of Gas' Error
If your transaction runs out of gas before completing its execution, it will result in an "Out of Gas" error.
When this happens:
- All state changes made by the transaction are reverted.
- The transaction fails and is not recorded on the blockchain (except as a failed transaction).
- Crucially, you still pay the transaction fee for all the gas consumed up to the point of failure.
Gas Refunds: A Small Reward
Ethereum offers gas refunds for certain operations that reduce the blockchain's state size.
For instance, if a smart contract deletes data from storage, a portion of the gas spent on that deletion is refunded.
This incentivizes developers to write efficient contracts that don't unnecessarily bloat the blockchain's state.
Quick Check: EVM & Gas
Test your understanding of the Ethereum Virtual Machine and Gas mechanics.
EVM & Gas: The Essentials
In this lesson, we explored the core mechanics of the Ethereum network:
- The Ethereum Virtual Machine (EVM) is the global, deterministic computer executing smart contracts.
- Gas is the unit of computational effort required for transactions.
- Gas Limit sets the maximum gas a transaction can consume.
- Gas Price (in Gwei) determines the cost per unit of gas.
- Total transaction fees are
Gas Used * Gas Price. - Running "out of gas" reverts the transaction but still consumes the spent gas.
Understanding these concepts is vital for developing efficient and cost-effective DApps!
AI 튜터와 함께 Web3 & DApp Development Fundamentals을(를) 배우세요 — 무료
브라우저에서 실제 코드를 작성하고 실행하며, 24/7 AI 튜터로부터 즉각적인 도움을 받고, 웹이나 앱에서 중단한 부분부터 계속 학습하세요.
- 코스
- 29
- 레슨
- 105
자주 묻는 질문
“EVM 및 가스 작동 원리” 강의는 무료인가요?
네 — “EVM 및 가스 작동 원리” 전체 내용을 이 웹사이트에서 무료로 읽을 수 있습니다. 인터랙티브하게 실습하려면(내장 코드 에디터와 24/7 AI 튜터), CoddyKit PRO로 업그레이드하면 Web3 & DApp Development Fundamentals 강의 전체를 잠금 해제할 수 있습니다. Web3 & DApp Development Fundamentals 강의에는 총 3개의 강의가 포함되어 있습니다.
“EVM 및 가스 작동 원리”에서 뭘 배우나요?
스마트 계약의 실행 환경인 Ethereum 가상 머신(EVM)과 트랜잭션 수수료에 사용되는 가스의 개념을 이해합니다. 브라우저에서 직접 실행하는 실습 코드로 Web3 & DApp Development Fundamentals을(를) 배우며, 24/7 AI 튜터가 강의를 진행하면서 질문에 답변해줍니다.
Web3 & DApp Development Fundamentals을(를) 시작하는 데 경험이 필요한가요?
사전 경험은 필요하지 않습니다. CoddyKit의 Web3 & DApp Development Fundamentals은(는) 초급자부터 고급 학습자까지를 위해 구성되어 있으므로, 여기서 시작하거나 처음부터 시작할 수 있으며 자신의 속도대로 진행할 수 있습니다. 이것은 3개 중 3번째 강의입니다.
“EVM 및 가스 작동 원리” 강의는 얼마나 걸리나요?
대부분의 CoddyKit 강의는 약 5~10분이 소요됩니다. 각 강의는 간결하고 인터랙티브하여 꾸준한 진행이 가능하며, 웹과 앱에서 중단한 부분부터 바로 시작할 수 있습니다.
이 Web3 & DApp Development Fundamentals 강의에서 코드를 작성하고 실행할 수 있나요?
네. 모든 Web3 & DApp Development Fundamentals 강의에는 내장 코드 에디터가 포함되어 있으므로, 브라우저에서 바로 실제 코드를 작성하고 실행한 후 즉시 AI 피드백을 받을 수 있습니다 — 로컬 설정이 필요 없습니다.
이 강의의 모든 강의
- Ethereum 블록체인
- 스마트 계약이란 무엇인가요?
- EVM 및 가스 작동 원리