Introduction to Gas and Fees
Blockchain transactions require computational resources to process. Both Ethereum and OKTC networks use systems called Gas and Fees to manage these resources efficiently. While these concepts share similarities, their implementations differ between networks.
Denominations and Units of Value
Blockchain networks use specific denominations to measure transaction values. OKTC employs a metric system for its native token, okt, with Wei being the smallest unit (base unit). Here's how these denominations break down:
| Unit | Wei Value | Equivalent in Wei |
|---|---|---|
| wei | 1 wei | 1 |
| Kwei (babbage) | 1e3 wei | 1,000 |
| Mwei (lovelace) | 1e6 wei | 1,000,000 |
| Gwei (shannon) | 1e9 wei | 1,000,000,000 |
| microether (szabo) | 1e12 wei | 1,000,000,000,000 |
| milliether (finney) | 1e15 wei | 1,000,000,000,000,000 |
| okt | 1e18 wei | 1,000,000,000,000,000,000 |
👉 Explore blockchain transaction costs in detail
Core Concepts: Gas in Ethereum and Cosmos
Ethereum's Gas System
- Purpose: Prevents infinite loops by attaching costs to operations.
- Function: Every EVM operation consumes gas, paid in fractions of ETH.
- Key Feature: Ensures operations are computationally feasible and deters spam.
Cosmos SDK's Gas System
- Tracks Usage: Through
GasMeter(per transaction) andBlockGasMeter(per block). - Flexibility: Block gas limits adjustable via governance proposals.
- Operations: Includes non-transactional state changes like
BeginBlock/EndBlock.
Technical Implementation in OKTC
Matching EVM Gas Consumption
OKTC bridges Ethereum compatibility with Cosmos infrastructure by:
- Resetting GasMeters: For EVM module operations to align with Ethereum's standards.
- Custom AnteHandler: Tailored for EVM transactions to verify fees accurately.
Special Cases
- Gas Refunds: EVM-type transactions refund unused gas; Cosmos-types don't.
- 0-Fee Transactions: Possible for non-EVM modules if validators permit (EVM transactions always require gas).
👉 Learn how to optimize gas usage
FAQs
Why does Ethereum use gas?
Gas ensures operations have a computational cost, preventing abuse and infinite execution loops.
Can I get a gas refund on OKTC?
Yes, but only for EVM-type transactions. Cosmos-type transactions don't support refunds.
How does OKTC handle 0-fee transactions?
Non-EVM transactions can be 0-fee if validators allow it. EVM transactions always require gas fees.
What’s the smallest unit of okt?
The base unit is Wei (1 okt = 1e18 Wei).
How is gas price determined in Cosmos?
Validators set minimum prices locally, leading to variable fee requirements across the network.