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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 104
bytes: int = 13
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 20282409603651670423947251286015
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 112
bytes: int = 14
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 5192296858534827628530496329220095
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 120
bytes: int = 15
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 1329227995784915872903807060280344575
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 128
bytes: int = 16
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 340282366920938463463374607431768211455
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 136
bytes: int = 17
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 87112285931760246646623899502532662132735
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 144
bytes: int = 18
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 22300745198530623141535718272648361505980415
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 152
bytes: int = 19
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 5708990770823839524233143877797980545530986495
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 16
bytes: int = 2
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 65535
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 160
bytes: int = 20
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 1461501637330902918203684832716283019655932542975
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 168
bytes: int = 21
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 374144419156711147060143317175368453031918731001855
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 176
bytes: int = 22
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 95780971304118053647396689196894323976171195136475135
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 184
bytes: int = 23
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 24519928653854221733733552434404946937899825954937634815
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 192
bytes: int = 24
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 6277101735386680763835789423207666416102355444464034512895
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 200
bytes: int = 25
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 1606938044258990275541962092341162602522202993782792835301375
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 208
bytes: int = 26
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 411376139330301510538742295639337626245683966408394965837152255
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 216
bytes: int = 27
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 105312291668557186697918027683670432318895095400549111254310977535
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 224
bytes: int = 28
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 26959946667150639794667015087019630673637144422540572481103610249215
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 232
bytes: int = 29
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 6901746346790563787434755862277025452451108972170386555162524223799295
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 24
bytes: int = 3
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 16777215
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 240
bytes: int = 30
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 1766847064778384329583297500742918515827483896875618958121606201292619775
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 248
bytes: int = 31
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 452312848583266388373324160190187140051835877600158453279131187530910662655
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 32
bytes: int = 4
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 4294967295
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 40
bytes: int = 5
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 1099511627775
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 48
bytes: int = 6
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 281474976710655
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 56
bytes: int = 7
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 72057594037927935
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 64
bytes: int = 8
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 18446744073709551615
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 72
bytes: int = 9
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 4722366482869645213695
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 8
bytes: int = 1
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 255
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 80
bytes: int = 10
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 1208925819614629174706175
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 88
bytes: int = 11
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 309485009821345068724781055
min_value = 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)
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 integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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: int = 96
bytes: int = 12
denominator

the denominator of a rational number in lowest terms

imag

the imaginary part of a complex number

max_value: int = 79228162514264337593543950335
min_value = 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.

static __new__(cls, address)[source]

Creates a new Address instance with checksum validation.

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:

An Address object with a checksummed address.

Examples

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

See also

  • cchecksum.to_checksum_address: Function used for checksum conversion.

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).

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.

count(sub[, start[, end]]) int

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(suffix[, start[, end]]) bool

Return True if S ends with the specified suffix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. suffix can also be a tuple of strings to try.

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(sub[, start[, end]]) int

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) str

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

format_map(mapping) str

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

index(sub[, start[, end]]) int

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 the string is printable, False otherwise.

A string is printable if all of its characters are considered printable in repr() or if it is empty.

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.

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.

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(sub[, start[, end]]) int

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(sub[, start[, end]]) int

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 (starting from the left). -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 (starting from the left). -1 (the default value) means no limit.

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(prefix[, start[, end]]) bool

Return True if S starts with the specified prefix, False otherwise. With optional start, test S beginning at that position. With optional end, stop comparing S at that position. prefix can also be a tuple of strings to try.

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)

Create a new HexBytes32 object.

Parameters:

v – A value that can be converted to HexBytes32.

Returns:

A HexBytes32 object.

Raises:

ValueError – If the string representation is not the correct length.

Examples

>>> HexBytes32("0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef")
HexBytes32(0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef)
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(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of subsection sub in bytes B[start:end]. Optional arguments start and end are interpreted as in slice notation.

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(suffix[, start[, end]]) bool

Return True if B ends with the specified suffix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. suffix can also be a tuple of bytes to try.

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(sub[, start[, end]]) int

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

fromhex()

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()

Create a string of hexadecimal numbers from a bytes object.

sep

An optional single character or byte to separate hex bytes.

bytes_per_sep

How many bytes between separators. Positive values count from the right, negative values count from the left.

Example: >>> value = b’xb9x01xef’ >>> value.hex() ‘b901ef’ >>> value.hex(‘:’) ‘b9:01:ef’ >>> value.hex(‘:’, 2) ‘b9:01ef’ >>> value.hex(‘:’, -2) ‘b901:ef’

index(sub[, start[, end]]) int

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when 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.

static maketrans(frm, to, /)

Return a translation table useable 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.

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(sub[, start[, end]]) int

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raise ValueError when 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(prefix[, start[, end]]) bool

Return True if B starts with the specified prefix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. prefix can also be a tuple of bytes to try.

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.

to_0x_hex()

Convert the bytes to a 0x-prefixed hex string

Return type:

str

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.

class evmspec.data.BlockNumber[source]

Bases: uint

__new__(**kwargs)
as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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

__new__(**kwargs)
as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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)[source]

