Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/Nonce

primitives/Nonce

Type Aliases

NonceType

NonceType = bigint & object
Defined in: src/primitives/Nonce/NonceType.ts:7 Branded Nonce type - prevents nonce reuse/confusion Represents a transaction nonce as a branded bigint

Type Declaration

[brand]
readonly [brand]: "Nonce"

Variables

Nonce

const Nonce: (value) => NonceType & object
Defined in: src/primitives/Nonce/index.ts:30

Type Declaration

from()
from: (value) => NonceType
Create Nonce from number, bigint, or hex string
Parameters
value
Value to convert string | number | bigint
Returns
NonceType Nonce
Example
const nonce1 = Nonce.from(0);
const nonce2 = Nonce.from(42n);
const nonce3 = Nonce.from("0x2a");
increment()
increment: (nonce) => NonceType
Parameters
nonce
string | number | bigint
Returns
NonceType
toBigInt()
toBigInt: (nonce) => bigint
Parameters
nonce
string | number | bigint
Returns
bigint
toNumber()
toNumber: (nonce) => number
Parameters
nonce
string | number | bigint
Returns
number

Functions

_increment()

_increment(this): NonceType
Defined in: src/primitives/Nonce/increment.js:14 Increment nonce by 1

Parameters

this
NonceType

Returns

NonceType New nonce incremented by 1

Example

const next = Nonce._increment.call(nonce);

_toBigInt()

_toBigInt(this): bigint
Defined in: src/primitives/Nonce/toBigInt.js:14 Convert Nonce to bigint

Parameters

this
NonceType

Returns

bigint BigInt

Example

const n = Nonce._toBigInt.call(nonce);

_toNumber()

_toNumber(this): number
Defined in: src/primitives/Nonce/toNumber.js:15 Convert Nonce to number

Parameters

this
NonceType

Returns

number Number

Throws

If nonce exceeds safe integer range

Example

const n = Nonce._toNumber.call(nonce);

from()

from(value): NonceType
Defined in: src/primitives/Nonce/from.js:16 Create Nonce from number, bigint, or hex string

Parameters

value
Value to convert string | number | bigint

Returns

NonceType Nonce

Example

const nonce1 = Nonce.from(0);
const nonce2 = Nonce.from(42n);
const nonce3 = Nonce.from("0x2a");

increment()

increment(nonce): NonceType
Defined in: src/primitives/Nonce/index.ts:22

Parameters

nonce
string | number | bigint

Returns

NonceType

toBigInt()

toBigInt(nonce): bigint
Defined in: src/primitives/Nonce/index.ts:18

Parameters

nonce
string | number | bigint

Returns

bigint

toNumber()

toNumber(nonce): number
Defined in: src/primitives/Nonce/index.ts:14

Parameters

nonce
string | number | bigint

Returns

number