Paying for Transactions
Learn how Ethereum users pay for Ethereum transactions.
We've already mentioned that we need to pay a fee for interacting with an Ethereum network, and in this lesson, we'll look into how this fee is calculated and what it depends on. We'll also learn about the concept of gas and how it's used to calculate transaction fees in Ethereum.
Interacting with a smart contract
It turns out that we don’t need to pay a fee for all the operations within an Ethereum network; but first, let’s look into what types of operations we can perform. There are two different ways to interact with a smart contract: call and transaction.
The main difference between them is that a call can only read data from an Ethereum network and can't change the state of the network, can’t send payments, and can’t deploy new contracts. Transactions, on the other hand, can change the state of the network, for example, update the state variable of a state contract or deploy a new smart contract.
We need to pay only to execute a transaction, and transactions are recorded on the blockchain, while calls that are free are not stored in the blockchain history. Because transactions need to be included in a block, they take longer to execute.
A transaction on Ethereum can be an execution of a smart contract method, but it can also be a payment to an Ethereum address or a smart contract deployment. Moreover, we need to pay a fee for all of these operations.
Since calls only read data from a network, they can only be used with the view
and pure
functions, which can't change the state of the network.
Why can’t ...