Transaction Signing

Functions to create and sign transactions.

ledgereth.transactions.create_transaction(destination: Union[str, bytes], amount: int, gas: int, nonce: int, data: Union[str, bytes] = b'', gas_price: int = 0, max_priority_fee_per_gas: int = 0, max_fee_per_gas: int = 0, chain_id: int = 1, sender_path: str = "44'/60'/0'/0/0", access_list: Optional[List[Tuple[Union[bytes, str], List[int]]]] = None, dongle: Optional[ledgerblue.Dongle.Dongle] = None) ledgereth.objects.SignedTransaction[source]

Create and sign a transaction from given arguments.

Parameters
  • destination – (str|bytes) - Destination address (AKA to)

  • amount – (int) - Transaction value in wei

  • gas – (int) - Gas limit for the transaction

  • nonce – (int) - Nonce for the transaction

  • data – (str|bytes) - Transaction data (e.g. contract calldata)

  • gas_price – (int) - Gas price in wei to use for the transaction. This is not compatible with max_fee_per_gas.

  • max_priority_fee_per_gas – (int) - Priority fee per gas (in wei) to provide to the miner of the block.

  • max_fee_per_gas – (int) - Maximum fee in wei to pay for the transaction. This is not compatible with gas_price.

  • chain_id – (int) - Chain ID to limit the transaction to. Defaults to 1.

  • 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) ledgereth.objects.SerializableTransaction[source]

Decode a raw transaction to a Serializable transaction object

Parameters
  • rawtx – (bytes) - Raw transaction to decode

  • signed – (bool) - If the raw transaction is a signed transaction.

Returns

Decoded ledgereth.objects.SerializableTransaction instance for transaction

ledgereth.transactions.sign_transaction(tx: rlp.sedes.serializable.Serializable, sender_path: str = "44'/60'/0'/0/0", dongle: Optional[ledgerblue.Dongle.Dongle] = None) ledgereth.objects.SignedTransaction[source]

Sign a rlp.Serializable transaction object. Compatible with ledgereth and web3.py transaction objects.

Parameters
  • tx – (rlp.Serializable) - Serializable transaction object to sign

  • sender_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