/** * IPFS Client Configuration */ export interface IPFSClientConfig { /** Service provider: 'pinata', 'nftstorage', 'web3storage', or 'ipfs' (local node) */ provider: 'pinata' | 'nftstorage' | 'web3storage' | 'ipfs'; /** API key/token for the service */ apiKey?: string; /** API secret (required for Pinata) */ apiSecret?: string; /** Custom IPFS gateway URL (defaults to public gateways) */ gatewayUrl?: string; /** Custom IPFS node URL (for local IPFS node) */ nodeUrl?: string; } /** * IPFS Upload Result */ export interface IPFSUploadResult { /** The IPFS CID (Content Identifier) */ cid: string; /** Full IPFS URI (ipfs://...) */ uri: string; /** Gateway URL for accessing the content */ url: string; /** File size in bytes */ size?: number; } /** * Convert any IPFS CID (v0 or v1) to bytes32 hex string * Works for Qm... (CIDv0) formats * * @param cidStr - The IPFS CID string (v0 like "QmXXX...") * @returns Ethereum bytes32 hex string (0x-prefixed) * @throws Error if the CID is invalid or digest length is not 32 bytes * * @example * ```typescript * const cidv0 = 'QmR7GSQM93Cx5eAg6a6yRzNde1FQv7uL6X1o4k7zrJa3LX'; * const bytes32 = cidToBytes32(cidv0); * // Returns: '0x...' (32 bytes hex) * ``` */ export declare function cidToBytes32(cidStr: string): string; /** * Extract CID from IPFS URI and convert to bytes32 * Handles both raw CIDs and ipfs:// URIs * * @param uri - IPFS URI (e.g., "ipfs://QmXXX..." or just "QmXXX...") * @returns Ethereum bytes32 hex string (0x-prefixed) * * @example * ```typescript * const uri = 'ipfs://QmR7GSQM93Cx5eAg6a6yRzNde1FQv7uL6X1o4k7zrJa3LX'; * const bytes32 = ipfsUriToBytes32(uri); * ``` */ export declare function ipfsUriToBytes32(uri: string): string; /** * IPFS Client for uploading, pinning, and fetching content */ export declare class IPFSClient { private config; constructor(config: IPFSClientConfig); /** * Upload content to IPFS * @param content - String, Buffer, or File to upload * @param options - Optional metadata like filename * @returns Upload result with CID and URLs */ upload(content: string | Buffer | Blob, options?: { name?: string; metadata?: Record; }): Promise; /** * Upload JSON data to IPFS * @param data - JavaScript object to stringify and upload * @param options - Optional metadata * @returns Upload result */ uploadJSON(data: any, options?: { name?: string; metadata?: Record; }): Promise; /** * Pin an existing CID (keep it available on the network) * @param cid - The CID to pin * @param options - Optional metadata */ pin(cid: string, options?: { name?: string; }): Promise; /** * Fetch content from IPFS * @param cidOrUri - CID or ipfs:// URI * @returns Content as string */ fetch(cidOrUri: string): Promise; /** * Fetch JSON content from IPFS * @param cidOrUri - CID or ipfs:// URI * @returns Parsed JSON object */ fetchJSON(cidOrUri: string): Promise; /** * Get gateway URL for a CID * @param cid - The IPFS CID * @returns Full gateway URL */ getGatewayUrl(cid: string): string; private uploadToPinata; private uploadToNFTStorage; private uploadToWeb3Storage; private uploadToLocalIPFS; private pinOnPinata; private pinOnLocalIPFS; } /** * Create an IPFS client instance * @param config - IPFS client configuration * @returns Configured IPFS client */ export declare function createIPFSClient(config: IPFSClientConfig): IPFSClient; //# sourceMappingURL=ipfs.d.ts.map