pub trait SignableTransaction<Signature>: Transaction {
    // Required methods
    fn set_chain_id(&mut self, chain_id: ChainId);
    fn encode_for_signing(&self, out: &mut dyn BufMut);
    fn payload_len_for_signature(&self) -> usize;
    fn into_signed(self, signature: Signature) -> Signed<Self, Signature>
       where Self: Sized;

    // Provided methods
    fn use_eip155(&self) -> bool { ... }
    fn set_chain_id_checked(&mut self, chain_id: ChainId) -> bool { ... }
    fn encoded_for_signing(&self) -> Vec<u8>  { ... }
    fn signature_hash(&self) -> B256 { ... }
}
Expand description

A signable transaction.

A transaction can have multiple signature types. This is usually [alloy_primitives::Signature], however, it may be different for future EIP-2718 transaction types, or in other networks. For example, in Optimism, the deposit transaction signature is the unit type ().

Required Methods§

source

fn set_chain_id(&mut self, chain_id: ChainId)

Sets chain_id.

Prefer set_chain_id_checked.

source

fn encode_for_signing(&self, out: &mut dyn BufMut)

RLP-encodes the transaction for signing.

source

fn payload_len_for_signature(&self) -> usize

Outputs the length of the signature RLP encoding for the transaction.

source

fn into_signed(self, signature: Signature) -> Signed<Self, Signature>
where Self: Sized,

Convert to a signed transaction by adding a signature and computing the hash.

Provided Methods§

source

fn use_eip155(&self) -> bool

True if the transaction uses EIP-155 signatures.

source

fn set_chain_id_checked(&mut self, chain_id: ChainId) -> bool

Set chain_id if it is not already set. Checks that the provided chain_id matches the existing chain_id if it is already set, returning false if they do not match.

source

fn encoded_for_signing(&self) -> Vec<u8>

RLP-encodes the transaction for signing it. Used to calculate signature_hash.

See SignableTransaction::encode_for_signing.

source

fn signature_hash(&self) -> B256

Calculate the signing hash for the transaction.

Implementors§

source§

impl SignableTransaction<Signature<Signature<Secp256k1>>> for TxEip4844Variant

source§

impl SignableTransaction<Signature<Signature<Secp256k1>>> for TxEip1559

source§

impl SignableTransaction<Signature<Signature<Secp256k1>>> for TxEip2930

source§

impl SignableTransaction<Signature<Signature<Secp256k1>>> for TxEip4844

source§

impl SignableTransaction<Signature<Signature<Secp256k1>>> for TxEip4844WithSidecar

source§

impl SignableTransaction<Signature<Signature<Secp256k1>>> for TxLegacy