What Is the Difference between a View Function and a State-Changing Function?

A view function is a smart contract function that only reads data from the blockchain's state and does not modify it. It is free to call because it requires no gas.

A state-changing function, conversely, writes new data to the blockchain, altering the contract's state. It requires gas to execute because it must be processed and validated by the network's miners or validators.

What Is the Concept of “Gas Limit” and How Does It Differ from Gas Price?
How Does a Read-Only Reentrancy Attack Differ from These Two Types?
How Do Gas Limitations Prevent Reentrancy in Some Cases?
Why Was the 2,300 Gas Limit Considered a “Safe” Amount against Reentrancy?
Define the Concept of “Permissioned Access” in the Context of a Blockchain
Why Is the 2,300 Gas Limit Sometimes Considered a Design Flaw?
What Is the Difference between Gas Limit and Gas Price?
What Is the Primary Difference between a ‘View’ Function and a ‘State-Changing’ Function?

Glossar