khodpay_signing/lib.rs
1//! # Khodpay Signing
2//!
3//! EVM transaction signing library for BSC (BNB Smart Chain) and other EVM-compatible chains.
4//!
5//! This crate provides EIP-1559 (Type 2) transaction signing, integrating with
6//! `khodpay-bip44` for HD wallet key derivation.
7//!
8//! ## Features
9//!
10//! - **EIP-1559 Transactions**: Modern fee market transactions
11//! - **BSC Support**: Native support for BNB Smart Chain (mainnet/testnet)
12//! - **BIP-44 Integration**: Seamless key derivation from HD wallets
13//! - **BEP-20 Helpers**: Token transfer encoding utilities
14//!
15//! ## Quick Start
16//!
17//! ```rust,ignore
18//! use khodpay_signing::{Eip1559Transaction, ChainId, Wei, Bip44Signer};
19//! use khodpay_bip44::{Wallet, Purpose, CoinType, Language};
20//! use khodpay_bip32::Network;
21//!
22//! // Create wallet and get account
23//! let mnemonic = "your twelve word mnemonic phrase here";
24//! let mut wallet = Wallet::from_mnemonic(mnemonic, "", Language::English, Network::BitcoinMainnet)?;
25//! let account = wallet.get_account(Purpose::BIP44, CoinType::Ethereum, 0)?;
26//!
27//! // Create signer
28//! let signer = Bip44Signer::new(account, 0)?;
29//!
30//! // Build transaction
31//! let tx = Eip1559Transaction::builder()
32//! .chain_id(ChainId::BscMainnet)
33//! .nonce(0)
34//! .to("0x...".parse()?)
35//! .value(Wei::from_ether(1))
36//! .gas_limit(21000)
37//! .max_fee_per_gas(Wei::from_gwei(5))
38//! .max_priority_fee_per_gas(Wei::from_gwei(1))
39//! .build()?;
40//!
41//! // Sign and get raw transaction
42//! let signed = signer.sign_transaction(&tx)?;
43//! let raw_tx = signed.to_raw_transaction();
44//! ```
45
46#![warn(missing_docs)]
47#![warn(rustdoc::broken_intra_doc_links)]
48#![deny(unsafe_code)]
49
50mod access_list;
51mod address;
52mod chain_id;
53mod error;
54mod rlp_encode;
55mod signature;
56mod signed_transaction;
57mod signer;
58mod transaction;
59mod wei;
60
61pub use access_list::{AccessList, AccessListItem};
62pub use address::Address;
63pub use chain_id::ChainId;
64pub use error::Error;
65pub use signature::Signature;
66pub use signed_transaction::SignedTransaction;
67pub use signer::{recover_signer, Bip44Signer};
68pub use transaction::{
69 Eip1559Transaction, Eip1559TransactionBuilder, TOKEN_TRANSFER_GAS, TRANSFER_GAS,
70};
71pub use wei::{Wei, ETHER, GWEI};
72
73/// Result type alias for signing operations.
74pub type Result<T> = std::result::Result<T, Error>;