ethereum.london.utils.hexadecimalethereum.arrow_glacier.utils.hexadecimal
Utility Functions For Hexadecimal Strings ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
.. contents:: Table of Contents :backlinks: none :local:
Introduction
Hexadecimal utility functions used in this specification, specific to
London types.Arrow Glacier types.
hex_to_root
Convert hex string to trie root.
Parameters
hex_string : The hexadecimal string to be converted to trie root.
Returns
root : Root
Trie root obtained from the given hexadecimal string.
def hex_to_root(hex_string: str) -> Root:
23 | """ |
---|---|
24 | Convert hex string to trie root. |
25 |
|
26 | Parameters |
27 | ---------- |
28 | hex_string : |
29 | The hexadecimal string to be converted to trie root. |
30 |
|
31 | Returns |
32 | ------- |
33 | root : `Root` |
34 | Trie root obtained from the given hexadecimal string. |
35 | """ |
36 | return Root(Bytes.fromhex(remove_hex_prefix(hex_string))) |
hex_to_bloom
Convert hex string to bloom.
Parameters
hex_string : The hexadecimal string to be converted to bloom.
Returns
bloom : Bloom
Bloom obtained from the given hexadecimal string.
def hex_to_bloom(hex_string: str) -> Bloom:
40 | """ |
---|---|
41 | Convert hex string to bloom. |
42 |
|
43 | Parameters |
44 | ---------- |
45 | hex_string : |
46 | The hexadecimal string to be converted to bloom. |
47 |
|
48 | Returns |
49 | ------- |
50 | bloom : `Bloom` |
51 | Bloom obtained from the given hexadecimal string. |
52 | """ |
53 | return Bloom(Bytes.fromhex(remove_hex_prefix(hex_string))) |
hex_to_address
Convert hex string to Address (20 bytes).
Parameters
hex_string : The hexadecimal string to be converted to Address.
Returns
address : Address
The address obtained from the given hexadecimal string.
def hex_to_address(hex_string: str) -> Address:
57 | """ |
---|---|
58 | Convert hex string to Address (20 bytes). |
59 |
|
60 | Parameters |
61 | ---------- |
62 | hex_string : |
63 | The hexadecimal string to be converted to Address. |
64 |
|
65 | Returns |
66 | ------- |
67 | address : `Address` |
68 | The address obtained from the given hexadecimal string. |
69 | """ |
70 | return Address(Bytes.fromhex(remove_hex_prefix(hex_string).rjust(40, "0"))) |