Demonstrates how to use and interact with "variables" in Clarity by incrementing a 32-bit unsigned integer and an additional Clarity function to retrieve the incremented value.
The counter.clar contract includes the following functionality.
count-up
function increments the designated "32-bit unsigned integer" for the account holder, and that value is wrapped inside thecounters
, which is declared as amap
data structure in Clarityget-count (...)
function retrieves the latest count from thecounters
map for a given account holder
To add new contracts, follow detailed instructions at Add new Contract.
NOTE: To use this example with Clarinet inside Hiro Platform, you can open the terminal session inside VS code by navigating to File -> View -> Terminal.
- You can manually test your your contracts in the Clarinet console.
- You can programmatically test your contracts with unit tests.