Transaction Signing
Functions to create and sign transactions.
This module provides functions for creating and signing transactions.
- ledgereth.transactions.create_transaction(destination: str | bytes, amount: int, gas: int, nonce: int, data: str | bytes = b'', gas_price: int | None = None, max_priority_fee_per_gas: int | None = None, max_fee_per_gas: int | None = None, chain_id: int = 1, sender_path: str = "44'/60'/0'/0/0", access_list: list[tuple[bytes, Sequence[str | int]]] | list[tuple[str, Sequence[str | int]]] | list[tuple[bytes, list[int]]] | None = None, dongle: Dongle | None = None) SignedTransaction [source]
Create and sign a transaction from given arguments.
- Parameters:
destination – (
str|bytes
) - Destination address (AKAto
)amount – (
int
) - Transaction value in weigas – (
int
) - Gas limit for the transactionnonce – (
int
) - Nonce for the transactiondata – (
str|bytes
) - Transaction data (e.g. contract calldata)gas_price – (
int|None
) - Gas price in wei to use for the transaction. This is not compatible withmax_fee_per_gas
.max_priority_fee_per_gas – (
int|None
) - Priority fee per gas (in wei) to provide to the miner of the block.max_fee_per_gas – (
int|None
) - Maximum fee in wei to pay for the transaction. This is not compatible withgas_price
.chain_id – (
int
) - Chain ID to limit the transaction to. Defaults to1
.sender_path – (
str
) - BIP-44 HD derivation path for the account to sign with. Defaults to first account in the default derivation path.access_list – (
List[Tuple[bytes, List[int]]]
) - EIP-2930 access list to use for the transaction.dongle – (
ledgerblue.Dongle.Dongle
) - The Dongle instance to use to communicate with the Ledger device
- Returns:
ledgereth.objects.SignedTransaction
instance for transaction
- ledgereth.transactions.decode_transaction(rawtx: bytes, signed: bool = False) SerializableTransaction [source]
Decode a raw transaction to a Serializable transaction object.
- Parameters:
rawtx – (
bytes
) - Raw transaction to decodesigned – (
bool
) - If the raw transaction is a signed transaction.
- Returns:
Decoded
ledgereth.objects.SerializableTransaction
instance for transaction
- ledgereth.transactions.sign_transaction(tx: Serializable, sender_path: str = "44'/60'/0'/0/0", dongle: Dongle | None = None) SignedTransaction [source]
Sign a
rlp.Serializable
transaction object.Compatible with both ledgereth and web3.py transaction objects.
- Parameters:
tx – (
rlp.Serializable
) - Serializable transaction object to signsender_path – (
str
) - HID derivation path for the account to sign with. Defaults to first account in the derivation path.dongle – (
ledgerblue.Dongle.Dongle
) - The Dongle instance to use to communicate with the Ledger device
- Returns:
ledgereth.objects.SignedTransaction
instance for transaction