UNPKG

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

57 lines (56 loc) 2.37 kB
import type { EvmNetwork } from '../../Explorer/EvmExplorer'; import type { MarketsResponse } from '../../Client'; import type { TTLCache } from '../../utils/TTLCache'; import { NetworkDescriptor } from './NetworkDescriptor'; import type { NetworkInfoInternal, EvmAddressType } from './types'; /** A {@link NetworkDescriptor} whose {@link id} is an EVM network. */ export declare class EvmNetworkDescriptor extends NetworkDescriptor<EvmAddressType> { readonly id: EvmNetwork; /** @internal */ constructor(id: EvmNetwork, info: NetworkInfoInternal, marketsCache: TTLCache<MarketsResponse>, apiKey?: string); /** * Derives an EIP-55 checksummed Ethereum address from a public key. * * @param publicKey - Compressed or uncompressed secp256k1 public key. */ publicKeyToAddress(publicKey: Uint8Array): string; /** * Checks whether a string is a valid EVM address for this network. * * Accepts both checksummed and all-lowercase/all-uppercase forms. * When the address uses mixed case, the EIP-55 checksum is verified. * * @param address - The address string to validate. * @returns `true` if the address is valid. */ isValidAddress(address: string): boolean; /** * Signs a message using EIP-191 personal sign (the same scheme as MetaMask's * `personal_sign`). * * @param message - The message to sign (string or raw bytes). * @param privateKey - The 32-byte secp256k1 private key. * @returns The 65-byte signature as a hex string with `0x` prefix. * * @example * ```ts * const key = await wallet.derive("m/44'/60'/0'/0/0"); * const sig = cg.networks.ethereum.signMessage('Hello', key.privateKey.raw); * ``` */ signMessage(message: string | Uint8Array, privateKey: Uint8Array): string; /** * Verifies an EIP-191 personal sign signature. * * @param message - The original message. * @param signature - The signature hex string (with `0x` prefix). * @param address - The expected signer address. * @returns `true` if the signature is valid. * * @example * ```ts * const valid = cg.networks.ethereum.verifyMessage('Hello', sig, '0xAb5801a7...'); * ``` */ verifyMessage(message: string | Uint8Array, signature: string, address: string): boolean; }