Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Counter64

Git Source

Counter for objects with IDs from 1 to type(uint64).max inclusive

State Variables

MIN_ID

uint64 constant MIN_ID = 1

MAX_ID

uint64 constant MAX_ID = type(uint64).max - 1

Functions

initialize

function initialize(Counter storage counter, uint64 initial) internal;

increment

function increment(Counter storage counter) internal returns (uint64 previous);

decrement

function decrement(Counter storage counter) internal returns (uint64 previous);

current

function current(Counter storage counter) internal view returns (uint64);

Errors

Overflow

error Overflow();

Underflow

error Underflow();

InvalidInitial

error InvalidInitial();

Structs

Counter

struct Counter {
    uint64 value;
}