View Source Ethers.Transaction.Signed (Ethers v0.6.3)
A struct that wraps a transaction and its signature values.
Summary
Types
A transaction signature envelope that wraps transaction data with its signature components.
Functions
Calculates the y-parity or v value for transaction signatures.
Calculates the from address of a signed transaction using its signature.
Types
@type t() :: %Ethers.Transaction.Signed{ metadata: Ethers.Transaction.Metadata.t() | nil, payload: Ethers.Transaction.t_payload(), signature_r: binary(), signature_s: binary(), signature_y_parity_or_v: non_neg_integer() }
A transaction signature envelope that wraps transaction data with its signature components.
This type supports both Legacy (pre-EIP-155), EIP-155 Legacy, and EIP-1559 transaction formats. The signature components consist of:
signature_r
,signature_s
: The ECDSA signature values as defined in Ethereum's Yellow Papersignature_y_parity_or_v
: The recovery value that varies by transaction type:- For pre-EIP-155 Legacy transactions: v = recovery_id + 27
- For EIP-155 Legacy transactions: v = recovery_id + chain_id * 2 + 35
- For EIP-1559 transactions: Just the recovery_id (0 or 1) as specified in EIP-2930
Related EIPs:
Functions
@spec calculate_y_parity_or_v( Ethers.Transaction.t_payload(), binary() | non_neg_integer() ) :: non_neg_integer()
Calculates the y-parity or v value for transaction signatures.
Handles both legacy and EIP-1559 transaction types according to their specifications.
Parameters
tx
- Transaction structrecovery_id
- Recovery ID from the signature
Returns
integer
- Calculated y-parity or v value
@spec from_address(t()) :: {:ok, Ethers.Types.t_address()} | {:error, atom()}
Calculates the from address of a signed transaction using its signature.
The from address is inferred from the signature of the transaction rather than being explicitly specified. This is done by recovering the signer's public key from the signature and then deriving the corresponding Ethereum address.
Returns
{:ok, address}
- Successfully recovered from address{:error, reason}
- Failed to recover address