Create a new HexBytes32 object.

Parameters:

v – A value that can be converted to HexBytes32.

Returns:

A HexBytes32 object.

Raises:

ValueError – If the string representation is not the correct length.

Examples

>>> HexBytes32("0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef")
HexBytes32(0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef)
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(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of subsection sub in bytes B[start:end]. Optional arguments start and end are interpreted as in slice notation.

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(suffix[, start[, end]]) bool

Return True if B ends with the specified suffix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. suffix can also be a tuple of bytes to try.

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(sub[, start[, end]]) int

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

fromhex()

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()

Create a string of hexadecimal numbers from a bytes object.

sep

An optional single character or byte to separate hex bytes.

bytes_per_sep

How many bytes between separators. Positive values count from the right, negative values count from the left.

Example: >>> value = b’xb9x01xef’ >>> value.hex() ‘b901ef’ >>> value.hex(‘:’) ‘b9:01:ef’ >>> value.hex(‘:’, 2) ‘b9:01ef’ >>> value.hex(‘:’, -2) ‘b901:ef’

index(sub[, start[, end]]) int

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when 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.

static maketrans(frm, to, /)

Return a translation table useable 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.

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(sub[, start[, end]]) int

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raise ValueError when 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(prefix[, start[, end]]) bool

Return True if B starts with the specified prefix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. prefix can also be a tuple of bytes to try.

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.

to_0x_hex()

Convert the bytes to a 0x-prefixed hex string

Return type:

str

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.

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

__new__(**kwargs)
as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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

__new__(**kwargs)
as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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)

Create a new HexBytes32 object.

Parameters:

v – A value that can be converted to HexBytes32.

Returns:

A HexBytes32 object.

Raises:

ValueError – If the string representation is not the correct length.

Examples

>>> HexBytes32("0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef")
HexBytes32(0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef)
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(sub[, start[, end]]) int

Return the number of non-overlapping occurrences of subsection sub in bytes B[start:end]. Optional arguments start and end are interpreted as in slice notation.

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(suffix[, start[, end]]) bool

Return True if B ends with the specified suffix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. suffix can also be a tuple of bytes to try.

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(sub[, start[, end]]) int

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

fromhex()

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()

Create a string of hexadecimal numbers from a bytes object.

sep

An optional single character or byte to separate hex bytes.

bytes_per_sep

How many bytes between separators. Positive values count from the right, negative values count from the left.

Example: >>> value = b’xb9x01xef’ >>> value.hex() ‘b901ef’ >>> value.hex(‘:’) ‘b9:01:ef’ >>> value.hex(‘:’, 2) ‘b9:01ef’ >>> value.hex(‘:’, -2) ‘b901:ef’

index(sub[, start[, end]]) int

Return the lowest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raises ValueError when 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.

static maketrans(frm, to, /)

Return a translation table useable 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.

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(sub[, start[, end]]) int

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Return -1 on failure.

rindex(sub[, start[, end]]) int

Return the highest index in B where subsection sub is found, such that sub is contained within B[start,end]. Optional arguments start and end are interpreted as in slice notation.

Raise ValueError when 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(prefix[, start[, end]]) bool

Return True if B starts with the specified prefix, False otherwise. With optional start, test B beginning at that position. With optional end, stop comparing B at that position. prefix can also be a tuple of bytes to try.

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.

to_0x_hex()

Convert the bytes to a 0x-prefixed hex string

Return type:

str

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.

a_sync = None
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

__new__(**kwargs)
as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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

__new__(**kwargs)
as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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

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

__new__(**kwargs)
as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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

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

__new__(**kwargs)
as_integer_ratio()

Return integer ratio.

Return a pair of integers, whose ratio is exactly equal to the original int and with 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.

from_bytes(byteorder, *, 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.

signed

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

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)
to_bytes(length, byteorder, *, 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.

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.

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