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 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 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.