0Pricing
Web3 & DApp Development Fundamentals · Lekcja

Kody operacji

Operacje niskiego poziomu

Kody operacji to bezpłatna lekcja Web3 & DApp Development Fundamentals na CoddyKit. To lekcja 3 z 4. Możesz przeczytać całą lekcję poniżej za darmo — a potem ćwiczyć ją interaktywnie w przeglądarce z wbudowanym edytorem kodu i tutorem AI dostępnym 24/7. To część ścieżki edukacyjnej Web3 & DApp Development Fundamentals, a Twój postęp synchronizuje się między webem a aplikacją CoddyKit. Kurs Web3 & DApp Development Fundamentals zawiera 4 lekcji w sumie.

Części tej lekcji nie zostały jeszcze przetłumaczone i są wyświetlane po angielsku.

The EVM Instruction Set

At its lowest level, the EVM runs a sequence of opcodes — single-byte instructions that each do one thing.

Understanding opcodes reveals what your Solidity actually does and where gas goes.

What Is an Opcode?

An opcode (operation code) is a one-byte command the EVM executes. Examples include ADD, MUL, PUSH1, SLOAD, and JUMP.

Each opcode has a name, a numeric value, and a fixed gas cost.

0x01 = ADD
0x02 = MUL
0x60 = PUSH1
0x54 = SLOAD
0x56 = JUMP

Stack Manipulation Opcodes

Opcodes like PUSH, POP, DUP, and SWAP manage the stack.

PUSH adds a value, POP removes one, DUP duplicates an item, and SWAP exchanges two stack positions.

PUSH1 0x0A   // [10]
DUP1         // [10, 10]
PUSH1 0x14   // [10, 10, 20]
SWAP1        // [10, 20, 10]

Arithmetic Opcodes

Arithmetic opcodes pop operands and push results: ADD, SUB, MUL, DIV, and MOD.

All math is done on 256-bit unsigned integers (with signed variants available).

PUSH1 0x09   // [9]
PUSH1 0x04   // [9, 4]
SUB          // [5]   (9 - 4)

Comparison and Logic

Opcodes like LT, GT, EQ, AND, OR, and ISZERO handle comparisons and bitwise logic.

They push 1 for true and 0 for false, which control flow then uses.

Memory and Storage Opcodes

Data movement opcodes touch the costly locations:

  • MLOAD / MSTORE — read/write memory
  • SLOAD / SSTORE — read/write storage

SSTORE is one of the most expensive opcodes.

Control Flow Opcodes

JUMP and JUMPI (conditional jump) move execution to a JUMPDEST marker.

This is how the EVM implements loops and if-statements at the bytecode level.

PUSH1 0x10   // jump target
JUMPI        // jump if top of stack != 0
// ... at offset 0x10:
JUMPDEST     // valid landing spot

Environment Opcodes

Opcodes like CALLER, CALLVALUE, ADDRESS, and TIMESTAMP expose context.

For example, CALLER pushes the address that initiated the call (this is what msg.sender compiles to).

Gas Cost per Opcode

Every opcode has a defined gas cost. Cheap ones like ADD cost 3 gas; expensive ones like SSTORE cost up to 20000.

The total gas of a transaction is the sum of all opcodes it executes.

ADD    -> 3 gas
MLOAD  -> 3 gas
SLOAD  -> 2100 gas
SSTORE -> up to 20000 gas

From Solidity to Opcodes

The Solidity compiler turns each high-level statement into many opcodes.

A single uint x = a + b; becomes PUSH, PUSH, ADD, and an MSTORE or SSTORE depending on where x lives.

Putting It Together

Opcodes are the EVM's atomic instructions for stack, arithmetic, logic, memory, storage, control flow, and environment.

Each carries a gas cost, and your Solidity ultimately becomes a stream of them.

Quick Check

Test your opcode knowledge.

Recap: Opcodes

You learned that:

  • Opcodes are one-byte EVM instructions
  • They cover the stack, arithmetic, logic, memory, storage, control flow, and environment
  • SSTORE is among the most expensive
  • Solidity compiles into many opcodes

Next: accounts and state.

Często zadawane pytania

Czy lekcja „Kody operacji” jest bezpłatna?

Tak — pełny tekst „Kody operacji” jest dostępny za darmo tutaj w sieci. Aby ćwiczyć ją interaktywnie (wbudowany edytor kodu i tutor AI dostępny 24/7) i odblokować resztę kursu Web3 & DApp Development Fundamentals, przejdź na CoddyKit PRO. Kurs Web3 & DApp Development Fundamentals zawiera 4 lekcji w sumie.

Co nauczysz się w „Kody operacji”?

Operacje niskiego poziomu Ćwiczysz Web3 & DApp Development Fundamentals z praktycznym kodem, który uruchamiasz bezpośrednio w przeglądarce, a tutor AI dostępny 24/7 odpowiada na Twoje pytania podczas pracy nad lekcją.

Czy potrzebuję doświadczenia, aby zacząć Web3 & DApp Development Fundamentals?

Nie wymagamy żadnego doświadczenia. Web3 & DApp Development Fundamentals w CoddyKit jest strukturyzowany dla początkujących i zaawansowanych użytkowników, więc możesz zacząć tutaj lub od początku i uczyć się w swoim tempie. To lekcja 3 z 4.

Ile czasu zajmuje lekcja „Kody operacji”?

Większość lekcji CoddyKit trwa około 5–10 minut. Każda lekcja to mały, interaktywny krok, dzięki czemu robisz systematyczne postępy i zawsze wracasz dokładnie do tego samego miejsca — na webie i w aplikacji.

Czy mogę pisać i uruchamiać kod w tej lekcji Web3 & DApp Development Fundamentals?

Tak. Każda lekcja Web3 & DApp Development Fundamentals zawiera wbudowany edytor kodu, więc piszesz i uruchamiasz prawdziwy kod bezpośrednio w przeglądarce i od razu otrzymujesz sprzężenie zwrotne od AI — bez konfiguracji na komputerze.

Wszystkie lekcje w tym kursie

  1. Maszyna wirtualna Ethereum
  2. Storage, memory i stack
  3. Kody operacji
  4. Konta i stan
← Powrót do Web3 & DApp Development Fundamentals