import { Signer, JsonRpcProvider, Provider, TransactionReceipt } from 'ethers'; import { TokenConfig, Address } from './types/deploy-config'; import { ChainConfig } from './types/token-data'; /** * Result of a successful token deployment. */ export interface DeploymentResult { /** Transaction hash of the deployment */ readonly txHash: `0x${string}`; /** Deployed token contract address */ readonly tokenAddress: Address; } /** * Gas estimation for a token deployment. */ export interface GasEstimation { /** Estimated gas limit */ readonly gasLimit: bigint; /** Factory creation fee in wei */ readonly creationFee: bigint; } /** * Human-readable ABI for LaunchERC20Factory contract. * Contains only the functions needed for token deployment. */ export declare const FACTORY_ABI: readonly ["function createToken((string name, string symbol, uint8 decimals, uint256 initialSupply, address finalOwner, bool mintingEnabled, uint256 hardCap, bool pausable, bool rescueEnabled, bool burnEnabled, bool metadataMutable, bool socialsMutable, bool feesModuleEnabled, bool limitsModuleEnabled, bool cooldownModuleEnabled, bool blacklistModuleEnabled, string website, string telegram, string xHandle, string discord, bool feesEnabled, uint16 maxBuyFeeBps, uint16 maxSellFeeBps, uint16 maxTransferFeeBps, uint16 buyFeeBps, uint16 sellFeeBps, uint16 transferFeeBps, uint16 feeBurnShareBps, address feeRecipient, uint256 maxWalletAmount, uint256 maxTxAmount, uint64 limitsEndTime, bool exemptRecipientsFromLimits, address[] additionalLimitExempt, uint32 maxCooldownSeconds, uint32 cooldownSeconds, address[] initialRecipients, uint256[] initialAmounts, string[] initialLabels, uint64 tradingSchedule, bool enableTradingImmediately, address router, bool routerProtectionEnabled, address[] initialBlacklist, bool freezeBlacklistAfterDeploy, bool renounceOwnership, bool useSalt, bytes32 salt, bool deadblocksEnabled, uint8 deadBlocks, uint8 deadblockMode, bool deadblockExemptLimitExempt, bool whitelistModuleEnabled, uint8 whitelistMode, bool whitelistAutoDisable, bool whitelistBypassesRouter, bool whitelistMutable, address[] initialWhitelist, bool freezeWhitelistAfterDeploy, bool antiDumpModuleEnabled, uint8 antiDumpType, uint256 maxAntiDumpLimit, uint64 maxAntiDumpPeriod, uint256 antiDumpLimit, uint64 antiDumpPeriod, uint64 antiDumpEndTime, uint8 batchTransferAccess, uint8 batchTransferFees, uint16 maxBatchSize, bool permitEnabled, bool freezeFeesAfterDeploy, bool freezeLimitsAfterDeploy, bool freezeCooldownAfterDeploy, bool freezeAntiDumpAfterDeploy, bool blockOwnershipTransferAfterDeploy) p) payable returns (address)", "function getCreationFee() view returns (uint256 fee)", "function predictAddress(bytes32 salt) view returns (address)", "function implementation() view returns (address)", "event TokenCreated(address indexed token, address indexed owner, bytes32 salt)"]; /** * Full JSON ABI for LaunchERC20Factory contract. * Use this if you need the full ABI structure for contract interactions. */ export declare const FACTORY_ABI_JSON: readonly [{ readonly type: "function"; readonly name: "createToken"; readonly inputs: readonly [{ readonly name: "p"; readonly type: "tuple"; readonly components: readonly [{ readonly name: "name"; readonly type: "string"; }, { readonly name: "symbol"; readonly type: "string"; }, { readonly name: "decimals"; readonly type: "uint8"; }, { readonly name: "initialSupply"; readonly type: "uint256"; }, { readonly name: "finalOwner"; readonly type: "address"; }, { readonly name: "mintingEnabled"; readonly type: "bool"; }, { readonly name: "hardCap"; readonly type: "uint256"; }, { readonly name: "pausable"; readonly type: "bool"; }, { readonly name: "rescueEnabled"; readonly type: "bool"; }, { readonly name: "burnEnabled"; readonly type: "bool"; }, { readonly name: "metadataMutable"; readonly type: "bool"; }, { readonly name: "socialsMutable"; readonly type: "bool"; }, { readonly name: "feesModuleEnabled"; readonly type: "bool"; }, { readonly name: "limitsModuleEnabled"; readonly type: "bool"; }, { readonly name: "cooldownModuleEnabled"; readonly type: "bool"; }, { readonly name: "blacklistModuleEnabled"; readonly type: "bool"; }, { readonly name: "website"; readonly type: "string"; }, { readonly name: "telegram"; readonly type: "string"; }, { readonly name: "xHandle"; readonly type: "string"; }, { readonly name: "discord"; readonly type: "string"; }, { readonly name: "feesEnabled"; readonly type: "bool"; }, { readonly name: "maxBuyFeeBps"; readonly type: "uint16"; }, { readonly name: "maxSellFeeBps"; readonly type: "uint16"; }, { readonly name: "maxTransferFeeBps"; readonly type: "uint16"; }, { readonly name: "buyFeeBps"; readonly type: "uint16"; }, { readonly name: "sellFeeBps"; readonly type: "uint16"; }, { readonly name: "transferFeeBps"; readonly type: "uint16"; }, { readonly name: "feeBurnShareBps"; readonly type: "uint16"; }, { readonly name: "feeRecipient"; readonly type: "address"; }, { readonly name: "maxWalletAmount"; readonly type: "uint256"; }, { readonly name: "maxTxAmount"; readonly type: "uint256"; }, { readonly name: "limitsEndTime"; readonly type: "uint64"; }, { readonly name: "exemptRecipientsFromLimits"; readonly type: "bool"; }, { readonly name: "additionalLimitExempt"; readonly type: "address[]"; }, { readonly name: "maxCooldownSeconds"; readonly type: "uint32"; }, { readonly name: "cooldownSeconds"; readonly type: "uint32"; }, { readonly name: "initialRecipients"; readonly type: "address[]"; }, { readonly name: "initialAmounts"; readonly type: "uint256[]"; }, { readonly name: "initialLabels"; readonly type: "string[]"; }, { readonly name: "tradingSchedule"; readonly type: "uint64"; }, { readonly name: "enableTradingImmediately"; readonly type: "bool"; }, { readonly name: "router"; readonly type: "address"; }, { readonly name: "routerProtectionEnabled"; readonly type: "bool"; }, { readonly name: "initialBlacklist"; readonly type: "address[]"; }, { readonly name: "freezeBlacklistAfterDeploy"; readonly type: "bool"; }, { readonly name: "renounceOwnership"; readonly type: "bool"; }, { readonly name: "useSalt"; readonly type: "bool"; }, { readonly name: "salt"; readonly type: "bytes32"; }, { readonly name: "deadblocksEnabled"; readonly type: "bool"; }, { readonly name: "deadBlocks"; readonly type: "uint8"; }, { readonly name: "deadblockMode"; readonly type: "uint8"; }, { readonly name: "deadblockExemptLimitExempt"; readonly type: "bool"; }, { readonly name: "whitelistModuleEnabled"; readonly type: "bool"; }, { readonly name: "whitelistMode"; readonly type: "uint8"; }, { readonly name: "whitelistAutoDisable"; readonly type: "bool"; }, { readonly name: "whitelistBypassesRouter"; readonly type: "bool"; }, { readonly name: "whitelistMutable"; readonly type: "bool"; }, { readonly name: "initialWhitelist"; readonly type: "address[]"; }, { readonly name: "freezeWhitelistAfterDeploy"; readonly type: "bool"; }, { readonly name: "antiDumpModuleEnabled"; readonly type: "bool"; }, { readonly name: "antiDumpType"; readonly type: "uint8"; }, { readonly name: "maxAntiDumpLimit"; readonly type: "uint256"; }, { readonly name: "maxAntiDumpPeriod"; readonly type: "uint64"; }, { readonly name: "antiDumpLimit"; readonly type: "uint256"; }, { readonly name: "antiDumpPeriod"; readonly type: "uint64"; }, { readonly name: "antiDumpEndTime"; readonly type: "uint64"; }, { readonly name: "batchTransferAccess"; readonly type: "uint8"; }, { readonly name: "batchTransferFees"; readonly type: "uint8"; }, { readonly name: "maxBatchSize"; readonly type: "uint16"; }, { readonly name: "permitEnabled"; readonly type: "bool"; }, { readonly name: "freezeFeesAfterDeploy"; readonly type: "bool"; }, { readonly name: "freezeLimitsAfterDeploy"; readonly type: "bool"; }, { readonly name: "freezeCooldownAfterDeploy"; readonly type: "bool"; }, { readonly name: "freezeAntiDumpAfterDeploy"; readonly type: "bool"; }, { readonly name: "blockOwnershipTransferAfterDeploy"; readonly type: "bool"; }]; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "address"; }]; readonly stateMutability: "payable"; }, { readonly type: "function"; readonly name: "getCreationFee"; readonly inputs: readonly []; readonly outputs: readonly [{ readonly name: "fee"; readonly type: "uint256"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "predictAddress"; readonly inputs: readonly [{ readonly name: "salt"; readonly type: "bytes32"; }]; readonly outputs: readonly [{ readonly name: ""; readonly type: "address"; }]; readonly stateMutability: "view"; }, { readonly type: "function"; readonly name: "implementation"; readonly inputs: readonly []; readonly outputs: readonly [{ readonly name: ""; readonly type: "address"; }]; readonly stateMutability: "view"; }, { readonly type: "event"; readonly name: "TokenCreated"; readonly inputs: readonly [{ readonly name: "token"; readonly type: "address"; readonly indexed: true; }, { readonly name: "owner"; readonly type: "address"; readonly indexed: true; }, { readonly name: "salt"; readonly type: "bytes32"; readonly indexed: false; }]; readonly anonymous: false; }]; /** * EIP-1193 Provider interface (window.ethereum, WalletConnect, etc.) */ export interface EIP1193Provider { request: (args: { method: string; params?: unknown[]; }) => Promise; } /** * Wallet input for provider + account (used by Reown, wagmi, etc.) */ export interface WalletClientInput { /** EIP-1193 compatible provider */ provider: EIP1193Provider; /** Connected account address */ account: Address; } /** * Union type for all supported wallet inputs. * * Supported inputs: * - EIP1193Provider: window.ethereum, WalletConnect provider, etc. * - ethers.Signer: Already resolved ethers Signer * - WalletClientInput: Provider + account object (wagmi/viem style) * * @example Different wallet sources * ```typescript * // MetaMask/browser extension * const signer = await normalizeWallet(window.ethereum); * * // Already have an ethers Signer * const signer = await normalizeWallet(existingSigner); * * // wagmi/viem style wallet client * const signer = await normalizeWallet({ provider: walletClient, account: '0x...' }); * ``` */ export type WalletInput = EIP1193Provider | Signer | WalletClientInput; /** * Chain IDs that don't support EIP-1559 (use legacy gas pricing). * These chains require { type: 0 } in transaction options. */ export declare const LEGACY_CHAIN_IDS: Set; /** * Check if a chain uses legacy gas pricing (no EIP-1559). * * @param chainId - Chain ID to check * @returns True if chain requires legacy transactions */ export declare function isLegacyChain(chainId: number): boolean; /** * Normalize any wallet input to an ethers Signer. * * Handles: * - EIP-1193 providers (window.ethereum, WalletConnect) * - ethers.Signer (pass-through) * - WalletClientInput (provider + account from wagmi/viem) * * @param wallet - Wallet input in any supported format * @returns ethers Signer ready for transactions * @throws Error if wallet type is not supported or connection fails * * @example React with wagmi * ```typescript * import { useWalletClient } from 'wagmi'; * import { normalizeWallet } from '@escapehub/token-creator'; * * const { data: walletClient } = useWalletClient(); * const signer = await normalizeWallet(walletClient); * ``` * * @example Vue with ethers * ```typescript * import { normalizeWallet } from '@escapehub/token-creator'; * * const signer = await normalizeWallet(window.ethereum); * ``` * * @example Vanilla JS * ```typescript * import { normalizeWallet } from '@escapehub/token-creator'; * * // From MetaMask * const signer = await normalizeWallet(window.ethereum); * * // From existing signer (pass-through) * const signer = await normalizeWallet(existingSigner); * ``` */ export declare function normalizeWallet(wallet: WalletInput): Promise; /** * Encode TokenConfig into the CreateParams tuple for the factory contract. * * This function converts the high-level TokenConfig into the exact format * expected by the LaunchERC20Factory.createToken() function. * * @param config - Token configuration * @param salt - Optional vanity salt (bytes32 hex string, defaults to zero bytes) * @returns CreateParams struct ready for contract call * * @example * ```typescript * import { encodeTokenConfig, createDefaultConfig } from '@escapehub/token-creator'; * * const config = createDefaultConfig('My Token', 'MTK', '1000000', '0x...'); * const params = encodeTokenConfig(config); * // params is ready for contract.createToken(params) * ``` */ export declare function encodeTokenConfig(config: TokenConfig, salt?: string): Record; /** * Get the creation fee required by the factory contract. * * The factory charges a small fee (~$1 in native tokens) for each token deployment. * This fee is sent as msg.value when calling createToken(). * * @param provider - ethers Provider or Signer with provider * @param factoryAddress - Factory contract address * @returns Creation fee in wei (native token smallest unit) * * @example * ```typescript * import { getCreationFee } from '@escapehub/token-creator'; * import { JsonRpcProvider, formatEther } from 'ethers'; * * const provider = new JsonRpcProvider('https://rpc.sepolia.org'); * const fee = await getCreationFee(provider, '0x...'); * console.log('Fee:', formatEther(fee), 'ETH'); * ``` */ export declare function getCreationFee(provider: Provider | Signer, factoryAddress: Address): Promise; /** * Estimate gas for token deployment. * * Returns both the estimated gas limit and the creation fee required. * Use this to display estimated costs to users before deployment. * * @param provider - ethers Provider or Signer (must have a provider) * @param factoryAddress - Factory contract address * @param config - Token configuration * @param salt - Optional vanity salt (bytes32 hex string) * @returns Gas estimation including factory creation fee * * @example * ```typescript * import { estimateGas, createDefaultConfig } from '@escapehub/token-creator'; * import { formatEther, formatUnits } from 'ethers'; * * const config = createDefaultConfig('My Token', 'MTK', '1000000', '0x...'); * const estimation = await estimateGas(provider, '0x...', config); * * console.log('Gas limit:', estimation.gasLimit.toString()); * console.log('Creation fee:', formatEther(estimation.creationFee), 'ETH'); * ``` */ export declare function estimateGas(provider: Provider | Signer, factoryAddress: Address, config: TokenConfig, salt?: string): Promise; /** * Deploy a new token using the LaunchERC20Factory. * * This is the main deployment function. It: * 1. Encodes the token configuration * 2. Fetches the creation fee * 3. Sends the createToken transaction * 4. Waits for confirmation * 5. Extracts the token address from events * * Handles legacy chains (no EIP-1559) automatically. * * @param wallet - Wallet input (will be normalized to Signer) * @param config - Token configuration * @param chainConfig - Chain configuration with factory address * @param salt - Optional vanity salt (bytes32 hex string) * @returns Deployment result with transaction hash and token address * * @example React with wagmi * ```tsx * import { deployToken, createDefaultConfig } from '@escapehub/token-creator'; * import { useWalletClient } from 'wagmi'; * * function DeployButton() { * const { data: walletClient } = useWalletClient(); * * const handleDeploy = async () => { * const config = createDefaultConfig( * 'My Token', * 'MTK', * '1000000', * await walletClient.account.address * ); * * const result = await deployToken( * walletClient, * config, * { chainId: 11155111, factoryAddress: '0x...' } * ); * * console.log('Token deployed at:', result.tokenAddress); * console.log('Transaction:', result.txHash); * }; * * return ; * } * ``` * * @example Vue with ethers * ```vue * * ``` * * @example Vanilla JS * ```javascript * import { deployToken, normalizeWallet, createDefaultConfig } from '@escapehub/token-creator'; * * async function deploy() { * const signer = await normalizeWallet(window.ethereum); * const address = await signer.getAddress(); * * const config = createDefaultConfig('My Token', 'MTK', '1000000', address); * * const result = await deployToken( * signer, * config, * { chainId: 11155111, factoryAddress: '0x...' } * ); * * console.log('Token deployed at:', result.tokenAddress); * } * ``` */ export declare function deployToken(wallet: WalletInput, config: TokenConfig, chainConfig: ChainConfig, salt?: string): Promise; /** * Predict the token address that would be created with a given salt. * * Uses the factory's predictAddress function via RPC call. * For local prediction without RPC, use predictAddressLocal(). * * @param provider - ethers Provider or Signer * @param factoryAddress - Factory contract address * @param salt - Vanity salt (bytes32 hex string) * @returns Predicted token address * * @example * ```typescript * import { predictAddress } from '@escapehub/token-creator'; * * const address = await predictAddress( * provider, * '0x10ca27bc0c4f9c1ea9169a76270c0c136d160a54', * '0x0000000000000000000000000000000000000000000000000000000000000001' * ); * console.log('Token will be deployed at:', address); * ``` */ export declare function predictAddress(provider: Provider | Signer, factoryAddress: Address, salt: string): Promise
; /** * Compute the init code hash for OpenZeppelin Clones minimal proxy. * Used for local CREATE2 address prediction without RPC calls. * * @param implementationAddress - The implementation contract address * @returns The init code hash for CREATE2 address prediction * * @example * ```typescript * import { getMinimalProxyInitCodeHash } from '@escapehub/token-creator'; * * const initCodeHash = getMinimalProxyInitCodeHash('0x...'); * // Can be used with predictAddressLocal * ``` */ export declare function getMinimalProxyInitCodeHash(implementationAddress: Address): string; /** * Predict token address locally using CREATE2 formula. * Does not require RPC call - useful for vanity address mining. * * @param factoryAddress - Factory contract address * @param salt - Vanity salt (bytes32 hex string) * @param initCodeHash - Init code hash (from getMinimalProxyInitCodeHash) * @returns Predicted token address * * @example * ```typescript * import { predictAddressLocal, getMinimalProxyInitCodeHash } from '@escapehub/token-creator'; * * const initCodeHash = getMinimalProxyInitCodeHash(implementationAddress); * const address = predictAddressLocal( * '0x10ca27bc0c4f9c1ea9169a76270c0c136d160a54', * '0x0000000000000000000000000000000000000000000000000000000000000001', * initCodeHash * ); * ``` */ export declare function predictAddressLocal(factoryAddress: Address, salt: string, initCodeHash: string): Address; /** * Wait for a deployment transaction to be confirmed. * * @param provider - ethers Provider or Signer with provider * @param txHash - Transaction hash to wait for * @param confirmations - Number of confirmations to wait for (default: 1) * @returns Transaction receipt * @throws Error if transaction fails or times out * * @example * ```typescript * import { waitForDeployment } from '@escapehub/token-creator'; * * // Wait for 1 confirmation (default) * const receipt = await waitForDeployment(provider, txHash); * * // Wait for 3 confirmations * const receipt = await waitForDeployment(provider, txHash, 3); * ``` */ export declare function waitForDeployment(provider: Provider | Signer, txHash: string, confirmations?: number): Promise; /** * Parse TokenCreated event from a transaction receipt. * * Extracts the deployed token address from the factory's TokenCreated event. * * @param receipt - Transaction receipt from deployment * @param factoryAddress - Factory contract address (for event filtering) * @returns Token address if found, null otherwise * * @example * ```typescript * import { parseTokenCreatedEvent } from '@escapehub/token-creator'; * * const receipt = await provider.waitForTransaction(txHash); * const tokenAddress = parseTokenCreatedEvent(receipt, factoryAddress); * * if (tokenAddress) { * console.log('Token deployed at:', tokenAddress); * } else { * console.log('TokenCreated event not found in receipt'); * } * ``` */ export declare function parseTokenCreatedEvent(receipt: TransactionReceipt, factoryAddress: Address): Address | null; /** * Get the implementation address used by the factory. * * The factory uses OpenZeppelin Clones to deploy minimal proxies * pointing to this implementation. * * @param provider - ethers Provider or Signer * @param factoryAddress - Factory contract address * @returns Implementation contract address * * @example * ```typescript * import { getImplementation } from '@escapehub/token-creator'; * * const impl = await getImplementation(provider, '0x...'); * console.log('Implementation:', impl); * ``` */ export declare function getImplementation(provider: Provider | Signer, factoryAddress: Address): Promise
; /** * Check if an address already has deployed code. * Returns true if address has code (deployment would fail). * * @param provider - ethers Provider or Signer with provider * @param address - Address to check * @returns True if address has code * * @example * ```typescript * import { addressHasCode } from '@escapehub/token-creator'; * * const hasCode = await addressHasCode(provider, '0x...'); * if (hasCode) { * console.log('Address already has a contract!'); * } * ``` */ export declare function addressHasCode(provider: Provider | Signer, address: Address): Promise; /** * Verify that an address is available for deployment. * Throws an error if the address already has code. * * @param provider - ethers Provider or Signer * @param factoryAddress - Factory contract address * @param salt - Vanity salt (bytes32 hex string) * @returns Predicted address if available * @throws Error if address already has code * * @example * ```typescript * import { verifyAddressAvailable } from '@escapehub/token-creator'; * * try { * const address = await verifyAddressAvailable(provider, factoryAddress, salt); * console.log('Address available:', address); * } catch (e) { * console.log('Address already taken!'); * } * ``` */ export declare function verifyAddressAvailable(provider: Provider | Signer, factoryAddress: Address, salt: string): Promise
; /** * Create a read-only provider for a chain. * Useful when you only need to read data without a wallet. * * @param rpcUrl - RPC endpoint URL * @returns JsonRpcProvider instance * * @example * ```typescript * import { createProvider, getCreationFee } from '@escapehub/token-creator'; * * const provider = createProvider('https://rpc.sepolia.org'); * const fee = await getCreationFee(provider, '0x...'); * ``` */ export declare function createProvider(rpcUrl: string): JsonRpcProvider; export type { TokenConfig, Address, } from './types/deploy-config'; export type { ChainConfig } from './types/token-data'; export { ZERO_ADDRESS, DeadblockMode, WhitelistMode, AntiDumpType, BatchTransferAccess, BatchTransferFees, createDefaultConfig, } from './types/deploy-config'; //# sourceMappingURL=deploy.d.ts.map