TokenId¶
- class blsct.TokenId(obj: Any = None)¶
Represents a token ID. A token ID consists of two parameters: token and subid, both of which are optional. When omitted, default values are used instead of random values.
>>> from blsct import TokenId >>> TokenId() TokenId(000000000000000...0000000ffffffffffffffff) >>> TokenId.from_token(123) TokenId(7b0000000000000...0000000ffffffffffffffff) >>> token_id = TokenId.from_token_and_subid(123, 456) >>> token_id.token() 123 >>> token_id.subid() 456 >>> ser = token_id.serialize() >>> deser = TokenId.deserialize(ser) >>> ser == deser.serialize() True
- classmethod deserialize(hex: str) Self¶
Deserialize the TokenId from a hexadecimal string
- classmethod from_token(token: int) Self¶
Generate a token ID from a given token.
- classmethod from_token_and_subid(token: int, subid: int) Self¶
Generate a token ID from a given token and subid.
- serialize() str¶
Serialize the TokenId to a hexadecimal string
- subid() int¶
Get the subid from the token ID.
- token() int¶
Get the token from the token ID.