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

Counter48

Git Source

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

State Variables

MIN_ID

uint48 constant MIN_ID = 1

MAX_ID

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

Functions

initialize

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

increase

function increase(Counter storage counter) internal returns (uint48 previous);

decrease

function decrease(Counter storage counter) internal returns (uint48 previous);

current

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

Errors

Overflow

error Overflow();

Underflow

error Underflow();

InvalidInitial

error InvalidInitial();

Structs

Counter

struct Counter {
    uint48 value;
}