Skip to content

Commit b14db11

Browse files
authored
Merge pull request #11997 from stolab/11989-GasCost
better described how gas is used when interacting with a smart contra…
2 parents 9364ce4 + 7a490cc commit b14db11

File tree

1 file changed

+8
-1
lines changed
  • public/content/developers/docs/transactions

1 file changed

+8
-1
lines changed

public/content/developers/docs/transactions/index.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,20 @@ The base fee will be burned **-0.00399 ETH**
160160

161161
Validator keeps the tip **+0.000210 ETH**
162162

163-
Gas is required for any smart contract interaction too.
164163

165164
![Diagram showing how unused gas is refunded](./gas-tx.png)
166165
_Diagram adapted from [Ethereum EVM illustrated](https://takenobu-hs.github.io/downloads/ethereum_evm_illustrated.pdf)_
167166

168167
Any gas not used in a transaction is refunded to the user account.
169168

169+
### Smart contract interactions {#smart-contract-interactions}
170+
171+
Gas is required for any transaction that involves a smart contract.
172+
173+
Smart contracts can also contain functions known as [`view`](https://docs.soliditylang.org/en/latest/contracts.html#view-functions) or [`pure`](https://docs.soliditylang.org/en/latest/contracts.html#pure-functions) functions, which do not alter the state of the contract. As such, calling these functions from an EOA will not require any gas. The underlying RPC call for this scenario is [`eth_call`](/developers/docs/apis/json-rpc#eth_call)
174+
175+
Unlike when accessed using `eth_call`, these `view` or `pure` functions are also commonly called internally (ie. from the contract itself or from another contract) which does cost gas.
176+
170177
## Transaction lifecycle {#transaction-lifecycle}
171178

172179
Once the transaction has been submitted the following happens:

0 commit comments

Comments
 (0)