#offline #sign #transaction #ethereum

ethereum-tx-sign

Allows you to sign Ethereum transactions offline

15 stable releases (5 major)

Uses old Rust 2015

6.1.3 Mar 19, 2024
6.1.2 May 23, 2023
6.1.1 Apr 14, 2023
6.1.0 Nov 29, 2022
0.0.2 Aug 31, 2018

#24 in #sign

Download history 174/week @ 2024-07-02 205/week @ 2024-07-09 180/week @ 2024-07-16 190/week @ 2024-07-23 621/week @ 2024-07-30 238/week @ 2024-08-06 244/week @ 2024-08-13 206/week @ 2024-08-20 311/week @ 2024-08-27 232/week @ 2024-09-03 180/week @ 2024-09-10 162/week @ 2024-09-17 443/week @ 2024-09-24 250/week @ 2024-10-01 145/week @ 2024-10-08 132/week @ 2024-10-15

1,029 downloads per month
Used in 3 crates

MIT license

58KB
1K SLoC

Rust 822 SLoC // 0.0% comments JavaScript 196 SLoC // 0.0% comments

ethereum-tx-sign

This is a Rust library that allows you to create and sign Ethereum transactions. It can work completely offline and does not require external software such as Web3. Legacy and access list transactions are supported (EIP-155 and EIP-2930 respectively).

Build Status

Usage

Native Rust types are used for transaction fields:

use ethereum_tx_sign::LegacyTransaction;

let new_transaction = LegacyTransaction {
    chain: 1,
    nonce: 0,
    to: Some([0; 20]),
    value: 1675538,
    gas_price: 250,
    gas: 21000,
    data: vec![/* contract code or other data */],
}

Signing a transaction is performed in two steps. First you get the ECDSA using your private key. Then sign the transaction using it.

let ecdsa = new_transaction.ecdsa(&private_key_32_bytes);
let transaction_bytes = new_transaction.sign(&ecdsa);

transaction_bytes is now a Vec<u8> containing the serialized transaction ready to be sent.

See the Rust documentation on docs.rs for more information and examples.

Contributing

This repository accepts contributions. Do not hesitate to raise an issue for any queries, issues, or suggestions. Pull requests must meet the following criteria:

  1. Target branch is development.
  2. It fixes a bug, supports a new EIP, or improves the library for >50% of all users.
  3. You have 95% unit test coverage and all tests pass.
  4. Semantic versioning is followed.
  5. Changes introduce breaking changes only as last resort.

To generate reference test data, see test/generate.

@synlestidae is the repository owner and will oversee all contributions.

Acknowledgements

Thank you to these people for their contributions:

  • 34x4p08
  • tritone11
  • rodoufuT
  • victor-wei126

Dependencies

~6.5MB
~77K SLoC