Open this lesson in your favourite AI. It'll walk you through the why, explain the demo, and quiz you on the try-it list.
Once deployed, your contract lives on-chain. You interact with it via two primitives: reading (a view call, free, instant) and writing (a transaction, costs gas, takes a block). cast call reads. cast send writes. Understanding that every write is a transaction — with gas, with a sender, with an event trail — is the mental model you'll use for the rest of Solidity.
cast call executes a view function off-chain and returns the result immediately at no gas cost, while cast send submits a real transaction, waits for a receipt, and reports gas used. The distinction maps directly to Solidity's view/pure vs state-mutating functions — every write costs gas and leaves a permanent on-chain record.
# READ (view call — free, no transaction)
cast call <HELLO_ADDR> 'greeting()(string)' \
--rpc-url http://127.0.0.1:8545
# -> "gm"
# WRITE (transaction — costs gas)
cast send <HELLO_ADDR> 'setGreeting(string)' 'hello world' \
--rpc-url http://127.0.0.1:8545 \
greeting() with cast call. Note that this is instant and free — no transaction is created.cast send, setting the greeting to something new. Copy the transaction hash it returns.cast receipt <tx_hash> and find the gasUsed field. Convert wei to gwei to USD — Anvil fakes gas prices, but the number is real.greeting() again and verify your new string.cast send with a wallet that has no ETH. It will fail — note the error. This is how you learn the difference between a view call and a transaction.Use these three in order. Each builds on the one before.
Explain the difference between `cast call` and `cast send`. Why does one cost gas and the other doesn't?
When I call `cast call greeting()`, the RPC node executes the function against the latest state and returns the result, but no transaction is created. Walk me through exactly what's happening under the hood — is anything persisted? Does the call cross the network?
A user's UI makes 50 reads and 2 writes per session. The writes are the expensive ones. Suggest three architectural patterns to minimize write transactions (batching, off-chain signatures, L2 rollups) and when to reach for each.