ethereum_types.bytes

Sequences of 256-bit values.

B

12
B = TypeVar("B", bound="FixedBytes")

FixedBytes

Superclass for fixed sized byte arrays. Not intended to be used directly, but should be subclassed.

15
@mypyc_attr(native_class=False)
class FixedBytes:

LENGTH

Number of bytes in each instance of this class.

22
    LENGTH: ClassVar[int]

__slots__

27
    __slots__ = ()

__new__

Create a new instance, ensuring the result has the correct length.

def __new__(cls: Type[B], ​​*args: Any, ​​**kwargs: Any) -> B:
30
        <snip>
33
        result = bytes.__new__(cls, *args, **kwargs)
34
        if len(result) != cls.LENGTH:
35
            message = f"expected {cls.LENGTH} bytes but got {len(result)}"
36
            raise ValueError(message)
37
        return result

zero_bytes

Count and return the number of zero bytes in the byte array.

def zero_bytes(self) -> "Uint":
40
        <snip>
43
        from .numeric import Uint
44
45
        return Uint(self.count(b"\0"))

Bytes0

Byte array of exactly zero elements.

48
@mypyc_attr(native_class=False)
class Bytes0:

LENGTH

Number of bytes in each instance of this class.

54
    LENGTH = 0

Bytes1

Byte array of exactly one elements.

60
@mypyc_attr(native_class=False)
class Bytes1:

LENGTH

Number of bytes in each instance of this class.

66
    LENGTH = 1

Bytes4

Byte array of exactly four elements.

72
@mypyc_attr(native_class=False)
class Bytes4:

LENGTH

Number of bytes in each instance of this class.

78
    LENGTH = 4

Bytes8

Byte array of exactly eight elements.

84
@mypyc_attr(native_class=False)
class Bytes8:

LENGTH

Number of bytes in each instance of this class.

90
    LENGTH = 8

Bytes20

Byte array of exactly 20 elements.

96
@mypyc_attr(native_class=False)
class Bytes20:

LENGTH

Number of bytes in each instance of this class.

102
    LENGTH = 20

Bytes32

Byte array of exactly 32 elements.

108
@mypyc_attr(native_class=False)
class Bytes32:

LENGTH

Number of bytes in each instance of this class.

114
    LENGTH = 32

Bytes48

Byte array of exactly 48 elements.

120
@mypyc_attr(native_class=False)
class Bytes48:

LENGTH

126
    LENGTH = 48

Bytes64

Byte array of exactly 64 elements.

129
@mypyc_attr(native_class=False)
class Bytes64:

LENGTH

Number of bytes in each instance of this class.

135
    LENGTH = 64

Bytes96

Byte array of exactly 96 elements.

141
@mypyc_attr(native_class=False)
class Bytes96:

LENGTH

Number of bytes in each instance of this class.

147
    LENGTH = 96

Bytes256

Byte array of exactly 256 elements.

153
@mypyc_attr(native_class=False)
class Bytes256:

LENGTH

Number of bytes in each instance of this class.

159
    LENGTH = 256

Bytes

165
Bytes = bytes