ETH_RLP(1)

NAME
eth_rlp - eth-rlp Documentation

RLP definitions for common Ethereum objects in Python

INSTALLATION

    python -m pip install eth-rlp

Import with

    from eth_rlp import HashableRLP

  eth_rlp package

  HashableRLP

class eth_rlp.main.HashableRLP(*args, **kwargs)
    An extension of rlp.Serializable <https://pyrlp.readthedocs.io/en/latest/api.html#rlp.Serializable>. In addition to the below functions, the class is iterable.

    Use like:

        class MyRLP(HashableRLP):
            fields = (
                ('name1', rlp.sedes.big_endian_int),
                ('name2', rlp.sedes.binary),
                etc...
            )
        my_obj = MyRLP(name2=b'\xff', name1=1)
        list(my_obj) == [1, b'\xff']
        # note that the iteration order is always in RLP-defined order

as_dict() -> dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]
    Convert rlp object to a dict

Returns
    mapping of RLP field names to field values

Return type
    dict <https://docs.python.org/3.10/library/stdtypes.html#dict>

classmethod from_bytes(serialized_bytes: bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes> | bytearray <https://docs.python.org/3.10/library/stdtypes.html#bytearray>) -> Self
    Shorthand invocation for rlp.decode() using this class.

Parameters
    serialized_bytes (bytes <https://docs.python.org/3.10/library/stdtypes.html#bytes>) -- the byte string to decode

Returns
    the decoded object

Return type
    HashableRLP <#eth_rlp.main.HashableRLP>

classmethod from_dict(field_dict: dict <https://docs.python.org/3.10/library/stdtypes.html#dict>[str <https://docs.python.org/3.10/library/stdtypes.html#str>, Any <https://docs.python.org/3.10/library/typing.html#typing.Any>]) -> Self
    In addition to the standard initialization of.

        my_obj = MyRLP(name1=1, name2=b"\xff")

    This method enables initialization with.

        my_obj = MyRLP.from_dict({"name1": 1, "name2": b"\xff"})

    In general, the standard initialization is preferred, but some approaches might favor this API, like when using toolz.functoolz.pipe().

        return eth_utils.toolz.pipe(
            my_dict,
            normalize,
            validate,
            MyRLP.from_dict,
        )

Parameters
    field_dict (dict <https://docs.python.org/3.10/library/stdtypes.html#dict>) -- the dictionary of values to initialize with

Returns
    the new rlp object

Return type
    HashableRLP <#eth_rlp.main.HashableRLP>

hash() -> HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>

Returns
    the hash of the encoded bytestring

Return type
    HexBytes <https://hexbytes.readthedocs.io/en/latest/hexbytes.html#hexbytes.main.HexBytes>

  Release Notes

  eth-rlp v3.0.0-beta.1 (2025-12-17)

  Breaking Changes

•   Drop support for Python 3.8 and 3.9 (#27 <https://github.com/ethereum/eth-rlp/issues/27>)

  Features

•   Add support for pyrlp v5 and Python 3.14 (#27 <https://github.com/ethereum/eth-rlp/issues/27>)

  eth-rlp v2.2.0 (2025-02-04)

  Features

•   Merge template, adding py313 support and replacing bumpversion with bump-my-version. (#26 <https://github.com/ethereum/eth-rlp/issues/26>)

  Internal Changes - for eth-rlp Contributors

•   Merge template, fixing docs CI, add nightly CI runs (#24 <https://github.com/ethereum/eth-rlp/issues/24>)

  eth-rlp v2.1.0 (2024-03-19)

  Internal Changes - for eth-rlp Contributors

•   Bump to hexbytes>=1.2.0 and add blocklint to linting (#22 <https://github.com/ethereum/eth-rlp/issues/22>)

  eth-rlp v2.0.0 (2024-03-04)

  Breaking Changes

•   Bump hexbytes dependency to >=1.0.0 (#21 <https://github.com/ethereum/eth-rlp/issues/21>)

  Features

•   Add Python 3.12 support (#18 <https://github.com/ethereum/eth-rlp/issues/18>)

  Internal Changes - for eth-rlp Contributors

•   Add windows-wheel CI job for py312, set both py311 and py312 to use latest patch version (#20 <https://github.com/ethereum/eth-rlp/issues/20>)

•   Add py.typed file, move misplaced newsfragment, correct py version pins for typing-extensions (#21 <https://github.com/ethereum/eth-rlp/issues/21>)

  eth-rlp v1.0.1 (2024-01-25)

  Bugfixes

•   Add the missing typing_extensions module requirement for Python <= 3.11 (#19 <https://github.com/ethereum/eth-rlp/issues/19>)

  eth-rlp v1.0.0 (2023-12-06)

  Breaking Changes

•   Drop python 3.7 support (#16 <https://github.com/ethereum/eth-rlp/issues/16>)

  Features

•   Add python 3.11 support (#16 <https://github.com/ethereum/eth-rlp/issues/16>)

  Internal Changes - for eth-rlp Contributors

•   Merge updates from template, including use pre-commit for linting, and changing the name of the master branch to main (#16 <https://github.com/ethereum/eth-rlp/issues/16>)

  eth-rlp v0.3.0 (2022-01-19)

  Eth_Rlp 0.3.0 (2022-01-19)

  Features

•   Add support for python 3.8-3.10 (#12 <https://github.com/ethereum/eth-rlp/issues/12>)

•   Require eth-utils>=2.0,<3 (#14 <https://github.com/ethereum/eth-rlp/issues/14>)

  Deprecations and Removals

•   Remove support for Python 3.6 (#13 <https://github.com/ethereum/eth-rlp/issues/13>)

  eth-rlp v0.2.0 (2020-09-01)

  Features

•   Add support for pyrlp v2.0.0-alpha.1 (as long as you don't use pypy) (#8 <https://github.com/ethereum/eth-rlp/issues/8>)

  Deprecations and Removals

•   Dropped py3.5 support (#7 <https://github.com/ethereum/eth-rlp/issues/7>)

  Miscellaneous changes

•   Merge updates from the project template (#7 <https://github.com/ethereum/eth-rlp/issues/7>)

  v0.1.2

Released April 25, 2018

•   Add as_dict() <#eth_rlp.main.HashableRLP.as_dict> as a shim for joint v0/v1 compatibility

  v0.1.1

Released April 25, 2018

•   Add support for rlp version 1 (but still backwards-compatible with v0)

  v0.1.0

Released Mar 1, 2018

•   Marked stable

•   Upgraded eth-utils and hexbytes to stable versions

•   Add pypy3 support

  v0.1.0-alpha.2

Released Jan 30, 2018

•   First working version

•   Some docs

•   New basic tests, that pass

  v0.1.0-alpha.1

•   Launched repository, claimed names for pip, RTD, github, etc

  Contributing

Thank you for your interest in contributing! We welcome all contributions no matter their size. Please read along to learn how to get started. If you get stuck, feel free to ask for help in Ethereum Python Discord server <https://discord.gg/GHryRvPB84>.

  Setting the stage

To get started, fork the repository to your own github account, then clone it to your development machine:

    git clone git@github.com:your-github-username/eth-rlp.git

Next, install the development dependencies with uv <https://docs.astral.sh/uv/>. The dev dependency group is installed by default, so uv sync is enough for a local development environment.

    cd eth-rlp
    uv sync
    uv run prek install

  Running the tests

A great way to explore the code base is to run the tests.

We can run all tests with:

    uv run --group test pytest tests

  Code Style

We use prek <https://prek.j178.dev> to enforce a consistent code style across the library. This tool runs automatically with every commit, but you can also run it manually with:

    uv run --group lint ruff check .
    uv run --group lint ruff format .
    uv run --group lint mypy -p eth_rlp

If you need to make a commit that skips the prek checks, you can do so with git commit --no-verify.

This library uses type hints, which are enforced by the mypy tool (part of the prek checks). All new code is required to land with type hints, with the exception of code within the tests directory.

  Documentation

Good documentation will lead to quicker adoption and happier users. Please check out our guide on how to create documentation for the Python Ethereum ecosystem <https://github.com/ethereum/snake-charmers-tactical-manual/blob/main/documentation.md>.

  Pull Requests

It's a good idea to make pull requests early on. A pull request represents the start of a discussion, and doesn't necessarily need to be the final, finished submission.

GitHub's documentation for working on pull requests is available here <https://docs.github.com/pull-requests/collaborating-with-pull-requests/proposing-changes-to-your-work-with-pull-requests/about-pull-requests>.

Once you've made a pull request, take a look at the GitHub Actions status in the GitHub interface and make sure all tests are passing. In general pull requests that do not pass the CI build yet won't get reviewed unless explicitly requested.

Release notes are managed through GitHub Releases.

  Releasing

Releases are typically done from the main branch, except when releasing a beta (in which case the beta is released from main, and the previous stable branch is released from said branch).

  Final review before each release

Before releasing a new version, build and test the package that will be released:

    git checkout main && git pull
    uv build

Review the documentation that will get published:

    uv run --group docs sphinx-build -W -b html docs docs/_build/html
    uv run --group docs sphinx-build -W -b doctest docs docs/_build/doctest

  Push the release to github & pypi

After confirming that the release package looks okay, create a GitHub Release for the target version. GitHub creates the release tag, setuptools-scm derives the package version from that tag during the release workflow, and GitHub Actions publishes to PyPI through trusted publishing.

  Code of Conduct

  Our Pledge

In the interest of fostering an open and welcoming environment, we as contributors and maintainers pledge to make participation in our project and our community a harassment-free experience for everyone, regardless of age, body size, disability, ethnicity, gender identity and expression, level of experience, education, socio-economic status, nationality, personal appearance, race, religion, or sexual identity and orientation.

  Our Standards

Examples of behavior that contributes to creating a positive environment include:

•   Using welcoming and inclusive language

•   Being respectful of differing viewpoints and experiences

•   Gracefully accepting constructive criticism

•   Focusing on what is best for the community

•   Showing empathy towards other community members

    Examples of unacceptable behavior by participants include:

•   The use of sexualized language or imagery and unwelcome sexual attention or advances

•   Trolling, insulting/derogatory comments, and personal or political attacks

•   Public or private harassment

•   Publishing others' private information, such as a physical or electronic address, without explicit permission

•   Other conduct which could reasonably be considered inappropriate in a professional setting

  Our Responsibilities

Project maintainers are responsible for clarifying the standards of acceptable behavior and are expected to take appropriate and fair corrective action in response to any instances of unacceptable behavior.

Project maintainers have the right and responsibility to remove, edit, or reject comments, commits, code, wiki edits, issues, and other contributions that are not aligned to this Code of Conduct, or to ban temporarily or permanently any contributor for other behaviors that they deem inappropriate, threatening, offensive, or harmful.

  Scope

This Code of Conduct applies both within project spaces and in public spaces when an individual is representing the project or its community. Examples of representing a project or community include using an official project e-mail address, posting via an official social media account, or acting as an appointed representative at an online or offline event. Representation of a project may be further defined and clarified by project maintainers.

  Enforcement

Instances of abusive, harassing, or otherwise unacceptable behavior may be reported by contacting the project team at <snakecharmers@ethereum.org>. All complaints will be reviewed and investigated and will result in a response that is deemed necessary and appropriate to the circumstances. The project team is obligated to maintain confidentiality with regard to the reporter of an incident. Further details of specific enforcement policies may be posted separately.

Project maintainers who do not follow or enforce the Code of Conduct in good faith may face temporary or permanent repercussions as determined by other members of the project's leadership.

  Attribution

This Code of Conduct is adapted from the Contributor Covenant <https://www.contributor-covenant.org>, version 1.4, available at <https://www.contributor-covenant.org/version/1/4/code-of-conduct.html>

Author
The Ethereum Foundation

Copyright
2018-2025, The Ethereum Foundation