- The contract has a state variable
counterthat is initialized to0. - When a user calls the
incremententrypoint, the contract incrementscounterby1. - When a user calls the
decrement, the contract decrementscounterby1.
Basic concepts
Simple counter
We now understand how to create a contract with state variables and functions. Let’s create a simple counter contract that increments and decrements a counter.
Here’s how it works: