@bit-gpt/h402
Version:
BitGPT's 402 open protocol for blockchain-native payments
35 lines • 1.67 kB
TypeScript
import { PaymentRequirements } from "../types";
import { PaymentClient } from "../types";
/**
* Creates a payment based header on the provided payment details and client.
*
* @param {PaymentRequirements} paymentRequirements - The details of the payment to be created
* @param {PaymentClient} client - The client object containing chain-specific clients
* @param h402Version
* @returns {Promise<string>} A promise that resolves to the payment header
*
* @throws {Error} If payment details namespace is missing
* @throws {Error} If the specified EVM network is not supported
* @throws {Error} If evmClient is missing for EIP-155 payments
* @throws {Error} If EVM client chainId doesn't match payment networkId
* @throws {Error} If solanaClient is missing for Solana payments
* @throws {Error} If the namespace is not supported
* @throws {Error} If the payment scheme is not supported
*
* @description
* This function handles the payment creation process by:
* 1. Validating the payment namespace
* 2.1 For EIP-155 (EVM) payments:
* - Verifies network support
* - Validates client configuration
* - Ensures chain ID matches
* - Processes the payment based on the specified scheme
* 2.2 For Solana payments:
* - Verifies network support
* - Validates client configuration
* - Ensures signAndSendTransaction is available
* - Processes the payment based on the specified scheme
* 3. Encodes and returns the payment data
*/
export declare function createPaymentHeader(client: PaymentClient, h402Version: number, paymentRequirements: PaymentRequirements): Promise<string>;
//# sourceMappingURL=createPaymentHeader.d.ts.map