112 releases (52 stable)

new 1.7.4 Mar 9, 2026
1.5.2 Jan 22, 2026
1.2.1 Dec 23, 2025
1.1.2 Nov 20, 2025
0.0.0-reserved Nov 23, 2023

#495 in Magic Beans

Download history 143516/week @ 2025-11-18 136851/week @ 2025-11-25 156526/week @ 2025-12-02 156267/week @ 2025-12-09 131139/week @ 2025-12-16 82682/week @ 2025-12-23 95456/week @ 2025-12-30 164876/week @ 2026-01-06 172237/week @ 2026-01-13 176976/week @ 2026-01-20 178980/week @ 2026-01-27 200382/week @ 2026-02-03 194036/week @ 2026-02-10 201146/week @ 2026-02-17 207900/week @ 2026-02-24 236786/week @ 2026-03-03

876,103 downloads per month
Used in 460 crates (58 directly)

MIT/Apache

25KB
379 lines

alloy-signer

Ethereum signer abstraction.

You can implement the Signer trait to extend functionality to other signers such as Hardware Security Modules, KMS etc. See its documentation for more.

Signer implementations in Alloy:

Examples

Sign an Ethereum prefixed message (EIP-712):

use alloy_signer::{Signer, SignerSync};
use alloy_signer_local::PrivateKeySigner;

// Instantiate a signer.
let signer = PrivateKeySigner::random();

// Sign a message.
let message = "Some data";
let signature = signer.sign_message_sync(message.as_bytes())?;

// Recover the signer from the message.
let recovered = signature.recover_address_from_msg(message)?;
assert_eq!(recovered, signer.address());
# Ok::<_, Box<dyn std::error::Error>>(())

Sign a transaction:

use alloy_consensus::TxLegacy;
use alloy_primitives::{U256, address, bytes};
use alloy_signer::{Signer, SignerSync};
use alloy_signer_local::PrivateKeySigner;
use alloy_network::TxSignerSync;

// Instantiate a signer.
let signer = "dcf2cbdd171a21c480aa7f53d77f31bb102282b3ff099c78e3118b37348c72f7"
    .parse::<PrivateKeySigner>()?;

// Create a transaction.
let mut tx = TxLegacy {
    to: address!("d8dA6BF26964aF9D7eEd9e03E53415D37aA96045").into(),
    value: U256::from(1_000_000_000),
    gas_limit: 2_000_000,
    nonce: 0,
    gas_price: 21_000_000_000,
    input: bytes!(),
    chain_id: Some(1),
};

// Sign it.
let signature = signer.sign_transaction_sync(&mut tx)?;
# Ok::<_, Box<dyn std::error::Error>>(())

Dependencies

~20MB
~432K SLoC