alloy-eip8141 0.1.1

Implementation of EIP-8141 type definitions
Documentation

EIP-8141 frame transaction constants and types.

Targets, signers, and signed messages are typed: [FrameAddress] distinguishes an omitted address from an explicit one and [SignatureMessage] distinguishes the canonical transaction hash from an explicit digest. Decoding rejects malformed lengths and the reserved zero digest but not the remaining signature constraints: call [FrameSignature::validate_structure] or [FrameSignature::validate_structure_with_sender] before cryptographic verification.

The serde feature encodes protocol discriminants and gas counters as hex quantities, and optional addresses and signature messages as hex byte strings (empty values are "0x").

use alloy_eip8141::{FrameAddress, FrameSignature, SignatureMessage};
use alloy_primitives::{Signature, U256};

// Construct a structurally valid entry; the signature still needs cryptographic verification.
let signature = Signature::new(U256::from(1), U256::from(2), false);
let entry = FrameSignature::from_secp256k1(
    FrameAddress::Empty,
    SignatureMessage::TransactionHash,
    signature,
)?;
assert!(entry.signs_transaction_hash());
assert_eq!(entry.secp256k1_signature(), Some(signature));
# Ok::<(), alloy_eip8141::Eip8141Error>(())