uint — UInt160 and UInt256 data structures

The UInt classes are bytearray like classes heavily used through the NEO system. See Complex data types.

class neo3.core.types.uint.UInt160(data)

Bases: neo3.core.types.uint._UIntBase

Initialize an instance.

Parameters

data (bytes) – hex escaped bytearray.

deserialize(reader)

Deserialize the object from a binary stream.

Parameters

reader (BinaryReader) – instance.

Return type

None

classmethod deserialize_from_bytes(data)

Parse data into an object instance.

Parameters

data (bytes) – hex escaped bytes.

Raises

ValueError – if the length of the supplied bytearray is insufficient for the type.

Return type

UInt160

classmethod from_string(value)

Try to parse a string into an instance.

Note

NEO’s string representation is in reverse byte order from the internal bytearray.

Parameters

value (str) – accepts the same input as bytearray.fromhex().

Raises

ValueError – if the length of the supplied string does not match.

Return type

UInt160

serialize(writer)

Serialize the object into a binary stream.

Parameters

writer (BinaryWriter) – instance.

Return type

None

to_array()

Return an array of bytes representing the UInt

Returns:

Return type

bytes

classmethod zero()
Return type

UInt160

Returns

An instance initialized to zero.

class neo3.core.types.uint.UInt256(data)

Bases: neo3.core.types.uint._UIntBase

Initialize an instance.

Parameters

data (bytes) – hex escaped bytearray.

deserialize(reader)

Deserialize the object from a binary stream.

Parameters

reader (BinaryReader) – instance.

Return type

None

classmethod deserialize_from_bytes(data)

Parse data into an object instance.

Parameters

data (bytes) – hex escaped bytes.

Raises

ValueError – if the length of the supplied bytearray is insufficient for the type.

Return type

UInt256

classmethod from_string(value)

Try to parse a string into an instance.

Note

NEO’s string representation is in reverse byte order from the internal bytearray.

Parameters

value (str) – accepts the same input as bytearray.fromhex().

Raises

ValueError – if the length of the supplied string does not match.

Return type

UInt256

serialize(writer)

Serialize the object into a binary stream.

Parameters

writer (BinaryWriter) – instance.

Return type

None

to_array()

Return an array of bytes representing the UInt

Returns:

Return type

bytes

classmethod zero()
Return type

UInt256

Returns

An instance initialized to zero.