counter

package
v0.1.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2025 License: MIT Imports: 1 Imported by: 0

Documentation

Overview

Package counter implements a simple counter contract example. Each counter is stored in a separate object, allowing multiple counters to exist simultaneously. The user who calls Initialize becomes the owner of the counter object. Only the owner can modify the counter value through Increment or Reset functions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetValue

func GetValue(counterID core.ObjectID) uint64

GetValue retrieves the current value of the specified counter. This function can be called by any user.

func Increment

func Increment(counterID core.ObjectID, amount uint64) error

Increment increases the counter value by the specified amount. Only the owner of the counter object can call this function.

func Initialize

func Initialize(initialValue uint64) core.ObjectID

Initialize creates a new counter object with the specified initial value. The caller becomes the owner of the counter object. Returns the ObjectID of the created counter.

func Reset

func Reset(counterID core.ObjectID) error

Reset sets the counter value back to 0. Only the owner of the counter object can call this function.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL