T402 API Reference - v2.8.0
    Preparing search index...

    Class UptoEvmServerScheme

    EVM server implementation for the Up-To payment scheme.

    Enables usage-based billing by creating payment requirements that authorize up to a maximum amount, with actual settlement determined by usage.

    import { UptoEvmServerScheme } from "@t402/evm/upto/server";

    const scheme = new UptoEvmServerScheme({
    routerAddress: "0x...", // T402UptoRouter contract
    defaultUnit: "token",
    defaultUnitPrice: "100", // $0.0001 per token
    });

    server.registerScheme("eip155:8453", scheme);

    Implements

    Index

    Constructors

    Properties

    scheme: "upto"

    Methods

    • Check if a network is supported

      Parameters

      • network: string

        The network identifier to check

      Returns boolean

      True if the network is supported

    • Parses a price into an asset amount for maxAmount.

      Parameters

      • price: Price

        The price to parse (represents maxAmount)

      • network: Network

        The network to use

      Returns Promise<AssetAmount>

      Promise resolving to the parsed asset amount

    • Enhance payment requirements for the upto scheme.

      Parameters

      • paymentRequirements: PaymentRequirements

        Base payment requirements

      • supportedKind: {
            t402Version: number;
            scheme: string;
            network: Network;
            extra?: Record<string, unknown>;
        }

        The supported kind from facilitator

        • t402Version: number

          T402 protocol version

        • scheme: string

          Payment scheme

        • network: Network

          Network identifier

        • Optionalextra?: Record<string, unknown>

          Extra configuration

      • facilitatorExtensions: string[]

        Extensions supported by the facilitator

      Returns Promise<PaymentRequirements>

      Enhanced payment requirements for upto scheme