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§
sourcefn set_chain_id(&mut self, chain_id: ChainId)
fn set_chain_id(&mut self, chain_id: ChainId)
Sets chain_id
.
Prefer set_chain_id_checked
.
sourcefn encode_for_signing(&self, out: &mut dyn BufMut)
fn encode_for_signing(&self, out: &mut dyn BufMut)
RLP-encodes the transaction for signing.
sourcefn payload_len_for_signature(&self) -> usize
fn payload_len_for_signature(&self) -> usize
Outputs the length of the signature RLP encoding for the transaction.
sourcefn into_signed(self, signature: Signature) -> Signed<Self, Signature>where
Self: Sized,
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§
sourcefn use_eip155(&self) -> bool
fn use_eip155(&self) -> bool
True if the transaction uses EIP-155 signatures.
sourcefn set_chain_id_checked(&mut self, chain_id: ChainId) -> bool
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.
sourcefn encoded_for_signing(&self) -> Vec<u8> ⓘ
fn encoded_for_signing(&self) -> Vec<u8> ⓘ
RLP-encodes the transaction for signing it. Used to calculate signature_hash
.
sourcefn signature_hash(&self) -> B256
fn signature_hash(&self) -> B256
Calculate the signing hash for the transaction.