ethereum.forks.spurious_dragon.utils.hexadecimalethereum.forks.byzantium.utils.hexadecimal

Utility Functions For Hexadecimal Strings.

.. contents:: Table of Contents :backlinks: none :local:

Introduction

Hexadecimal utility functions used in this specification, specific to Spurious Dragon types.Byzantium 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:
24
    """
25
    Convert hex string to trie root.
26
27
    Parameters
28
    ----------
29
    hex_string :
30
        The hexadecimal string to be converted to trie root.
31
32
    Returns
33
    -------
34
    root : `Root`
35
        Trie root obtained from the given hexadecimal string.
36
37
    """
38
    return Root(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:
42
    """
43
    Convert hex string to Address (20 bytes).
44
45
    Parameters
46
    ----------
47
    hex_string :
48
        The hexadecimal string to be converted to Address.
49
50
    Returns
51
    -------
52
    address : `Address`
53
        The address obtained from the given hexadecimal string.
54
55
    """
56
    return Address(Bytes.fromhex(remove_hex_prefix(hex_string).rjust(40, "0")))