evmspec.data package

Submodules

evmspec.data.uints module

This module provides classes to decode and represent unsigned integer types of any byte size, ensuring values adhere to defined minimum and maximum constraints.

Note

While only a few specific classes like uint8, uint64, uint128, and uint256 are explicitly defined, other classes are dynamically generated for byte sizes from 2 to 31, excluding those already defined.

class evmspec.data.uints.uint104

Bases: _UintData

Unsigned 104-bit integer.

Examples

>>> uint104(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint104(20282409603651670423947251286015)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 104
bytes: ClassVar[int] = 13
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 20282409603651670423947251286015
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint112

Bases: _UintData

Unsigned 112-bit integer.

Examples

>>> uint112(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint112(5192296858534827628530496329220095)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 112
bytes: ClassVar[int] = 14
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 5192296858534827628530496329220095
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint120

Bases: _UintData

Unsigned 120-bit integer.

Examples

>>> uint120(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint120(1329227995784915872903807060280344575)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 120
bytes: ClassVar[int] = 15
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 1329227995784915872903807060280344575
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint128[source]

Bases: _UintData

Unsigned 128-bit integer.

Examples

>>> uint128(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint128(340282366920938463463374607431768211455)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 128
bytes: ClassVar[int] = 16
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 340282366920938463463374607431768211455
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint136

Bases: _UintData

Unsigned 136-bit integer.

Examples

>>> uint136(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint136(87112285931760246646623899502532662132735)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 136
bytes: ClassVar[int] = 17
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 87112285931760246646623899502532662132735
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint144

Bases: _UintData

Unsigned 144-bit integer.

Examples

>>> uint144(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint144(22300745198530623141535718272648361505980415)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 144
bytes: ClassVar[int] = 18
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 22300745198530623141535718272648361505980415
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint152

Bases: _UintData

Unsigned 152-bit integer.

Examples

>>> uint152(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint152(5708990770823839524233143877797980545530986495)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 152
bytes: ClassVar[int] = 19
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 5708990770823839524233143877797980545530986495
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint16

Bases: _UintData

Unsigned 16-bit integer.

Examples

>>> uint16(HexBytes('0xFFFF'))
uint16(65535)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 16
bytes: ClassVar[int] = 2
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 65535
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint160

Bases: _UintData

Unsigned 160-bit integer.

Examples

>>> uint160(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint160(1461501637330902918203684832716283019655932542975)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 160
bytes: ClassVar[int] = 20
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 1461501637330902918203684832716283019655932542975
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint168

Bases: _UintData

Unsigned 168-bit integer.

Examples

>>> uint168(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint168(374144419156711147060143317175368453031918731001855)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 168
bytes: ClassVar[int] = 21
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 374144419156711147060143317175368453031918731001855
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint176

Bases: _UintData

Unsigned 176-bit integer.

Examples

>>> uint176(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint176(95780971304118053647396689196894323976171195136475135)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 176
bytes: ClassVar[int] = 22
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 95780971304118053647396689196894323976171195136475135
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint184

Bases: _UintData

Unsigned 184-bit integer.

Examples

>>> uint184(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint184(24519928653854221733733552434404946937899825954937634815)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 184
bytes: ClassVar[int] = 23
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 24519928653854221733733552434404946937899825954937634815
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint192

Bases: _UintData

Unsigned 192-bit integer.

Examples

>>> uint192(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint192(6277101735386680763835789423207666416102355444464034512895)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 192
bytes: ClassVar[int] = 24
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 6277101735386680763835789423207666416102355444464034512895
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint200

Bases: _UintData

Unsigned 200-bit integer.

Examples

>>> uint200(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint200(1606938044258990275541962092341162602522202993782792835301375)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 200
bytes: ClassVar[int] = 25
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 1606938044258990275541962092341162602522202993782792835301375
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint208

Bases: _UintData

Unsigned 208-bit integer.

Examples

>>> uint208(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint208(411376139330301510538742295639337626245683966408394965837152255)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 208
bytes: ClassVar[int] = 26
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 411376139330301510538742295639337626245683966408394965837152255
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint216

Bases: _UintData

Unsigned 216-bit integer.

Examples

>>> uint216(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint216(105312291668557186697918027683670432318895095400549111254310977535)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 216
bytes: ClassVar[int] = 27
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 105312291668557186697918027683670432318895095400549111254310977535
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint224

Bases: _UintData

Unsigned 224-bit integer.

Examples

>>> uint224(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint224(26959946667150639794667015087019630673637144422540572481103610249215)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 224
bytes: ClassVar[int] = 28
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 26959946667150639794667015087019630673637144422540572481103610249215
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint232

Bases: _UintData

Unsigned 232-bit integer.

Examples

>>> uint232(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint232(6901746346790563787434755862277025452451108972170386555162524223799295)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 232
bytes: ClassVar[int] = 29
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 6901746346790563787434755862277025452451108972170386555162524223799295
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint24

Bases: _UintData

Unsigned 24-bit integer.

Examples

>>> uint24(HexBytes('0xFFFFFF'))
uint24(16777215)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 24
bytes: ClassVar[int] = 3
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 16777215
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint240

Bases: _UintData

Unsigned 240-bit integer.

Examples

>>> uint240(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint240(1766847064778384329583297500742918515827483896875618958121606201292619775)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 240
bytes: ClassVar[int] = 30
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 1766847064778384329583297500742918515827483896875618958121606201292619775
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint248

Bases: _UintData

Unsigned 248-bit integer.

Examples

>>> uint248(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint248(452312848583266388373324160190187140051835877600158453279131187530910662655)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 248
bytes: ClassVar[int] = 31
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 452312848583266388373324160190187140051835877600158453279131187530910662655
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint32

Bases: _UintData

Unsigned 32-bit integer.

Examples

>>> uint32(HexBytes('0xFFFFFFFF'))
uint32(4294967295)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 32
bytes: ClassVar[int] = 4
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 4294967295
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint40

Bases: _UintData

Unsigned 40-bit integer.

Examples

>>> uint40(HexBytes('0xFFFFFFFFFF'))
uint40(1099511627775)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 40
bytes: ClassVar[int] = 5
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 1099511627775
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint48

Bases: _UintData

Unsigned 48-bit integer.

Examples

>>> uint48(HexBytes('0xFFFFFFFFFFFF'))
uint48(281474976710655)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 48
bytes: ClassVar[int] = 6
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 281474976710655
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint56

Bases: _UintData

Unsigned 56-bit integer.

Examples

>>> uint56(HexBytes('0xFFFFFFFFFFFFFF'))
uint56(72057594037927935)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 56
bytes: ClassVar[int] = 7
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 72057594037927935
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint64[source]

Bases: _UintData

Unsigned 64-bit integer.

Examples

>>> uint64(HexBytes('0xFFFFFFFFFFFFFFFF'))
uint64(18446744073709551615)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 64
bytes: ClassVar[int] = 8
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 18446744073709551615
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint72

Bases: _UintData

Unsigned 72-bit integer.

Examples

>>> uint72(HexBytes('0xFFFFFFFFFFFFFFFFFF'))
uint72(4722366482869645213695)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 72
bytes: ClassVar[int] = 9
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 4722366482869645213695
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint8[source]

Bases: _UintData

Unsigned 8-bit integer.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 8
bytes: ClassVar[int] = 1
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 255
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint80

Bases: _UintData

Unsigned 80-bit integer.

Examples

>>> uint80(HexBytes('0xFFFFFFFFFFFFFFFFFFFF'))
uint80(1208925819614629174706175)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 80
bytes: ClassVar[int] = 10
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 1208925819614629174706175
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint88

Bases: _UintData

Unsigned 88-bit integer.

Examples

>>> uint88(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFF'))
uint88(309485009821345068724781055)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 88
bytes: ClassVar[int] = 11
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 309485009821345068724781055
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.uints.uint96

Bases: _UintData

Unsigned 96-bit integer.

Examples

>>> uint96(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFF'))
uint96(79228162514264337593543950335)
classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
static __new__(cls, v)

Create a new unsigned integer of the specified type from a hex byte value.

Parameters:

v (HexBytes) – The value to be converted into the unsigned integer type.

Raises:
  • ValueError – If the value is smaller than the minimum value or larger than

  • the maximum value.

Examples

>>> uint8(HexBytes('0x01'))
uint8(1)
>>> uint256(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF'))
uint256(115792089237316195423570985008687907853269984665640564039457584007913129639935)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

bits: ClassVar[int] = 96
bytes: ClassVar[int] = 12
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: ClassVar[int] = 79228162514264337593543950335
min_value: Final = 0
numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

Module contents

class evmspec.data.Address[source]

Bases: str

Represents an Ethereum address in its EIP-55 checksum format.

This class ensures that any Ethereum address is stored in its checksummed format, as defined by EIP-55. It uses a custom Cython implementation for the checksum conversion to optimize performance.

Examples

>>> addr = Address("0x52908400098527886E0F7030069857D2E4169EE7")
>>> print(addr)
0x52908400098527886E0F7030069857D2E4169EE7

See also

  • cchecksum.to_checksum_address: Function used for checksum conversion.

classmethod checksum(address)[source]

Returns the checksummed version of the address.

This function takes a hex address and returns it in the checksummed format as defined by EIP-55. It uses a custom Cython implementation for the checksum conversion to optimize performance.

Parameters:

address (str) – A string representing the Ethereum address.

Returns:

The checksummed Ethereum address.

Return type:

Self

Examples

>>> Address.checksum("0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe")
Address('0xDe0B295669a9FD93d5F28D9Ec85E40f4cb697BAe')

See also

  • cchecksum.to_checksum_address: Function used for checksum conversion.

static __new__(cls, address)
Parameters:
  • cls (Type[__T])

  • address (AnyAddress)

Return type:

__T

static maketrans()

Return a translation table usable for str.translate().

If there is only one argument, it must be a dictionary mapping Unicode ordinals (integers) or characters to Unicode ordinals, strings or None. Character keys will be then converted to ordinals. If there are two arguments, they must be strings of equal length, and in the resulting dictionary, each character in x will be mapped to the character at the same position in y. If there is a third argument, it must be a string, whose characters will be mapped to None in the result.

capitalize()

Return a capitalized version of the string.

More specifically, make the first character have upper case and the rest lower case.

casefold()

Return a version of the string suitable for caseless comparisons.

center(width, fillchar=' ', /)

Return a centered string of length width.

Padding is done using the specified fill character (default is a space).

count()

Return the number of non-overlapping occurrences of substring sub in string S[start:end].

Optional arguments start and end are interpreted as in slice notation.

encode(encoding='utf-8', errors='strict')

Encode the string using the codec registered for encoding.

encoding

The encoding in which to encode the string.

errors

The error handling scheme to use for encoding errors. The default is ‘strict’ meaning that encoding errors raise a UnicodeEncodeError. Other possible values are ‘ignore’, ‘replace’ and ‘xmlcharrefreplace’ as well as any other name registered with codecs.register_error that can handle UnicodeEncodeErrors.

endswith()

Return True if the string ends with the specified suffix, False otherwise.

suffix

A string or a tuple of strings to try.

start

Optional start position. Default: start of the string.

end

Optional stop position. Default: end of the string.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find()

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].

Optional arguments start and end are interpreted as in slice notation. Return -1 on failure.

format(*args, **kwargs)

Return a formatted version of the string, using substitutions from args and kwargs. The substitutions are identified by braces (‘{’ and ‘}’).

format_map(mapping, /)

Return a formatted version of the string, using substitutions from mapping. The substitutions are identified by braces (‘{’ and ‘}’).

index()

Return the lowest index in S where substring sub is found, such that sub is contained within S[start:end].

Optional arguments start and end are interpreted as in slice notation. Raises ValueError when the substring is not found.

isalnum()

Return True if the string is an alpha-numeric string, False otherwise.

A string is alpha-numeric if all characters in the string are alpha-numeric and there is at least one character in the string.

isalpha()

Return True if the string is an alphabetic string, False otherwise.

A string is alphabetic if all characters in the string are alphabetic and there is at least one character in the string.

isascii()

Return True if all characters in the string are ASCII, False otherwise.

ASCII characters have code points in the range U+0000-U+007F. Empty string is ASCII too.

isdecimal()

Return True if the string is a decimal string, False otherwise.

A string is a decimal string if all characters in the string are decimal and there is at least one character in the string.

isdigit()

Return True if the string is a digit string, False otherwise.

A string is a digit string if all characters in the string are digits and there is at least one character in the string.

isidentifier()

Return True if the string is a valid Python identifier, False otherwise.

Call keyword.iskeyword(s) to test whether string s is a reserved identifier, such as “def” or “class”.

islower()

Return True if the string is a lowercase string, False otherwise.

A string is lowercase if all cased characters in the string are lowercase and there is at least one cased character in the string.

isnumeric()

Return True if the string is a numeric string, False otherwise.

A string is numeric if all characters in the string are numeric and there is at least one character in the string.

isprintable()

Return True if all characters in the string are printable, False otherwise.

A character is printable if repr() may use it in its output.

isspace()

Return True if the string is a whitespace string, False otherwise.

A string is whitespace if all characters in the string are whitespace and there is at least one character in the string.

istitle()

Return True if the string is a title-cased string, False otherwise.

In a title-cased string, upper- and title-case characters may only follow uncased characters and lowercase characters only cased ones.

isupper()

Return True if the string is an uppercase string, False otherwise.

A string is uppercase if all cased characters in the string are uppercase and there is at least one cased character in the string.

join(iterable, /)

Concatenate any number of strings.

The string whose method is called is inserted in between each given string. The result is returned as a new string.

Example: ‘.’.join([‘ab’, ‘pq’, ‘rs’]) -> ‘ab.pq.rs’

ljust(width, fillchar=' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character (default is a space).

lower()

Return a copy of the string converted to lowercase.

lstrip(chars=None, /)

Return a copy of the string with leading whitespace removed.

If chars is given and not None, remove characters in chars instead.

partition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original string and two empty strings.

removeprefix(prefix, /)

Return a str with the given prefix string removed if present.

If the string starts with the prefix string, return string[len(prefix):]. Otherwise, return a copy of the original string.

removesuffix(suffix, /)

Return a str with the given suffix string removed if present.

If the string ends with the suffix string and that suffix is not empty, return string[:-len(suffix)]. Otherwise, return a copy of the original string.

replace(old, new, /, count=-1)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind()

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].

Optional arguments start and end are interpreted as in slice notation. Return -1 on failure.

rindex()

Return the highest index in S where substring sub is found, such that sub is contained within S[start:end].

Optional arguments start and end are interpreted as in slice notation. Raises ValueError when the substring is not found.

rjust(width, fillchar=' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character (default is a space).

rpartition(sep, /)

Partition the string into three parts using the given separator.

This will search for the separator in the string, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty strings and the original string.

rsplit(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the end of the string and works to the front.

rstrip(chars=None, /)

Return a copy of the string with trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

split(sep=None, maxsplit=-1)

Return a list of the substrings in the string, using sep as the separator string.

sep

The separator used to split the string.

When set to None (the default value), will split on any whitespace character (including n r t f and spaces) and will discard empty strings from the result.

maxsplit

Maximum number of splits. -1 (the default value) means no limit.

Splitting starts at the front of the string and works to the end.

Note, str.split() is mainly useful for data that has been intentionally delimited. With natural text that includes punctuation, consider using the regular expression module.

splitlines(keepends=False)

Return a list of the lines in the string, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith()

Return True if the string starts with the specified prefix, False otherwise.

prefix

A string or a tuple of strings to try.

start

Optional start position. Default: start of the string.

end

Optional stop position. Default: end of the string.

strip(chars=None, /)

Return a copy of the string with leading and trailing whitespace removed.

If chars is given and not None, remove characters in chars instead.

swapcase()

Convert uppercase characters to lowercase and lowercase characters to uppercase.

title()

Return a version of the string where each word is titlecased.

More specifically, words start with uppercased characters and all remaining cased characters have lower case.

translate(table, /)

Replace each character in the string using the given translation table.

table

Translation table, which must be a mapping of Unicode ordinals to Unicode ordinals, strings, or None.

The table must implement lookup/indexing via __getitem__, for instance a dictionary or list. If this operation raises LookupError, the character is left untouched. Characters mapped to None are deleted.

upper()

Return a copy of the string converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The string is never truncated.

class evmspec.data.BlockHash[source]

Bases: HexBytes32

static __new__(cls, v)
Parameters:
Return type:

__T

static maketrans(frm, to, /)

Return a translation table usable for the bytes or bytearray translate method.

The returned table will be one where each byte in frm is mapped to the byte at the same position in to.

The bytes objects frm and to must be of the same length.

capitalize() copy of B

Return a copy of B with only its first character capitalized (ASCII) and the rest lower-cased.

center(width, fillchar=b' ', /)

Return a centered string of length width.

Padding is done using the specified fill character.

count()

Return the number of non-overlapping occurrences of subsection ‘sub’ in bytes B[start:end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

decode(encoding='utf-8', errors='strict')

Decode the bytes using the codec registered for encoding.

encoding

The encoding with which to decode the bytes.

errors

The error handling scheme to use for the handling of decoding errors. The default is ‘strict’ meaning that decoding errors raise a UnicodeDecodeError. Other possible values are ‘ignore’ and ‘replace’ as well as any other name registered with codecs.register_error that can handle UnicodeDecodeErrors.

endswith()

Return True if the bytes ends with the specified suffix, False otherwise.

suffix

A bytes or a tuple of bytes to try.

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find()

Return the lowest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Return -1 on failure.

classmethod fromhex(string, /)

Create a bytes object from a string of hexadecimal numbers.

Spaces between two numbers are accepted. Example: bytes.fromhex(‘B9 01EF’) -> b’\xb9\x01\xef’.

hex()

Output hex-encoded bytes, with an “0x” prefix.

Everything following the “0x” is output exactly like bytes.hex().

Return type:

str

index()

Return the lowest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Raise ValueError if the subsection is not found.

isalnum() bool

Return True if all characters in B are alphanumeric and there is at least one character in B, False otherwise.

isalpha() bool

Return True if all characters in B are alphabetic and there is at least one character in B, False otherwise.

isascii() bool

Return True if B is empty or all characters in B are ASCII, False otherwise.

isdigit() bool

Return True if all characters in B are digits and there is at least one character in B, False otherwise.

islower() bool

Return True if all cased characters in B are lowercase and there is at least one cased character in B, False otherwise.

isspace() bool

Return True if all characters in B are whitespace and there is at least one character in B, False otherwise.

istitle() bool

Return True if B is a titlecased string and there is at least one character in B, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise.

isupper() bool

Return True if all cased characters in B are uppercase and there is at least one cased character in B, False otherwise.

join(iterable_of_bytes, /)

Concatenate any number of bytes objects.

The bytes whose method is called is inserted in between each pair.

The result is returned as a new bytes object.

Example: b’.’.join([b’ab’, b’pq’, b’rs’]) -> b’ab.pq.rs’.

ljust(width, fillchar=b' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character.

lower() copy of B

Return a copy of B with all ASCII characters converted to lowercase.

lstrip(bytes=None, /)

Strip leading bytes contained in the argument.

If the argument is omitted or None, strip leading ASCII whitespace.

partition(sep, /)

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original bytes object and two empty bytes objects.

removeprefix(prefix, /)

Return a bytes object with the given prefix string removed if present.

If the bytes starts with the prefix string, return bytes[len(prefix):]. Otherwise, return a copy of the original bytes.

removesuffix(suffix, /)

Return a bytes object with the given suffix string removed if present.

If the bytes ends with the suffix string and that suffix is not empty, return bytes[:-len(prefix)]. Otherwise, return a copy of the original bytes.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind()

Return the highest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Return -1 on failure.

rindex()

Return the highest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Raise ValueError if the subsection is not found.

rjust(width, fillchar=b' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character.

rpartition(sep, /)

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty bytes objects and the original bytes object.

rsplit(sep=None, maxsplit=-1)

Return a list of the sections in the bytes, using sep as the delimiter.

sep

The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

Splitting is done starting at the end of the bytes and working to the front.

rstrip(bytes=None, /)

Strip trailing bytes contained in the argument.

If the argument is omitted or None, strip trailing ASCII whitespace.

split(sep=None, maxsplit=-1)

Return a list of the sections in the bytes, using sep as the delimiter.

sep

The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

splitlines(keepends=False)

Return a list of the lines in the bytes, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith()

Return True if the bytes starts with the specified prefix, False otherwise.

prefix

A bytes or a tuple of bytes to try.

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

strip()

Returns self.hex() with leading zeroes removed.

Examples

>>> hb = HexBytes32("0x0000000000000000000000000000000000000000000000000000000000001234")
>>> hb.strip()
'1234'
Return type:

str

swapcase() copy of B

Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.

title() copy of B

Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.

translate(table, /, delete=b'')

Return a copy with each character mapped by the given translation table.

table

Translation table, which must be a bytes object of length 256.

All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.

upper() copy of B

Return a copy of B with all ASCII characters converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The original string is never truncated.

to_0x_hex
class evmspec.data.BlockNumber[source]

Bases: uint

classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
classmethod __new__(*args, **kwargs)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.ChainId[source]

Bases: IntId

Represents a unique identifier for an Ethereum chain.

It is used to distinguish between different blockchain networks. This class does not support any arithmetic operations.

See also

  • IntId

classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
classmethod __new__(*args, **kwargs)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.HexBytes32[source]

Bases: HexBytes

static __new__(cls, v)
Parameters:
Return type:

__T

static maketrans(frm, to, /)

Return a translation table usable for the bytes or bytearray translate method.

The returned table will be one where each byte in frm is mapped to the byte at the same position in to.

The bytes objects frm and to must be of the same length.

capitalize() copy of B

Return a copy of B with only its first character capitalized (ASCII) and the rest lower-cased.

center(width, fillchar=b' ', /)

Return a centered string of length width.

Padding is done using the specified fill character.

count()

Return the number of non-overlapping occurrences of subsection ‘sub’ in bytes B[start:end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

decode(encoding='utf-8', errors='strict')

Decode the bytes using the codec registered for encoding.

encoding

The encoding with which to decode the bytes.

errors

The error handling scheme to use for the handling of decoding errors. The default is ‘strict’ meaning that decoding errors raise a UnicodeDecodeError. Other possible values are ‘ignore’ and ‘replace’ as well as any other name registered with codecs.register_error that can handle UnicodeDecodeErrors.

endswith()

Return True if the bytes ends with the specified suffix, False otherwise.

suffix

A bytes or a tuple of bytes to try.

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find()

Return the lowest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Return -1 on failure.

classmethod fromhex(string, /)

Create a bytes object from a string of hexadecimal numbers.

Spaces between two numbers are accepted. Example: bytes.fromhex(‘B9 01EF’) -> b’\xb9\x01\xef’.

hex()[source]

Output hex-encoded bytes, with an “0x” prefix.

Everything following the “0x” is output exactly like bytes.hex().

Return type:

str

index()

Return the lowest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Raise ValueError if the subsection is not found.

isalnum() bool

Return True if all characters in B are alphanumeric and there is at least one character in B, False otherwise.

isalpha() bool

Return True if all characters in B are alphabetic and there is at least one character in B, False otherwise.

isascii() bool

Return True if B is empty or all characters in B are ASCII, False otherwise.

isdigit() bool

Return True if all characters in B are digits and there is at least one character in B, False otherwise.

islower() bool

Return True if all cased characters in B are lowercase and there is at least one cased character in B, False otherwise.

isspace() bool

Return True if all characters in B are whitespace and there is at least one character in B, False otherwise.

istitle() bool

Return True if B is a titlecased string and there is at least one character in B, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise.

isupper() bool

Return True if all cased characters in B are uppercase and there is at least one cased character in B, False otherwise.

join(iterable_of_bytes, /)

Concatenate any number of bytes objects.

The bytes whose method is called is inserted in between each pair.

The result is returned as a new bytes object.

Example: b’.’.join([b’ab’, b’pq’, b’rs’]) -> b’ab.pq.rs’.

ljust(width, fillchar=b' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character.

lower() copy of B

Return a copy of B with all ASCII characters converted to lowercase.

lstrip(bytes=None, /)

Strip leading bytes contained in the argument.

If the argument is omitted or None, strip leading ASCII whitespace.

partition(sep, /)

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original bytes object and two empty bytes objects.

removeprefix(prefix, /)

Return a bytes object with the given prefix string removed if present.

If the bytes starts with the prefix string, return bytes[len(prefix):]. Otherwise, return a copy of the original bytes.

removesuffix(suffix, /)

Return a bytes object with the given suffix string removed if present.

If the bytes ends with the suffix string and that suffix is not empty, return bytes[:-len(prefix)]. Otherwise, return a copy of the original bytes.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind()

Return the highest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Return -1 on failure.

rindex()

Return the highest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Raise ValueError if the subsection is not found.

rjust(width, fillchar=b' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character.

rpartition(sep, /)

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty bytes objects and the original bytes object.

rsplit(sep=None, maxsplit=-1)

Return a list of the sections in the bytes, using sep as the delimiter.

sep

The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

Splitting is done starting at the end of the bytes and working to the front.

rstrip(bytes=None, /)

Strip trailing bytes contained in the argument.

If the argument is omitted or None, strip trailing ASCII whitespace.

split(sep=None, maxsplit=-1)

Return a list of the sections in the bytes, using sep as the delimiter.

sep

The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

splitlines(keepends=False)

Return a list of the lines in the bytes, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith()

Return True if the bytes starts with the specified prefix, False otherwise.

prefix

A bytes or a tuple of bytes to try.

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

strip()[source]

Returns self.hex() with leading zeroes removed.

Examples

>>> hb = HexBytes32("0x0000000000000000000000000000000000000000000000000000000000001234")
>>> hb.strip()
'1234'
Return type:

str

swapcase() copy of B

Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.

title() copy of B

Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.

translate(table, /, delete=b'')

Return a copy with each character mapped by the given translation table.

table

Translation table, which must be a bytes object of length 256.

All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.

upper() copy of B

Return a copy of B with all ASCII characters converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The original string is never truncated.

to_0x_hex
class evmspec.data.LogIndex[source]

Bases: IntId

Represents the index of a log entry within a transaction.

It is used to identify the log’s position within the transaction. This class does not support any arithmetic operations.

See also

  • IntId

classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
classmethod __new__(*args, **kwargs)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.Nonce[source]

Bases: uint

classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
classmethod __new__(*args, **kwargs)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.TransactionHash[source]

Bases: HexBytes32

static __new__(cls, v)
Parameters:
Return type:

__T

static maketrans(frm, to, /)

Return a translation table usable for the bytes or bytearray translate method.

The returned table will be one where each byte in frm is mapped to the byte at the same position in to.

The bytes objects frm and to must be of the same length.

capitalize() copy of B

Return a copy of B with only its first character capitalized (ASCII) and the rest lower-cased.

center(width, fillchar=b' ', /)

Return a centered string of length width.

Padding is done using the specified fill character.

count()

Return the number of non-overlapping occurrences of subsection ‘sub’ in bytes B[start:end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

decode(encoding='utf-8', errors='strict')

Decode the bytes using the codec registered for encoding.

encoding

The encoding with which to decode the bytes.

errors

The error handling scheme to use for the handling of decoding errors. The default is ‘strict’ meaning that decoding errors raise a UnicodeDecodeError. Other possible values are ‘ignore’ and ‘replace’ as well as any other name registered with codecs.register_error that can handle UnicodeDecodeErrors.

endswith()

Return True if the bytes ends with the specified suffix, False otherwise.

suffix

A bytes or a tuple of bytes to try.

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

expandtabs(tabsize=8)

Return a copy where all tab characters are expanded using spaces.

If tabsize is not given, a tab size of 8 characters is assumed.

find()

Return the lowest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Return -1 on failure.

classmethod fromhex(string, /)

Create a bytes object from a string of hexadecimal numbers.

Spaces between two numbers are accepted. Example: bytes.fromhex(‘B9 01EF’) -> b’\xb9\x01\xef’.

hex()

Output hex-encoded bytes, with an “0x” prefix.

Everything following the “0x” is output exactly like bytes.hex().

Return type:

str

index()

Return the lowest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Raise ValueError if the subsection is not found.

isalnum() bool

Return True if all characters in B are alphanumeric and there is at least one character in B, False otherwise.

isalpha() bool

Return True if all characters in B are alphabetic and there is at least one character in B, False otherwise.

isascii() bool

Return True if B is empty or all characters in B are ASCII, False otherwise.

isdigit() bool

Return True if all characters in B are digits and there is at least one character in B, False otherwise.

islower() bool

Return True if all cased characters in B are lowercase and there is at least one cased character in B, False otherwise.

isspace() bool

Return True if all characters in B are whitespace and there is at least one character in B, False otherwise.

istitle() bool

Return True if B is a titlecased string and there is at least one character in B, i.e. uppercase characters may only follow uncased characters and lowercase characters only cased ones. Return False otherwise.

isupper() bool

Return True if all cased characters in B are uppercase and there is at least one cased character in B, False otherwise.

join(iterable_of_bytes, /)

Concatenate any number of bytes objects.

The bytes whose method is called is inserted in between each pair.

The result is returned as a new bytes object.

Example: b’.’.join([b’ab’, b’pq’, b’rs’]) -> b’ab.pq.rs’.

ljust(width, fillchar=b' ', /)

Return a left-justified string of length width.

Padding is done using the specified fill character.

lower() copy of B

Return a copy of B with all ASCII characters converted to lowercase.

lstrip(bytes=None, /)

Strip leading bytes contained in the argument.

If the argument is omitted or None, strip leading ASCII whitespace.

partition(sep, /)

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing the original bytes object and two empty bytes objects.

removeprefix(prefix, /)

Return a bytes object with the given prefix string removed if present.

If the bytes starts with the prefix string, return bytes[len(prefix):]. Otherwise, return a copy of the original bytes.

removesuffix(suffix, /)

Return a bytes object with the given suffix string removed if present.

If the bytes ends with the suffix string and that suffix is not empty, return bytes[:-len(prefix)]. Otherwise, return a copy of the original bytes.

replace(old, new, count=-1, /)

Return a copy with all occurrences of substring old replaced by new.

count

Maximum number of occurrences to replace. -1 (the default value) means replace all occurrences.

If the optional argument count is given, only the first count occurrences are replaced.

rfind()

Return the highest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Return -1 on failure.

rindex()

Return the highest index in B where subsection ‘sub’ is found, such that ‘sub’ is contained within B[start,end].

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

Raise ValueError if the subsection is not found.

rjust(width, fillchar=b' ', /)

Return a right-justified string of length width.

Padding is done using the specified fill character.

rpartition(sep, /)

Partition the bytes into three parts using the given separator.

This will search for the separator sep in the bytes, starting at the end. If the separator is found, returns a 3-tuple containing the part before the separator, the separator itself, and the part after it.

If the separator is not found, returns a 3-tuple containing two empty bytes objects and the original bytes object.

rsplit(sep=None, maxsplit=-1)

Return a list of the sections in the bytes, using sep as the delimiter.

sep

The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

Splitting is done starting at the end of the bytes and working to the front.

rstrip(bytes=None, /)

Strip trailing bytes contained in the argument.

If the argument is omitted or None, strip trailing ASCII whitespace.

split(sep=None, maxsplit=-1)

Return a list of the sections in the bytes, using sep as the delimiter.

sep

The delimiter according which to split the bytes. None (the default value) means split on ASCII whitespace characters (space, tab, return, newline, formfeed, vertical tab).

maxsplit

Maximum number of splits to do. -1 (the default value) means no limit.

splitlines(keepends=False)

Return a list of the lines in the bytes, breaking at line boundaries.

Line breaks are not included in the resulting list unless keepends is given and true.

startswith()

Return True if the bytes starts with the specified prefix, False otherwise.

prefix

A bytes or a tuple of bytes to try.

start

Optional start position. Default: start of the bytes.

end

Optional stop position. Default: end of the bytes.

strip()

Returns self.hex() with leading zeroes removed.

Examples

>>> hb = HexBytes32("0x0000000000000000000000000000000000000000000000000000000000001234")
>>> hb.strip()
'1234'
Return type:

str

swapcase() copy of B

Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.

title() copy of B

Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.

translate(table, /, delete=b'')

Return a copy with each character mapped by the given translation table.

table

Translation table, which must be a bytes object of length 256.

All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.

upper() copy of B

Return a copy of B with all ASCII characters converted to uppercase.

zfill(width, /)

Pad a numeric string with zeros on the left, to fill a field of the given width.

The original string is never truncated.

to_0x_hex
class evmspec.data.TransactionIndex[source]

Bases: IntId

Represents the index of a transaction within a block.

It is used to identify the transaction’s position in the block. This class does not support any arithmetic operations.

See also

  • IntId

classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
classmethod __new__(*args, **kwargs)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.UnixTimestamp[source]

Bases: uint

classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
classmethod __new__(*args, **kwargs)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

property datetime: datetime[source]

Converts the Unix timestamp to a datetime object in UTC.

Returns:

A datetime object representing the UTC date and time.

Examples

>>> timestamp = UnixTimestamp(1638316800)
>>> timestamp.datetime
datetime.datetime(2021, 12, 1, 0, 0, tzinfo=datetime.timezone.utc)
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

class evmspec.data.Wei[source]

Bases: uint

classmethod fromhex(hexstr)

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
classmethod __new__(*args, **kwargs)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number

property scaled: Decimal[source]

Returns the scaled decimal representation of Wei.

Calculation:

The value in Wei divided by 10**18 to convert to Ether.

Examples

>>> wei_value = Wei(1000000000000000000)
>>> wei_value.scaled
Decimal('1')
class evmspec.data.uint[source]

Bases: int

Represents an unsigned integer with additional utility methods for hexadecimal conversion and representation.

Examples

>>> num = uint.fromhex("0x1a")
>>> print(num)
uint(26)

See also

classmethod fromhex(hexstr)[source]

Converts a hexadecimal string to a uint.

Parameters:

hexstr (str) – A string representing a hexadecimal number.

Returns:

A uint object representing the integer value of the hexadecimal string.

Return type:

Self

Examples

>>> uint.fromhex("0x1a")
uint(26)
classmethod __new__(*args, **kwargs)
as_integer_ratio()

Return a pair of integers, whose ratio is equal to the original int.

The ratio is in lowest terms and has a positive denominator.

>>> (10).as_integer_ratio()
(10, 1)
>>> (-10).as_integer_ratio()
(-10, 1)
>>> (0).as_integer_ratio()
(0, 1)
bit_count()

Number of ones in the binary representation of the absolute value of self.

Also known as the population count.

>>> bin(13)
'0b1101'
>>> (13).bit_count()
3
bit_length()

Number of bits necessary to represent self in binary.

>>> bin(37)
'0b100101'
>>> (37).bit_length()
6
conjugate()

Returns self, the complex conjugate of any int.

classmethod from_bytes(bytes, byteorder='big', *, signed=False)

Return the integer represented by the given array of bytes.

bytes

Holds the array of bytes to convert. The argument must either support the buffer protocol or be an iterable object producing bytes. Bytes and bytearray are examples of built-in objects that support the buffer protocol.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Indicates whether two’s complement is used to represent the integer.

is_integer()

Returns True. Exists for duck type compatibility with float.is_integer.

to_bytes(length=1, byteorder='big', *, signed=False)

Return an array of bytes representing an integer.

length

Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1.

byteorder

The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use sys.byteorder as the byte order value. Default is to use ‘big’.

signed

Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.

denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

numerator

the numerator of a rational number in lowest terms

real

the real part of a complex number