0Pricing
Web3 & DApp Development Fundamentals · Aula

O que é gas

Pagamento pela computação

O que é gas é uma aula grátis de Web3 & DApp Development Fundamentals no CoddyKit. Esta é a aula 1 de 4. Você pode ler a aula completa abaixo gratuitamente — depois pratica ao vivo no navegador com um editor de código integrado e um tutor de IA 24/7. Faz parte do caminho de aprendizado de Web3 & DApp Development Fundamentals, e seu progresso é sincronizado entre a web e o app CoddyKit. O curso de Web3 & DApp Development Fundamentals inclui 4 aulas no total.

Partes desta aula ainda não foram traduzidas e aparecem em inglês.

Why Computation Costs Money

Every operation on Ethereum runs on thousands of nodes worldwide. To prevent abuse and pay for this work, the network charges gas.

Gas is the unit that measures computational effort.

What Is Gas?

Gas is a unit of measurement for the work required to execute operations on the EVM.

Sending ETH, calling a contract, or storing data each consume a specific amount of gas based on their complexity.

Gas Units per Operation

Different operations cost different amounts of gas. Simple operations are cheap; storage is expensive.

ADD        ->     3 gas
MUL        ->     5 gas
SLOAD      ->  2100 gas (read storage)
SSTORE     -> 20000 gas (new storage)
base tx    -> 21000 gas

Gas vs Gas Price

Keep two ideas separate:

  • Gas used — how much computation the transaction needs (units)
  • Gas price — how much you pay per unit, measured in gwei

Total fee = gas used multiplied by gas price.

Gwei: The Fee Unit

Gas prices are quoted in gwei, a tiny fraction of ETH. One gwei equals one billionth of an ETH (10^-9).

Quoting in gwei keeps numbers readable instead of writing many leading zeros.

1 ETH   = 1,000,000,000 gwei
1 gwei  = 1,000,000,000 wei
1 wei   = smallest unit of ETH

Calculating a Fee

The transaction fee is straightforward arithmetic. Multiply the gas your transaction consumes by the price you pay per unit of gas.

gasUsed   = 21000
gasPrice  = 20 gwei
fee = 21000 * 20 = 420000 gwei
    = 0.00042 ETH

Why Gas Exists

Gas serves two purposes:

  • Spam prevention — attackers cannot flood the network for free
  • Resource pricing — heavy computation costs more, encouraging efficient code

The Halting Problem Solution

Gas also stops infinite loops. Each step consumes gas, and when a transaction runs out, execution halts.

This guarantees the EVM always terminates — you cannot freeze the network with a runaway loop.

while (true) {
    // each iteration burns gas
}
// eventually: OUT OF GAS -> reverts

Who Receives the Fee?

Gas fees compensate the validators who include and execute your transaction.

Under EIP-1559, part of the fee is actually burned (destroyed), and a smaller tip goes to the validator. We cover this in a later lesson.

Gas and Smart Contracts

Complex smart contract calls cost more gas than simple transfers because they execute many operations.

Efficient contract code directly lowers user costs — gas optimization is a core skill for Solidity developers.

Putting It Together

Gas measures computational work; gas price (in gwei) sets the cost per unit. Their product is your fee.

Gas prevents spam, prices resources fairly, and guarantees execution always terminates.

Quick Check

Test your understanding of gas.

Recap: What Is Gas

You learned that:

  • Gas measures computational work on the EVM
  • Gas price is paid per unit in gwei
  • Fee = gas used multiplied by gas price
  • Gas prevents spam and stops infinite loops

Next: the full lifecycle of a transaction.

Perguntas Frequentes

A aula “O que é gas” é grátis?

Sim — o texto completo de “O que é gas” é grátis para ler aqui na web. Para praticá-la interativamente (um editor de código integrado e um tutor de IA 24/7) e desbloquear o restante do curso de Web3 & DApp Development Fundamentals, atualize para CoddyKit PRO. O curso de Web3 & DApp Development Fundamentals inclui 4 aulas no total.

O que vou aprender em “O que é gas”?

Pagamento pela computação Você pratica Web3 & DApp Development Fundamentals com código prático que executa diretamente no navegador, e um tutor de IA 24/7 responde suas dúvidas enquanto trabalha na aula.

Preciso ter experiência prévia para começar Web3 & DApp Development Fundamentals?

Nenhuma experiência prévia é necessária. Web3 & DApp Development Fundamentals no CoddyKit é estruturado para alunos iniciantes até avançados, então você pode começar aqui ou desde o início e aprender no seu ritmo. Esta é a aula 1 de 4.

Quanto tempo leva a aula “O que é gas”?

A maioria das aulas CoddyKit leva cerca de 5–10 minutos. Cada uma é compacta e interativa, então você faz progresso constante e retoma exatamente de onde parou entre web e app.

Posso escrever e executar código nesta aula de Web3 & DApp Development Fundamentals?

Sim. Cada aula de Web3 & DApp Development Fundamentals inclui um editor de código integrado, então você escreve e executa código real direto no navegador e recebe feedback de IA instantaneamente — nenhuma configuração local necessária.

Todas as aulas deste curso

  1. O que é gas
  2. Ciclo de vida de uma transação
  3. Limites e taxas de gas
  4. Nonces e ordenação
← Voltar para Web3 & DApp Development Fundamentals