Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rlp decode cant support decode EIP1559 rawtransaction #139

Open
CaiJiJi opened this issue Jun 16, 2023 · 1 comment
Open

rlp decode cant support decode EIP1559 rawtransaction #139

CaiJiJi opened this issue Jun 16, 2023 · 1 comment

Comments

@CaiJiJi
Copy link

CaiJiJi commented Jun 16, 2023


import rlp
from eth_typing import HexStr
from eth_utils import to_bytes

def hex_to_bytes(data: str) -> bytes:
    return to_bytes(hexstr=HexStr(data))


signed_transaction = '0x02f86b0580847735940085012a05f2008252089498b6ded3b7f2268e2ff997ff9371fdb11945838e7b80c080a0ea398ca69a80cdc2f11106717b1168db06503759c37e2e2fbb525d474fe4750ca00568d8b50e6e162cae79535541c367e05e80122c4f3647dea0aeff19995cd9a0'

tx = rlp.decode(hex_to_bytes(signed_transaction))

Error info

rlp.exceptions.DecodingError: RLP string ends with 109 superfluous bytes

But on https://rawtxdecode.in/

decode result is right

image

@eerkaijun
Copy link

EIP1559 transactions use the first byte as the typed transaction envelope (refer to https://eips.ethereum.org/EIPS/eip-2718). Therefore to decode the RLP correctly, you'll need to remove the first byte (i.e. 02 in your case).

Using your above example, 0xf86b0580847735940085012a05f2008252089498b6ded3b7f2268e2ff997ff9371fdb11945838e7b80c080a0ea398ca69a80cdc2f11106717b1168db06503759c37e2e2fbb525d474fe4750ca00568d8b50e6e162cae79535541c367e05e80122c4f3647dea0aeff19995cd9a0 should decode correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants