chaingate
Version:
Multi-chain cryptocurrency SDK for TypeScript — unified API for Bitcoin, Ethereum, Litecoin, Dogecoin, Bitcoin Cash, Polygon, Arbitrum, and any EVM-compatible chain. Create wallets, query balances, send transactions, and manage tokens and NFTs across UTXO
62 lines (61 loc) • 2.15 kB
TypeScript
/**
* EIP-1559 (type-2) transaction serialization and signing.
*
* Produces the signed raw transaction hex ready for broadcast.
*/
/** Parameters for an EIP-1559 transaction. All numeric values are in wei (bigint). */
export interface Eip1559TxParams {
/** Chain ID (e.g. 1 for Ethereum mainnet). */
chainId: bigint;
/** Sender nonce. */
nonce: bigint;
/** Max priority fee per gas (tip) in wei. */
maxPriorityFeePerGas: bigint;
/** Max fee per gas (base + tip cap) in wei. */
maxFeePerGas: bigint;
/** Gas limit. */
gasLimit: bigint;
/** Recipient address (20 bytes hex with 0x prefix). */
to: string;
/** Value to send in wei. */
value: bigint;
/** Calldata (hex with 0x prefix). Empty for plain ETH transfers. */
data: string;
}
/**
* Signs an EIP-1559 transaction and returns the raw signed transaction hex
* ready for broadcast (with `0x` prefix).
*
* @param tx - Transaction parameters.
* @param privateKey - 32-byte private key.
* @returns Signed raw transaction as a hex string with `0x` prefix.
*/
export declare function signEip1559Transaction(tx: Eip1559TxParams, privateKey: Uint8Array): string;
/** Parameters for a legacy (pre-EIP-1559) transaction. All numeric values in wei (bigint). */
export interface LegacyTxParams {
/** Chain ID (e.g. 56 for BSC). */
chainId: bigint;
/** Sender nonce. */
nonce: bigint;
/** Gas price in wei. */
gasPrice: bigint;
/** Gas limit. */
gasLimit: bigint;
/** Recipient address (20 bytes hex with 0x prefix). */
to: string;
/** Value to send in wei. */
value: bigint;
/** Calldata (hex with 0x prefix). Empty for plain transfers. */
data: string;
}
/**
* Signs a legacy (type-0) transaction and returns the raw signed transaction hex
* ready for broadcast (with `0x` prefix).
*
* Uses EIP-155 replay protection.
*
* @param tx - Transaction parameters.
* @param privateKey - 32-byte private key.
* @returns Signed raw transaction as a hex string with `0x` prefix.
*/
export declare function signLegacyTransaction(tx: LegacyTxParams, privateKey: Uint8Array): string;