eth-rlp

RLP definitions for common Ethereum objects in Python

Install with

pip install eth_rlp

Import with

from eth_rlp import HashableRLP

Contents

eth_rlp package

HashableRLP

class eth_rlp.main.HashableRLP(*args, **kwargs)

An extension of 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[str, Any]

Convert rlp object to a dict

Returns:

mapping of RLP field names to field values

Return type:

dict

classmethod from_bytes(serialized_bytes: bytes | bytearray) Self

Shorthand invocation for rlp.decode() using this class.

Parameters:

serialized_bytes (bytes) – the byte string to decode

Returns:

the decoded object

Return type:

HashableRLP

classmethod from_dict(field_dict: Dict[str, 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) – the dictionary of values to initialize with

Returns:

the new rlp object

Return type:

HashableRLP

hash() HexBytes
Returns:

the hash of the encoded bytestring

Return type:

HexBytes

Release Notes

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)

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

Breaking Changes
  • Bump hexbytes dependency to >=1.0.0 (#21)

Features
  • Add Python 3.12 support (#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)

  • Add py.typed file, move misplaced newsfragment, correct py version pins for typing-extensions (#21)

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

Bugfixes
  • Add the missing typing_extensions module requirement for Python <= 3.11 (#19)

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

Breaking Changes
  • Drop python 3.7 support (#16)

Features
  • Add python 3.11 support (#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)

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)

  • Require eth-utils>=2.0,<3 (#14)

Deprecations and Removals
  • Remove support for Python 3.6 (#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)

Deprecations and Removals
  • Dropped py3.5 support (#7)

Miscellaneous changes
  • Merge updates from the project template (#7)

v0.1.2

Released April 25, 2018

  • Add 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

Indices and tables