Repository navigation
Open
Labels
approvedIssue has been approved by team memberIssue has been approved by team memberpythonPull requests that update python codePull requests that update python codeskill: advancedrequires knowledge of multiple areas in the codebase without defined steps to implement or examplesrequires knowledge of multiple areas in the codebase without defined steps to implement or examples
Description
Description
Add a small utility with functions for canonical Ethereum integer encoding. Ethereum RLP encodes integers as minimal big-endian bytes: no leading zeros, and zero is the empty byte string.
Background
Ethereum transaction fields such as nonce, gas_limit, chain_id and value are RLP-encoded as canonical integers. The Ethereum transaction data classes (Legacy, EIP-2930, EIP-1559) store these fields as raw bytes and need a conversion layer for their numeric getters and setters.
Functionality required
| Function | Input | Output | Behaviour |
|---|---|---|---|
_uint64_to_eth_bytes(v) |
int |
bytes |
Treats v as a 64-bit value (a negative int wraps to its unsigned 64-bit form). Returns minimal big-endian bytes. 0 gives b"". |
_eth_bytes_to_uint64(b) |
bytes | None |
int |
None or empty gives 0. Input longer than 8 bytes is truncated to the low 8 bytes. Always returns an unsigned value. |
_big_int_to_eth_bytes(v) |
int | None |
bytes |
None and 0 give b"". Negative values encode their absolute value. Minimal big-endian bytes, unbounded size. |
_eth_bytes_to_big_int(b) |
bytes | None |
int |
None or empty gives 0. Leading zero bytes are tolerated. Unbounded size. |
Proposed architecture
- Location:
src/hiero_sdk_python/utils/ethereum_encoding_util.py - Add implement for the following methods
def _uint64_to_eth_bytes(v: int) -> bytes:
...
def _eth_bytes_to_uint64(b: bytes | None) -> int:
...
def _big_int_to_eth_bytes(v: int | None) -> bytes:
...
def _eth_bytes_to_big_int(b: bytes | None) -> int:
...Tasks
- Create
src/hiero_sdk_python/utils/ethereum_encoding_util.py - Implement the four private functions with type hints and docstrings
- Add unit tests in
tests/unit/test_ethereum_encoding_util.py:- Parametrized vectors:
0,1,0x7f,0x80,0xff,0x100,0xffff,2**64 - 1 - Zero encodes to
b""and decodes back to0 -
Nonedecodes to0in both decoders, andNoneencodes tob""in_big_int_to_eth_bytes - Output never starts with a zero byte
- Leading zeros are tolerated on decode (
b"\x00\x00\x01"gives1) -
_eth_bytes_to_uint64truncates input of 9 or more bytes to the low 8 bytes - Values beyond 64 bits round-trip through the big-int pair (for example
10**30) - Round-trip over a range of values
- Parametrized vectors:
Metadata
Metadata
Assignees
Labels
approvedIssue has been approved by team memberIssue has been approved by team memberpythonPull requests that update python codePull requests that update python codeskill: advancedrequires knowledge of multiple areas in the codebase without defined steps to implement or examplesrequires knowledge of multiple areas in the codebase without defined steps to implement or examples
Activity
github-actions commentedon Nov 12, 2026
Thanks for your submission.
This issue is awaiting approval from @hiero-ledger/hiero-sdk-python-triage and @hiero-ledger/hiero-sdk-python-committers and @hiero-ledger/hiero-sdk-python-maintainers.
github-actions commentedon Nov 13, 2026
Approved by @hiero-ledger/hiero-sdk-python-triage and @hiero-ledger/hiero-sdk-python-committers and @hiero-ledger/hiero-sdk-python-maintainers.
github-actions commentedon Nov 13, 2026