ethereum.base_types

Numeric & Array Types

Introduction

Integer and array types which are used by—but not unique to—Ethereum.

Module Contents

Classes

Uint

Unsigned positive integer.

U256

Unsigned positive integer, which can represent 0 to 2 ** 256 - 1,

Attributes

MAX_VALUE

Bytes

Bytes64

Bytes32

Bytes20

Bytes8

Module Details

Uint

Unsigned positive integer.

class ethereum.base_types.Uint

Bases: int

__slots__ = []
classmethod from_be_bytes(cls: Type, buffer: Bytes)Uint

Converts a sequence of bytes into an arbitrarily sized unsigned integer from its big endian representation.

Parameters

buffer – Bytes to decode.

Returns

self – Unsigned integer decoded from buffer.

Return type

Uint

__radd__(self, left: int)Uint

Return value+self.

__add__(self, right: int)Uint

Return self+value.

__iadd__(self, right: int)Uint
__sub__(self, right: int)Uint

Return self-value.

__rsub__(self, left: int)Uint

Return value-self.

__isub__(self, right: int)Uint
__mul__(self, right: int)Uint

Return self*value.

__rmul__(self, left: int)Uint

Return value*self.

__imul__(self, right: int)Uint
__floordiv__(self, right: int)Uint

Return self//value.

__rfloordiv__(self, left: int)Uint

Return value//self.

__ifloordiv__(self, right: int)Uint
__mod__(self, right: int)Uint

Return self%value.

__rmod__(self, left: int)Uint

Return value%self.

__imod__(self, right: int)Uint
__divmod__(self, right: int)Tuple[Uint, Uint]

Return divmod(self, value).

__rdivmod__(self, left: int)Tuple[Uint, Uint]

Return divmod(value, self).

__pow__(self, right: int, modulo: Optional[int] = None)Uint

Return pow(self, value, mod).

__rpow__(self, left: int, modulo: Optional[int] = None)Uint

Return pow(value, self, mod).

__ipow__(self, right: int, modulo: Optional[int] = None)Uint
to_be_bytes32(self)Bytes32

Converts this arbitrarily sized unsigned integer into its big endian representation with exactly 32 bytes.

Returns

big_endian – Big endian (most significant bits first) representation.

Return type

Bytes32

to_be_bytes(self)Bytes

Converts this arbitrarily sized unsigned integer into its big endian representation.

Returns

big_endian – Big endian (most significant bits first) representation.

Return type

Bytes

U256

Unsigned positive integer, which can represent 0 to 2 ** 256 - 1, inclusive.

class ethereum.base_types.U256

Bases: int

MAX_VALUE :U256
__slots__ = []
classmethod from_be_bytes(cls: Type, buffer: Bytes)U256

Converts a sequence of bytes into an arbitrarily sized unsigned integer from its big endian representation.

Parameters

buffer – Bytes to decode.

Returns

self – Unsigned integer decoded from buffer.

Return type

U256

__radd__(self, left: int)U256

Return value+self.

__add__(self, right: int)U256

Return self+value.

unchecked_add(self, right: int)int
wrapping_add(self, right: int)U256
__iadd__(self, right: int)U256
__sub__(self, right: int)U256

Return self-value.

unchecked_sub(self, right: int)int
wrapping_sub(self, right: int)U256
__rsub__(self, left: int)U256

Return value-self.

__isub__(self, right: int)U256
unchecked_mul(self, right: int)int
wrapping_mul(self, right: int)U256
__mul__(self, right: int)U256

Return self*value.

__rmul__(self, left: int)U256

Return value*self.

__imul__(self, right: int)U256
__floordiv__(self, right: int)U256

Return self//value.

__rfloordiv__(self, left: int)U256

Return value//self.

__ifloordiv__(self, right: int)U256
__mod__(self, right: int)U256

Return self%value.

__rmod__(self, left: int)U256

Return value%self.

__imod__(self, right: int)U256
__divmod__(self, right: int)Tuple[U256, U256]

Return divmod(self, value).

__rdivmod__(self, left: int)Tuple[U256, U256]

Return divmod(value, self).

unchecked_pow(self, right: int, modulo: Optional[int] = None)int
wrapping_pow(self, right: int, modulo: Optional[int] = None)U256
__pow__(self, right: int, modulo: Optional[int] = None)U256

Return pow(self, value, mod).

__rpow__(self, left: int, modulo: Optional[int] = None)U256

Return pow(value, self, mod).

__ipow__(self, right: int, modulo: Optional[int] = None)U256
to_be_bytes32(self)Bytes32

Converts this 256-bit unsigned integer into its big endian representation with exactly 32 bytes.

Returns

big_endian – Big endian (most significant bits first) representation.

Return type

Bytes32

to_be_bytes(self)Bytes

Converts this 256-bit unsigned integer into its big endian representation, omitting leading zero bytes.

Returns

big_endian – Big endian (most significant bits first) representation.

Return type

Bytes

MAX_VALUE

ethereum.base_types.MAX_VALUE

Bytes

ethereum.base_types.Bytes

Bytes64

ethereum.base_types.Bytes64

Bytes32

ethereum.base_types.Bytes32

Bytes20

ethereum.base_types.Bytes20

Bytes8

ethereum.base_types.Bytes8