Courses

Understanding Smart Contracts on Polygon
Polygon · Chapter 5

Understanding Smart Contracts on Polygon

A smart contract combines stored data with functions that read or change it. Its rules apply even when someone bypasses your website and calls the contract directly.

The basics

  • A state variable stores information onchain. A function defines an action, such as increasing a counter.
  • A view function reads state without changing it. A transaction is needed to persist a change.
  • Contract data is public, including variables marked private. Private limits access from other Solidity code; it does not encrypt stored information.

Try it yourself

Design a counter with one value and one increment action. Decide whether anyone can increment it. Our learning example allows everyone, making the rule easy to observe.

Read more in the official documentation

@ Daniel Burlacu