evmspec package
Subpackages
Submodules
evmspec.block module
- class evmspec.block.BaseBlock[source]
Bases:
MinedBlock
Represents a base Ethereum block with base fee per gas.
See also
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- number: BlockNumber
The block number.
- timestamp: UnixTimestamp
The Unix timestamp for when the block was collated.
- property transactions: Tuple[TransactionHash, ...] | Tuple[TransactionLegacy | Transaction2930 | Transaction1559, ...]
Decodes and returns the transactions in the block.
- Returns:
A tuple of transaction objects or transaction hashes.
Examples
>>> block = TinyBlock(timestamp=..., _transactions=...) >>> transactions = block.transactions
- class evmspec.block.Block[source]
Bases:
TinyBlock
Represents a full Ethereum block with all standard fields.
See also
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- number: BlockNumber
The block number.
- timestamp: UnixTimestamp
The Unix timestamp for when the block was collated.
- property transactions: Tuple[TransactionHash, ...] | Tuple[TransactionLegacy | Transaction2930 | Transaction1559, ...]
Decodes and returns the transactions in the block.
- Returns:
A tuple of transaction objects or transaction hashes.
Examples
>>> block = TinyBlock(timestamp=..., _transactions=...) >>> transactions = block.transactions
- class evmspec.block.MinedBlock[source]
Bases:
Block
Represents a mined Ethereum block with difficulty fields.
See also
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- number: BlockNumber
The block number.
- timestamp: UnixTimestamp
The Unix timestamp for when the block was collated.
- property transactions: Tuple[TransactionHash, ...] | Tuple[TransactionLegacy | Transaction2930 | Transaction1559, ...]
Decodes and returns the transactions in the block.
- Returns:
A tuple of transaction objects or transaction hashes.
Examples
>>> block = TinyBlock(timestamp=..., _transactions=...) >>> transactions = block.transactions
- class evmspec.block.ShanghaiCapellaBlock[source]
Bases:
Block
Represents a block from the Ethereum Shanghai or Capella upgrades, which includes staking withdrawals.
See also
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- number: BlockNumber
The block number.
- timestamp: UnixTimestamp
The Unix timestamp for when the block was collated.
- property transactions: Tuple[TransactionHash, ...] | Tuple[TransactionLegacy | Transaction2930 | Transaction1559, ...]
Decodes and returns the transactions in the block.
- Returns:
A tuple of transaction objects or transaction hashes.
Examples
>>> block = TinyBlock(timestamp=..., _transactions=...) >>> transactions = block.transactions
- property withdrawals: Tuple[StakingWithdrawal, ...]
Decodes and returns the staking withdrawals in the block.
- Returns:
A tuple of staking withdrawal objects.
Examples
>>> block = ShanghaiCapellaBlock(...) >>> withdrawals = block.withdrawals
See also
- class evmspec.block.StakingWithdrawal[source]
Bases:
DictStruct
A Struct representing an Ethereum staking withdrawal.
See also
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- index: IntId
- validatorIndex: IntId
This field is not always present.
- class evmspec.block.TinyBlock[source]
Bases:
LazyDictStruct
Represents a minimal block structure with essential fields.
The _transactions attribute can contain either transaction hashes, full transaction objects, or TransactionRLP objects, depending on the context of the RPC call used to retrieve the block, such as eth_getBlockByHash or eth_getBlockByNumber.
See also
evmspec.transaction.Transaction
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- timestamp: UnixTimestamp
The Unix timestamp for when the block was collated.
- property transactions: Tuple[TransactionHash, ...] | Tuple[TransactionLegacy | Transaction2930 | Transaction1559, ...]
Decodes and returns the transactions in the block.
- Returns:
A tuple of transaction objects or transaction hashes.
Examples
>>> block = TinyBlock(timestamp=..., _transactions=...) >>> transactions = block.transactions
- evmspec.block.Transactions
Represents a collection of transactions within a block, which can be either transaction hashes or full transaction objects.
Examples
>>> tx_hashes = (TransactionHash("0x..."), TransactionHash("0x...")) >>> tx_objects = (Transaction(...), Transaction(...))
alias of
Union
[Tuple
[TransactionHash
, …],Tuple
[Union
[TransactionLegacy
,Transaction2930
,Transaction1559
], …]]
evmspec.data module
- class evmspec.data.Address[source]
Bases:
str
Represents an Ethereum address with checksum validation.
This class ensures that any Ethereum address is stored in its checksummed format, which is a mixed-case encoding of the address that includes a checksum.
Examples
>>> addr = Address("0x52908400098527886E0F7030069857D2E4169EE7") >>> print(addr) 0x52908400098527886E0F7030069857D2E4169EE7
See also
eth_utils.to_checksum_address: Function used for checksum validation.
- static __new__(cls, address)[source]
Creates a new Address instance with checksum validation.
- Parameters:
address (str) – A string representing the Ethereum address.
- Returns:
An Address object with a checksummed address.
Examples
>>> Address("0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe") Address('0xDe0B295669a9FD93d5F28D9Ec85E40f4cb697BAe')
- 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.
- Parameters:
address (str) – A string representing the Ethereum address.
- Returns:
The checksummed Ethereum address.
- Return type:
Self
Examples
>>> Address.checksum("0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe") Address('0xDe0B295669a9FD93d5F28D9Ec85E40f4cb697BAe')
- 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.
- 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:
- swapcase() copy of B
Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.
- title() copy of B
Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.
- translate(table, /, delete=b'')
Return a copy with each character mapped by the given translation table.
- table
Translation table, which must be a bytes object of length 256.
All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.
- upper() copy of B
Return a copy of B with all ASCII characters converted to uppercase.
- zfill(width, /)
Pad a numeric string with zeros on the left, to fill a field of the given width.
The original string is never truncated.
- 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.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.
- 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:
- swapcase() copy of B
Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.
- title() copy of B
Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.
- translate(table, /, delete=b'')
Return a copy with each character mapped by the given translation table.
- table
Translation table, which must be a bytes object of length 256.
All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.
- upper() copy of B
Return a copy of B with all ASCII characters converted to uppercase.
- zfill(width, /)
Pad a numeric string with zeros on the left, to fill a field of the given width.
The original string is never truncated.
- 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.
- 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:
- swapcase() copy of B
Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.
- title() copy of B
Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.
- translate(table, /, delete=b'')
Return a copy with each character mapped by the given translation table.
- table
Translation table, which must be a bytes object of length 256.
All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.
- upper() copy of B
Return a copy of B with all ASCII characters converted to uppercase.
- zfill(width, /)
Pad a numeric string with zeros on the left, to fill a field of the given width.
The original string is never truncated.
- a_sync = None
- 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
- 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
uint.fromhex()
: Method to create a uint from a hexadecimal string.
- __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
evmspec.header module
- class evmspec.header.ErigonBlockHeader[source]
Bases:
LazyDictStruct
Represents a block header in the Erigon client.
This class is designed to utilize LazyDictStruct for handling block header data, ensuring immutability and strictness to known fields. It is currently under development, and specific features may not yet be functional. There may be known issues needing resolution.
- timestamp
The Unix timestamp for when the block was collated.
- Type:
- parentHash
The hash of the parent block.
- Type:
HexBytes
- uncleHash
The hash of the list of uncle headers.
- Type:
HexBytes
- root
The root hash of the state trie.
- Type:
HexBytes
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- timestamp: UnixTimestamp
The Unix timestamp for when the block was collated.
evmspec.log module
- class evmspec.log.Data[source]
Bases:
HexBytes
Represents data in Ethereum logs, providing utilities for interpreting the data as various types. The data is assumed to be in hexadecimal format as received from the RPC.
Examples
>>> data = Data("0x000000000000000000000000000000000000000000000000000000000000000a") >>> data.as_uint 10 >>> data.as_address '0x000000000000000000000000000000000000000a'
- static __new__(cls, val)
- 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.
- 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(bytes=None, /)
Strip leading and trailing bytes contained in the argument.
If the argument is omitted or None, strip leading and trailing ASCII whitespace.
- swapcase() copy of B
Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.
- title() copy of B
Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.
- translate(table, /, delete=b'')
Return a copy with each character mapped by the given translation table.
- table
Translation table, which must be a bytes object of length 256.
All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.
- upper() copy of B
Return a copy of B with all ASCII characters converted to uppercase.
- zfill(width, /)
Pad a numeric string with zeros on the left, to fill a field of the given width.
The original string is never truncated.
- property as_address: Address
Interprets the data as an Ethereum address.
- Raises:
ValueError – If the data does not represent a valid Ethereum address.
Examples
>>> data = Data("0x000000000000000000000000000000000000000a") >>> data.as_address '0x000000000000000000000000000000000000000a'
- property as_uint: uint
Interprets the data as an unsigned integer.
Examples
>>> data = Data("0x0a") >>> data.as_uint 10
- property as_uint128: uint128
Interprets the data as a 128-bit unsigned integer.
Examples
>>> data = Data("0x0000000000000000000000000000000a") >>> data.as_uint128 10
- property as_uint256: uint256
Interprets the data as a 256-bit unsigned integer.
Examples
>>> data = Data("0x000000000000000000000000000000000000000000000000000000000000000a") >>> data.as_uint256 10
- class evmspec.log.FullLog[source]
Bases:
Log
Represents a full log structure with comprehensive block and transaction details.
See also
Log
for the comprehensive log structure with transaction details.- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- property block: BlockNumber | None
A shorthand getter for ‘blockNumber’.
- blockHash: BlockHash | None
The hash of the block where the transaction was included where the log originated from. None for pending transactions.
- blockNumber: BlockNumber | None
The block where the transaction was included where the log originated from. None for pending transactions.
- logIndex: LogIndex
Index position of the log in the transaction. None for pending transactions.
- removed: bool | None
True when the log was removed, due to a chain reorganization. False if it’s a valid log.
- topics: Tuple[Topic, ...]
An array of 0 to 4 32-byte topics. The first topic is the event signature and the others are indexed filters on the event return data.
- transactionHash: TransactionHash
The hash of the transaction that generated the log.
- transactionIndex: TransactionIndex
The index of the transaction in the block, where the log originated from.
- class evmspec.log.Log[source]
Bases:
SmallLog
Represents a comprehensive log structure with additional transaction details.
See also
SmallLog
for the log structure with address and data.- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- property block: BlockNumber | None
A shorthand getter for ‘blockNumber’.
- blockNumber: BlockNumber | None
The block where the transaction was included where the log originated from. None for pending transactions.
- logIndex: LogIndex
Index position of the log in the transaction. None for pending transactions.
- removed: bool | None
True when the log was removed, due to a chain reorganization. False if it’s a valid log.
- topics: Tuple[Topic, ...]
An array of 0 to 4 32-byte topics. The first topic is the event signature and the others are indexed filters on the event return data.
- transactionHash: TransactionHash
The hash of the transaction that generated the log.
- transactionIndex: TransactionIndex
The index of the transaction in the block, where the log originated from.
- class evmspec.log.SmallLog[source]
Bases:
TinyLog
Represents a log with additional attributes for the contract address and data.
See also
TinyLog
for the base log structure.- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- class evmspec.log.TinyLog[source]
Bases:
LazyDictStruct
Represents a minimal log structure with topics.
Examples
>>> log = TinyLog(topics=(Topic(b''*32),)) >>> log.topic0 Topic('0x0000000000000000000000000000000000000000000000000000000000000000')
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- class evmspec.log.Topic[source]
Bases:
HexBytes32
,Data
Represents a topic in Ethereum logs, providing utilities for interpreting the topic as various EVM types.
See also
Data
for more utilities on interpreting data.- 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.
- 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:
- swapcase() copy of B
Return a copy of B with uppercase ASCII characters converted to lowercase ASCII and vice versa.
- title() copy of B
Return a titlecased version of B, i.e. ASCII words start with uppercase characters, all remaining cased characters have lowercase.
- translate(table, /, delete=b'')
Return a copy with each character mapped by the given translation table.
- table
Translation table, which must be a bytes object of length 256.
All characters occurring in the optional argument delete are removed. The remaining characters are mapped through the given translation table.
- upper() copy of B
Return a copy of B with all ASCII characters converted to uppercase.
- zfill(width, /)
Pad a numeric string with zeros on the left, to fill a field of the given width.
The original string is never truncated.
- property as_address: Address
Interprets the data as an Ethereum address.
- Raises:
ValueError – If the data does not represent a valid Ethereum address.
Examples
>>> data = Data("0x000000000000000000000000000000000000000a") >>> data.as_address '0x000000000000000000000000000000000000000a'
- property as_uint: uint
Interprets the data as an unsigned integer.
Examples
>>> data = Data("0x0a") >>> data.as_uint 10
- property as_uint104
Unsigned 104-bit integer.
Examples
>>> uint104(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint104(20282409603651670423947251286015)
- property as_uint112
Unsigned 112-bit integer.
Examples
>>> uint112(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint112(5192296858534827628530496329220095)
- property as_uint120
Unsigned 120-bit integer.
Examples
>>> uint120(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint120(1329227995784915872903807060280344575)
- property as_uint128: uint128
Interprets the data as a 128-bit unsigned integer.
Examples
>>> data = Data("0x0000000000000000000000000000000a") >>> data.as_uint128 10
- property as_uint136
Unsigned 136-bit integer.
Examples
>>> uint136(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint136(87112285931760246646623899502532662132735)
- property as_uint144
Unsigned 144-bit integer.
Examples
>>> uint144(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint144(22300745198530623141535718272648361505980415)
- property as_uint152
Unsigned 152-bit integer.
Examples
>>> uint152(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint152(5708990770823839524233143877797980545530986495)
- property as_uint16
Unsigned 16-bit integer.
Examples
>>> uint16(HexBytes('0xFFFF')) uint16(65535)
- property as_uint160
Unsigned 160-bit integer.
Examples
>>> uint160(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint160(1461501637330902918203684832716283019655932542975)
- property as_uint168
Unsigned 168-bit integer.
Examples
>>> uint168(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint168(374144419156711147060143317175368453031918731001855)
- property as_uint176
Unsigned 176-bit integer.
Examples
>>> uint176(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint176(95780971304118053647396689196894323976171195136475135)
- property as_uint184
Unsigned 184-bit integer.
Examples
>>> uint184(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint184(24519928653854221733733552434404946937899825954937634815)
- property as_uint192
Unsigned 192-bit integer.
Examples
>>> uint192(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint192(6277101735386680763835789423207666416102355444464034512895)
- property as_uint200
Unsigned 200-bit integer.
Examples
>>> uint200(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint200(1606938044258990275541962092341162602522202993782792835301375)
- property as_uint208
Unsigned 208-bit integer.
Examples
>>> uint208(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint208(411376139330301510538742295639337626245683966408394965837152255)
- property as_uint216
Unsigned 216-bit integer.
Examples
>>> uint216(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint216(105312291668557186697918027683670432318895095400549111254310977535)
- property as_uint224
Unsigned 224-bit integer.
Examples
>>> uint224(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint224(26959946667150639794667015087019630673637144422540572481103610249215)
- property as_uint232
Unsigned 232-bit integer.
Examples
>>> uint232(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint232(6901746346790563787434755862277025452451108972170386555162524223799295)
- property as_uint24
Unsigned 24-bit integer.
Examples
>>> uint24(HexBytes('0xFFFFFF')) uint24(16777215)
- property as_uint240
Unsigned 240-bit integer.
Examples
>>> uint240(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF')) uint240(1766847064778384329583297500742918515827483896875618958121606201292619775)
- property as_uint256: uint256
Interprets the data as a 256-bit unsigned integer.
Examples
>>> data = Data("0x000000000000000000000000000000000000000000000000000000000000000a") >>> data.as_uint256 10
- property as_uint32
Unsigned 32-bit integer.
Examples
>>> uint32(HexBytes('0xFFFFFFFF')) uint32(4294967295)
- property as_uint40
Unsigned 40-bit integer.
Examples
>>> uint40(HexBytes('0xFFFFFFFFFF')) uint40(1099511627775)
- property as_uint48
Unsigned 48-bit integer.
Examples
>>> uint48(HexBytes('0xFFFFFFFFFFFF')) uint48(281474976710655)
- property as_uint56
Unsigned 56-bit integer.
Examples
>>> uint56(HexBytes('0xFFFFFFFFFFFFFF')) uint56(72057594037927935)
- property as_uint64: uint64
Interprets the data as a 64-bit unsigned integer.
Examples
>>> data = Data("0x000000000000000a") >>> data.as_uint64 10
- property as_uint72
Unsigned 72-bit integer.
Examples
>>> uint72(HexBytes('0xFFFFFFFFFFFFFFFFFF')) uint72(4722366482869645213695)
- property as_uint8: uint8
Interprets the data as an 8-bit unsigned integer.
Examples
>>> data = Data("0x01") >>> data.as_uint8 1
- property as_uint80
Unsigned 80-bit integer.
Examples
>>> uint80(HexBytes('0xFFFFFFFFFFFFFFFFFFFF')) uint80(1208925819614629174706175)
- property as_uint88
Unsigned 88-bit integer.
Examples
>>> uint88(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFF')) uint88(309485009821345068724781055)
- property as_uint96
Unsigned 96-bit integer.
Examples
>>> uint96(HexBytes('0xFFFFFFFFFFFFFFFFFFFFFFFF')) uint96(79228162514264337593543950335)
evmspec.receipt module
- class evmspec.receipt.ArbitrumFeeStats[source]
Bases:
DictStruct
Arbitrum includes these with a tx receipt.
See also
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- class evmspec.receipt.FeeStats[source]
Bases:
DictStruct
Arbitrum includes this in the feeStats field of a tx receipt.
See also
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- class evmspec.receipt.FullTransactionReceipt[source]
Bases:
TransactionReceipt
Extends
TransactionReceipt
to include full details.- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- blobGasUsed: Wei
This field is sometimes present, only on Mainnet.
Examples
>>> receipt.blobGasUsed Wei(0)
- blockHash: HexBytes
The hash of the block that contains the transaction.
Examples
>>> full_receipt.blockHash HexBytes('0x...')
- blockNumber: BlockNumber
The block number that contains the transaction.
Examples
>>> receipt.blockNumber BlockNumber(1234567)
- contractAddress: Address | None
The contract address created, if the transaction was a contract creation, otherwise None.
Examples
>>> receipt.contractAddress Address('0x...')
- cumulativeGasUsed: Wei
The total amount of gas used in the block up to and including this transaction.
Examples
>>> receipt.cumulativeGasUsed Wei(100000)
- effectiveGasPrice: Wei
The actual value per gas deducted from the sender’s account.
This field is only present on Mainnet.
Examples
>>> receipt.effectiveGasPrice Wei(1000000000)
- property feeStats: ArbitrumFeeStats
This field is only present on Arbitrum.
Examples
>>> receipt.feeStats ArbitrumFeeStats(...)
- gasUsed: Wei
The amount of gas used by this transaction, not counting internal transactions, calls or delegate calls.
Examples
>>> receipt.gasUsed Wei(21000)
- l1BlockNumber: BlockNumber
This field is only present on Arbitrum.
Examples
>>> receipt.l1BlockNumber BlockNumber(1234567)
- l1FeeScalar: Decimal
This field is only present on Optimism.
Examples
>>> receipt.l1FeeScalar Decimal('1.0')
- l1GasPrice: Wei
This field is only present on Optimism.
Examples
>>> receipt.l1GasPrice Wei(1000000000)
- l1InboxBatchInfo: HexBytes | None
This field is only present on Arbitrum.
Examples
>>> receipt.l1InboxBatchInfo HexBytes('0x...')
- property logs: Tuple[Log, ...]
The logs that were generated during this transaction.
Examples
>>> receipt.logs (Log(...), Log(...))
- logsBloom: HexBytes
The bloom filter for all logs in this block.
Examples
>>> full_receipt.logsBloom HexBytes('0x...')
- status: Status
The status of the transaction, represented by the
Status
enum:Status.success
(1) if the transaction succeeded,Status.failure
(0) if it failed.Examples
>>> receipt.status <Status.success: 1>
- transactionHash: TransactionHash
The unique hash of this transaction.
Examples
>>> receipt.transactionHash TransactionHash('0x...')
- transactionIndex: TransactionIndex
The position of this transaction within the block.
Examples
>>> receipt.transactionIndex TransactionIndex(0)
- class evmspec.receipt.Status[source]
Bases:
Enum
Enum representing the status of a transaction, indicating success or failure.
Examples
>>> Status.success <Status.success: 1>
>>> Status.failure <Status.failure: 0>
- failure = 0
- success = 1
- class evmspec.receipt.TransactionReceipt[source]
Bases:
LazyDictStruct
Represents the receipt of a transaction within a block.
See also
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- blobGasUsed: Wei
This field is sometimes present, only on Mainnet.
Examples
>>> receipt.blobGasUsed Wei(0)
- blockNumber: BlockNumber
The block number that contains the transaction.
Examples
>>> receipt.blockNumber BlockNumber(1234567)
- contractAddress: Address | None
The contract address created, if the transaction was a contract creation, otherwise None.
Examples
>>> receipt.contractAddress Address('0x...')
- cumulativeGasUsed: Wei
The total amount of gas used in the block up to and including this transaction.
Examples
>>> receipt.cumulativeGasUsed Wei(100000)
- effectiveGasPrice: Wei
The actual value per gas deducted from the sender’s account.
This field is only present on Mainnet.
Examples
>>> receipt.effectiveGasPrice Wei(1000000000)
- property feeStats: ArbitrumFeeStats
This field is only present on Arbitrum.
Examples
>>> receipt.feeStats ArbitrumFeeStats(...)
- gasUsed: Wei
The amount of gas used by this transaction, not counting internal transactions, calls or delegate calls.
Examples
>>> receipt.gasUsed Wei(21000)
- l1BlockNumber: BlockNumber
This field is only present on Arbitrum.
Examples
>>> receipt.l1BlockNumber BlockNumber(1234567)
- l1FeeScalar: Decimal
This field is only present on Optimism.
Examples
>>> receipt.l1FeeScalar Decimal('1.0')
- l1GasPrice: Wei
This field is only present on Optimism.
Examples
>>> receipt.l1GasPrice Wei(1000000000)
- l1InboxBatchInfo: HexBytes | None
This field is only present on Arbitrum.
Examples
>>> receipt.l1InboxBatchInfo HexBytes('0x...')
- property logs: Tuple[Log, ...]
The logs that were generated during this transaction.
Examples
>>> receipt.logs (Log(...), Log(...))
- status: Status
The status of the transaction, represented by the
Status
enum:Status.success
(1) if the transaction succeeded,Status.failure
(0) if it failed.Examples
>>> receipt.status <Status.success: 1>
- transactionHash: TransactionHash
The unique hash of this transaction.
Examples
>>> receipt.transactionHash TransactionHash('0x...')
- transactionIndex: TransactionIndex
The position of this transaction within the block.
Examples
>>> receipt.transactionIndex TransactionIndex(0)
evmspec.transaction module
- class evmspec.transaction.AccessListEntry[source]
Bases:
LazyDictStruct
Represents an entry in an Ethereum transaction access list.
Access lists are used in EIP-2930 and EIP-1559 transactions to specify storage slots that the transaction plans to access, potentially reducing gas costs.
Example
>>> entry = AccessListEntry(address='0x742d35Cc6634C0532925a3b844Bc454e4438f44e', storageKeys=[...]) >>> entry.address '0x742d35Cc6634C0532925a3b844Bc454e4438f44e' >>> len(entry.storageKeys) 2
See also
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- property storageKeys: List[HexBytes32]
Decodes storage keys from raw format to a list of HexBytes32.
Example
>>> entry = AccessListEntry(address='0x742d35Cc6634C0532925a3b844Bc454e4438f44e', storageKeys=[...]) >>> decoded_keys = entry.storageKeys >>> isinstance(decoded_keys, list) True >>> isinstance(decoded_keys[0], HexBytes32) True
See also
_TransactionBase.accessList()
- class evmspec.transaction.Transaction1559[source]
Bases:
_TransactionBase
Represents a type-1559 (EIP-1559) Ethereum transaction with dynamic fee.
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- property accessList: List[AccessListEntry]
Decodes the access list from raw format to a list of AccessListEntry.
Example
>>> transaction = _TransactionBase(...) >>> access_list = transaction.accessList >>> isinstance(access_list, list) True >>> isinstance(access_list[0], AccessListEntry) True
See also
- property block: BlockNumber
A shorthand getter for blockNumber.
Example
>>> transaction = _TransactionBase(...) >>> transaction.block == transaction.blockNumber True
- blockNumber: BlockNumber
The number of the block including this transaction.
- chainId: ChainId | None
The chain id of the transaction, if any.
None for v in {27, 28}, otherwise derived from eip-155.
This field is not included in the transactions field of a eth_getBlock response.
- hash: TransactionHash
The hash of the transaction.
- transactionIndex: TransactionIndex
The index position of the transaction in the block.
- class evmspec.transaction.Transaction2930[source]
Bases:
_TransactionBase
Represents a type-2930 (EIP-2930) Ethereum transaction with an access list.
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- property accessList: List[AccessListEntry]
Decodes the access list from raw format to a list of AccessListEntry.
Example
>>> transaction = _TransactionBase(...) >>> access_list = transaction.accessList >>> isinstance(access_list, list) True >>> isinstance(access_list[0], AccessListEntry) True
See also
- property block: BlockNumber
A shorthand getter for blockNumber.
Example
>>> transaction = _TransactionBase(...) >>> transaction.block == transaction.blockNumber True
- blockNumber: BlockNumber
The number of the block including this transaction.
- chainId: ChainId | None
The chain id of the transaction, if any.
None for v in {27, 28}, otherwise derived from eip-155.
This field is not included in the transactions field of a eth_getBlock response.
- hash: TransactionHash
The hash of the transaction.
- transactionIndex: TransactionIndex
The index position of the transaction in the block.
- class evmspec.transaction.TransactionLegacy[source]
Bases:
_TransactionBase
Represents a Legacy Ethereum transaction (pre-EIP-2718).
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- property accessList: List[AccessListEntry]
Decodes the access list from raw format to a list of AccessListEntry.
Example
>>> transaction = _TransactionBase(...) >>> access_list = transaction.accessList >>> isinstance(access_list, list) True >>> isinstance(access_list[0], AccessListEntry) True
See also
- property block: BlockNumber
A shorthand getter for blockNumber.
Example
>>> transaction = _TransactionBase(...) >>> transaction.block == transaction.blockNumber True
- blockNumber: BlockNumber
The number of the block including this transaction.
- chainId: ChainId | None
The chain id of the transaction, if any.
None for v in {27, 28}, otherwise derived from eip-155.
This field is not included in the transactions field of a eth_getBlock response.
- hash: TransactionHash
The hash of the transaction.
- transactionIndex: TransactionIndex
The index position of the transaction in the block.
- class evmspec.transaction.TransactionRLP[source]
Bases:
_TransactionBase
Represents a RLP encoded transaction that might have network-specific fields.
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- property accessList: List[AccessListEntry]
Decodes the access list from raw format to a list of AccessListEntry.
Example
>>> transaction = _TransactionBase(...) >>> access_list = transaction.accessList >>> isinstance(access_list, list) True >>> isinstance(access_list[0], AccessListEntry) True
See also
- property block: BlockNumber
A shorthand getter for blockNumber.
Example
>>> transaction = _TransactionBase(...) >>> transaction.block == transaction.blockNumber True
- blockNumber: BlockNumber
The number of the block including this transaction.
- chainId: ChainId | None
The chain id of the transaction, if any.
None for v in {27, 28}, otherwise derived from eip-155.
This field is not included in the transactions field of a eth_getBlock response.
- hash: TransactionHash
The hash of the transaction.
- l1BlockNumber: BlockNumber
- transactionIndex: TransactionIndex
The index position of the transaction in the block.
evmspec.uints module
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- min_value = 0
- numerator
the numerator of a rational number in lowest terms
- real
the real part of a complex number
- class evmspec.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.
- denominator
the denominator of a rational number in lowest terms
- imag
the imaginary part of a complex number
- 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.ErigonBlockHeader[source]
Bases:
LazyDictStruct
Represents a block header in the Erigon client.
This class is designed to utilize LazyDictStruct for handling block header data, ensuring immutability and strictness to known fields. It is currently under development, and specific features may not yet be functional. There may be known issues needing resolution.
- timestamp
The Unix timestamp for when the block was collated.
- Type:
- parentHash
The hash of the parent block.
- Type:
HexBytes
- uncleHash
The hash of the list of uncle headers.
- Type:
HexBytes
- root
The root hash of the state trie.
- Type:
HexBytes
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- timestamp: UnixTimestamp
The Unix timestamp for when the block was collated.
- class evmspec.FullTransactionReceipt[source]
Bases:
TransactionReceipt
Extends
TransactionReceipt
to include full details.- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- blobGasUsed: Wei
This field is sometimes present, only on Mainnet.
Examples
>>> receipt.blobGasUsed Wei(0)
- blockHash: HexBytes
The hash of the block that contains the transaction.
Examples
>>> full_receipt.blockHash HexBytes('0x...')
- blockNumber: BlockNumber
The block number that contains the transaction.
Examples
>>> receipt.blockNumber BlockNumber(1234567)
- contractAddress: Address | None
The contract address created, if the transaction was a contract creation, otherwise None.
Examples
>>> receipt.contractAddress Address('0x...')
- cumulativeGasUsed: Wei
The total amount of gas used in the block up to and including this transaction.
Examples
>>> receipt.cumulativeGasUsed Wei(100000)
- effectiveGasPrice: Wei
The actual value per gas deducted from the sender’s account.
This field is only present on Mainnet.
Examples
>>> receipt.effectiveGasPrice Wei(1000000000)
- property feeStats: ArbitrumFeeStats
This field is only present on Arbitrum.
Examples
>>> receipt.feeStats ArbitrumFeeStats(...)
- gasUsed: Wei
The amount of gas used by this transaction, not counting internal transactions, calls or delegate calls.
Examples
>>> receipt.gasUsed Wei(21000)
- l1BlockNumber: BlockNumber
This field is only present on Arbitrum.
Examples
>>> receipt.l1BlockNumber BlockNumber(1234567)
- l1FeeScalar: Decimal
This field is only present on Optimism.
Examples
>>> receipt.l1FeeScalar Decimal('1.0')
- l1GasPrice: Wei
This field is only present on Optimism.
Examples
>>> receipt.l1GasPrice Wei(1000000000)
- l1InboxBatchInfo: HexBytes | None
This field is only present on Arbitrum.
Examples
>>> receipt.l1InboxBatchInfo HexBytes('0x...')
- property logs: Tuple[Log, ...]
The logs that were generated during this transaction.
Examples
>>> receipt.logs (Log(...), Log(...))
- logsBloom: HexBytes
The bloom filter for all logs in this block.
Examples
>>> full_receipt.logsBloom HexBytes('0x...')
- status: Status
The status of the transaction, represented by the
Status
enum:Status.success
(1) if the transaction succeeded,Status.failure
(0) if it failed.Examples
>>> receipt.status <Status.success: 1>
- transactionHash: TransactionHash
The unique hash of this transaction.
Examples
>>> receipt.transactionHash TransactionHash('0x...')
- transactionIndex: TransactionIndex
The position of this transaction within the block.
Examples
>>> receipt.transactionIndex TransactionIndex(0)
- class evmspec.Transaction1559[source]
Bases:
_TransactionBase
Represents a type-1559 (EIP-1559) Ethereum transaction with dynamic fee.
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- property accessList: List[AccessListEntry]
Decodes the access list from raw format to a list of AccessListEntry.
Example
>>> transaction = _TransactionBase(...) >>> access_list = transaction.accessList >>> isinstance(access_list, list) True >>> isinstance(access_list[0], AccessListEntry) True
See also
AccessListEntry
- property block: BlockNumber
A shorthand getter for blockNumber.
Example
>>> transaction = _TransactionBase(...) >>> transaction.block == transaction.blockNumber True
- blockNumber: BlockNumber
The number of the block including this transaction.
- chainId: ChainId | None
The chain id of the transaction, if any.
None for v in {27, 28}, otherwise derived from eip-155.
This field is not included in the transactions field of a eth_getBlock response.
- hash: TransactionHash
The hash of the transaction.
- transactionIndex: TransactionIndex
The index position of the transaction in the block.
- class evmspec.Transaction2930[source]
Bases:
_TransactionBase
Represents a type-2930 (EIP-2930) Ethereum transaction with an access list.
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- property accessList: List[AccessListEntry]
Decodes the access list from raw format to a list of AccessListEntry.
Example
>>> transaction = _TransactionBase(...) >>> access_list = transaction.accessList >>> isinstance(access_list, list) True >>> isinstance(access_list[0], AccessListEntry) True
See also
AccessListEntry
- property block: BlockNumber
A shorthand getter for blockNumber.
Example
>>> transaction = _TransactionBase(...) >>> transaction.block == transaction.blockNumber True
- blockNumber: BlockNumber
The number of the block including this transaction.
- chainId: ChainId | None
The chain id of the transaction, if any.
None for v in {27, 28}, otherwise derived from eip-155.
This field is not included in the transactions field of a eth_getBlock response.
- hash: TransactionHash
The hash of the transaction.
- transactionIndex: TransactionIndex
The index position of the transaction in the block.
- class evmspec.TransactionLegacy[source]
Bases:
_TransactionBase
Represents a Legacy Ethereum transaction (pre-EIP-2718).
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- property accessList: List[AccessListEntry]
Decodes the access list from raw format to a list of AccessListEntry.
Example
>>> transaction = _TransactionBase(...) >>> access_list = transaction.accessList >>> isinstance(access_list, list) True >>> isinstance(access_list[0], AccessListEntry) True
See also
AccessListEntry
- property block: BlockNumber
A shorthand getter for blockNumber.
Example
>>> transaction = _TransactionBase(...) >>> transaction.block == transaction.blockNumber True
- blockNumber: BlockNumber
The number of the block including this transaction.
- chainId: ChainId | None
The chain id of the transaction, if any.
None for v in {27, 28}, otherwise derived from eip-155.
This field is not included in the transactions field of a eth_getBlock response.
- hash: TransactionHash
The hash of the transaction.
- transactionIndex: TransactionIndex
The index position of the transaction in the block.
- class evmspec.TransactionRLP[source]
Bases:
_TransactionBase
Represents a RLP encoded transaction that might have network-specific fields.
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- property accessList: List[AccessListEntry]
Decodes the access list from raw format to a list of AccessListEntry.
Example
>>> transaction = _TransactionBase(...) >>> access_list = transaction.accessList >>> isinstance(access_list, list) True >>> isinstance(access_list[0], AccessListEntry) True
See also
AccessListEntry
- property block: BlockNumber
A shorthand getter for blockNumber.
Example
>>> transaction = _TransactionBase(...) >>> transaction.block == transaction.blockNumber True
- blockNumber: BlockNumber
The number of the block including this transaction.
- chainId: ChainId | None
The chain id of the transaction, if any.
None for v in {27, 28}, otherwise derived from eip-155.
This field is not included in the transactions field of a eth_getBlock response.
- hash: TransactionHash
The hash of the transaction.
- l1BlockNumber: BlockNumber
- transactionIndex: TransactionIndex
The index position of the transaction in the block.
- class evmspec.TransactionReceipt[source]
Bases:
LazyDictStruct
Represents the receipt of a transaction within a block.
See also
- get(key, default=None)
Get the value associated with a key, or a default value if the key is not present.
- Parameters:
key (str) – The key to look up.
default (optional) – The value to return if the key is not present.
- Return type:
Example
>>> class MyStruct(DictStruct): ... field1: str >>> s = MyStruct(field1="value") >>> s.get('field1') 'value' >>> s.get('field2', 'default') 'default'
- items()
Returns an iterator over the struct’s field name and value pairs.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.items()) [('field1', 'value'), ('field2', 42)]
- keys()
Returns an iterator over the field names of the struct.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.keys()) ['field1', 'field2']
- values()
Returns an iterator over the struct’s field values.
Example
>>> class MyStruct(DictStruct): ... field1: str ... field2: int >>> s = MyStruct(field1="value", field2=42) >>> list(s.values()) ['value', 42]
- blobGasUsed: Wei
This field is sometimes present, only on Mainnet.
Examples
>>> receipt.blobGasUsed Wei(0)
- blockNumber: BlockNumber
The block number that contains the transaction.
Examples
>>> receipt.blockNumber BlockNumber(1234567)
- contractAddress: Address | None
The contract address created, if the transaction was a contract creation, otherwise None.
Examples
>>> receipt.contractAddress Address('0x...')
- cumulativeGasUsed: Wei
The total amount of gas used in the block up to and including this transaction.
Examples
>>> receipt.cumulativeGasUsed Wei(100000)
- effectiveGasPrice: Wei
The actual value per gas deducted from the sender’s account.
This field is only present on Mainnet.
Examples
>>> receipt.effectiveGasPrice Wei(1000000000)
- property feeStats: ArbitrumFeeStats
This field is only present on Arbitrum.
Examples
>>> receipt.feeStats ArbitrumFeeStats(...)
- gasUsed: Wei
The amount of gas used by this transaction, not counting internal transactions, calls or delegate calls.
Examples
>>> receipt.gasUsed Wei(21000)
- l1BlockNumber: BlockNumber
This field is only present on Arbitrum.
Examples
>>> receipt.l1BlockNumber BlockNumber(1234567)
- l1FeeScalar: Decimal
This field is only present on Optimism.
Examples
>>> receipt.l1FeeScalar Decimal('1.0')
- l1GasPrice: Wei
This field is only present on Optimism.
Examples
>>> receipt.l1GasPrice Wei(1000000000)
- l1InboxBatchInfo: HexBytes | None
This field is only present on Arbitrum.
Examples
>>> receipt.l1InboxBatchInfo HexBytes('0x...')
- property logs: Tuple[Log, ...]
The logs that were generated during this transaction.
Examples
>>> receipt.logs (Log(...), Log(...))
- status: Status
The status of the transaction, represented by the
Status
enum:Status.success
(1) if the transaction succeeded,Status.failure
(0) if it failed.Examples
>>> receipt.status <Status.success: 1>
- transactionHash: TransactionHash
The unique hash of this transaction.
Examples
>>> receipt.transactionHash TransactionHash('0x...')
- transactionIndex: TransactionIndex
The position of this transaction within the block.
Examples
>>> receipt.transactionIndex TransactionIndex(0)