Chapter 5 · Solidity foundations · lesson 2
Your first contract
9 min
Builds on What a smart contract actually is
Chapter 5 · Solidity foundations · lesson 2
9 min
Builds on What a smart contract actually is
Now you change something. One thing.
If it went red, read the message under the editor before doing anything else. The compiler's own wording is on the first line; the plain-English version is underneath it.
Four separate things, in order:
greeting() at that address.This is exactly the cycle you will run against a real network in track 6. Same steps, same tools, and there it costs money.
Notice that deployment reported a gas figure. Storing a string permanently is one of the more expensive things a contract can do — the longer your greeting, the more deployment costs.
That is not a quirk of this playground. It is the pricing from track 1, applied to code you just wrote.
Predict
Check
Marking a variable private stops other contracts reading it. It does not
hide anything from people.
Every storage slot of every contract is readable by anyone with a node — the
data is right there in the state. private is a compile-time visibility rule,
not encryption.
Contracts have been drained because someone stored a secret in a private
variable and assumed that meant secret. Never put anything on-chain you would
not publish.