@tevm/voltaire / primitives/TokenId
primitives/TokenId
Classes
InvalidTokenIdError
Defined in: src/primitives/TokenId/errors.ts:23 Base validation errorExample
Extends
Constructors
Constructor
new InvalidTokenIdError(Defined in: src/primitives/TokenId/errors.ts:24message,options?):InvalidTokenIdError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
expected?
string
value?
unknown
Returns
InvalidTokenIdError
Overrides
ValidationError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
ValidationError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
ValidationError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
ValidationError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
ValidationError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
ValidationError.expected
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
ValidationError.value
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
ValidationError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
ValidationError.toJSON
TokenIdError
Defined in: src/primitives/TokenId/errors.ts:3 Base error for all primitive-related errorsExample
Extends
Constructors
Constructor
new TokenIdError(Defined in: src/primitives/TokenId/errors.ts:4message,options?):TokenIdError
Parameters
message
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
Returns
TokenIdError
Overrides
PrimitiveError.constructor
Properties
cause?
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)optionalcause:Error
Inherited from
PrimitiveError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39
Machine-readable error code for programmatic handling
Example
Inherited from
PrimitiveError.code
context?
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debuggingoptionalcontext:Record<string,unknown>
Example
Inherited from
PrimitiveError.context
docsPath?
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this erroroptionaldocsPath:string
Example
Inherited from
PrimitiveError.docsPath
Methods
getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94
Get full error chain as string for logging
Returns
string
Inherited from
PrimitiveError.getErrorChain
toJSON()
toJSON():Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetryRecord<string,unknown>
Returns
Record<string, unknown>
Inherited from
PrimitiveError.toJSON
Type Aliases
TokenIdType
TokenIdType =Defined in: src/primitives/TokenId/TokenIdType.ts:10 TokenId type - ERC-721 NFT token identifierbigint&object
Type Declaration
[brand]
readonly[brand]:"TokenId"
See
- https://voltaire.tevm.sh/primitives/token-id for TokenId documentation
- https://eips.ethereum.org/EIPS/eip-721 for ERC-721 specification
Since
0.0.0Variables
compare()
Defined in: src/primitives/TokenId/index.ts:22 Compare two TokenId valuesconstcompare: (a,b) =>number=_compare
Parameters
a
TokenIdType
First TokenId
b
TokenIdType
Second TokenId
Returns
number
-1 if a < b, 0 if a === b, 1 if a > b
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Example
constants
Defined in: src/primitives/TokenId/index.ts:26constconstants:object
Type Declaration
MAX
MAX: bigint
Maximum TokenId value (2^256 - 1)
MIN
MIN: bigint
Minimum TokenId value (0)
equals()
Defined in: src/primitives/TokenId/index.ts:21 Check if two TokenId values are equalconstequals: (a,b) =>boolean=_equals
Parameters
a
TokenIdType
First TokenId
b
TokenIdType
Second TokenId
Returns
boolean
true if equal
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Example
ERC721_SELECTORS
Defined in: src/primitives/TokenId/index.ts:32constERC721_SELECTORS:object
Type Declaration
approve
readonlyapprove:"0x095ea7b3"="0x095ea7b3"
balanceOf
readonlybalanceOf:"0x70a08231"="0x70a08231"
getApproved
readonlygetApproved:"0x081812fc"="0x081812fc"
isApprovedForAll
readonlyisApprovedForAll:"0xe985e9c5"="0xe985e9c5"
ownerOf
readonlyownerOf:"0x6352211e"="0x6352211e"
safeTransferFrom
readonlysafeTransferFrom:"0x42842e0e"="0x42842e0e"
setApprovalForAll
readonlysetApprovalForAll:"0xa22cb465"="0xa22cb465"
transferFrom
readonlytransferFrom:"0x23b872dd"="0x23b872dd"
from()
Defined in: src/primitives/TokenId/index.ts:17 Create TokenId from bigint, number, or stringconstfrom: (value) =>TokenIdType=_from
Parameters
value
bigint, number, or decimal/hex stringstring | number | bigint
Returns
TokenIdType
TokenId value
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Throws
If value is out of range or invalidExample
isValid()
Defined in: src/primitives/TokenId/index.ts:23 Check if TokenId is valid (non-zero)constisValid: (tokenId) =>boolean=_isValid
Parameters
tokenId
TokenIdType
TokenId value to check
Returns
boolean
true if valid (non-zero)
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Example
toBigInt()
Defined in: src/primitives/TokenId/index.ts:19 Convert TokenId to bigintconsttoBigInt: (tokenId) =>bigint=_toBigInt
Parameters
tokenId
TokenIdType
TokenId value to convert
Returns
bigint
bigint value
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Example
toHex()
Defined in: src/primitives/TokenId/index.ts:20 Convert TokenId to hex stringconsttoHex: (tokenId) =>string=_toHex
Parameters
tokenId
TokenIdType
TokenId value to convert
Returns
string
Hex string with 0x prefix
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Example
toNumber()
Defined in: src/primitives/TokenId/index.ts:18 Convert TokenId to number (unsafe for large values)consttoNumber: (tokenId) =>number=_toNumber
Parameters
tokenId
TokenIdType
TokenId value to convert
Returns
number
number value
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Throws
If value exceeds Number.MAX_SAFE_INTEGERExample
Functions
_compare()
_compare(Defined in: src/primitives/TokenId/compare.js:17 Compare two TokenId valuesa,b):number
Parameters
a
TokenIdType
First TokenId
b
TokenIdType
Second TokenId
Returns
number
-1 if a < b, 0 if a === b, 1 if a > b
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Example
_equals()
_equals(Defined in: src/primitives/TokenId/equals.js:17 Check if two TokenId values are equala,b):boolean
Parameters
a
TokenIdType
First TokenId
b
TokenIdType
Second TokenId
Returns
boolean
true if equal
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Example
_from()
_from(Defined in: src/primitives/TokenId/from.js:20 Create TokenId from bigint, number, or stringvalue):TokenIdType
Parameters
value
bigint, number, or decimal/hex stringstring | number | bigint
Returns
TokenIdType
TokenId value
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Throws
If value is out of range or invalidExample
_isValid()
_isValid(Defined in: src/primitives/TokenId/isValid.js:17 Check if TokenId is valid (non-zero)tokenId):boolean
Parameters
tokenId
TokenIdType
TokenId value to check
Returns
boolean
true if valid (non-zero)
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Example
_toBigInt()
_toBigInt(Defined in: src/primitives/TokenId/toBigInt.js:15 Convert TokenId to biginttokenId):bigint
Parameters
tokenId
TokenIdType
TokenId value to convert
Returns
bigint
bigint value
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Example
_toHex()
_toHex(Defined in: src/primitives/TokenId/toHex.js:15 Convert TokenId to hex stringtokenId):string
Parameters
tokenId
TokenIdType
TokenId value to convert
Returns
string
Hex string with 0x prefix
See
https://voltaire.tevm.sh/primitives/token-id for TokenId documentationSince
0.0.0Example
_toNumber()
_toNumber(Defined in: src/primitives/TokenId/toNumber.js:16 Convert TokenId to number (unsafe for large values)tokenId):number
Parameters
tokenId
TokenIdType
TokenId value to convert
Returns
number
number value

