Skip to content

Yenya030/ethereum-rlp

 
 

Repository files navigation

Ethereum RLP

Recursive-length prefix (RLP) serialization as used by the Ethereum Execution Layer Specification (EELS).

Usage

Here's a very basic example demonstrating how to define a schema, then encode/decode it:

from dataclasses import dataclass
from ethereum_rlp import encode, decode_to
from ethereum_types.numeric import Uint
from typing import List

@dataclass
class Stuff:
    toggle: bool
    number: Uint
    sequence: List["Stuff"]

encoded = encode(Stuff(toggle=True, number=Uint(3), sequence=[]))
decoded = decode_to(Stuff, encoded)
assert decoded.number == Uint(3)

See the tests/ directory for more examples.

About

Recursive-length prefix (RLP) serialization as used by the Ethereum Specification.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • Python 100.0%