66
edits
Line 9: | Line 9: | ||
Since in a blockchain each node must independently execute every transaction, it is important to limit the amount of computational effort required from the nodes. | Since in a blockchain each node must independently execute every transaction, it is important to limit the amount of computational effort required from the nodes. | ||
In EVM-based blockchains each transaction has a gas cost, which is defined by its complexity and its needs for storage. | In EVM-based blockchains each transaction has a gas cost, which is defined by its complexity and its needs for storage. | ||
Each transaction has a minimum gas cost of 21 | Each transaction has a minimum gas cost of 21,000 gas, to which more is added as the transaction gets more complicated. | ||
For example, a swap on [[Uniswap]] costs about 190 | For example, a swap on [[Uniswap]] costs about 190,000 gas, an [[ERC20]] token transfer costs about 65,000 gas, adding liquidity in a Uniswap v3 pool costs about 220,000 gas. | ||
When sending out a transaction, the user (or more commonly the wallet) sets a '''gas limit''', which is the maximum amount of gas the transaction is allowed to spend. If the transaction ends up spending less gas, the user gets a '''refund'''; if it ends up needing more gas, the transaction is reverted and the gas is '''not refunded.''' | When sending out a transaction, the user (or more commonly the wallet) sets a '''gas limit''', which is the maximum amount of gas the transaction is allowed to spend. If the transaction ends up spending less gas, the user gets a '''refund'''; if it ends up needing more gas, the transaction is reverted and the gas is '''not refunded.''' | ||
edits