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.
Glossar
Smart Contract Function
Execution ⎊ Smart contract function execution represents the deterministic computation triggered by a transaction interacting with deployed code on a blockchain, fundamentally altering state variables according to predefined logic.
View Function
Query ⎊ A View Function is a read-only method within a smart contract that allows external entities to query the contract's state variables without initiating a transaction or incurring gas costs.