Skip to content

module : sdk.payment_strategies.freecall_payment_strategy

Link to GitHub

Entities:

  1. FreeCallPaymentStrategy

Class FreeCallPaymentStrategy

extends: PaymentStrategy

is extended by: -

description

The FreeCallPaymentStrategy class is a concrete implementation of the PaymentStrategy interface. It allows you to use free calls (which can be received from the Dapp) to call services.

methods

is_free_call_available

Checks if a free call is available for a given service client.

args:
  • service_client (ServiceClient): The service client instance.
returns:
  • True if a free call is available, False otherwise. (bool)
raises:
  • Exception: If an error occurs while checking the free call availability.

Note: If any exception occurs during the process, it returns False.

get_payment_metadata

Retrieves the payment metadata for a service client with the field snet-payment-type equals to free-call using the provided free call configuration.

args:
  • service_client (ServiceClient): The service client instance.
returns:
  • The payment metadata. (list[tuple[str, Any]])

generate_signature

Generates a signature for the given service client using the provided free call configuration.

args:
  • service_client (ServiceClient): The service client instance.
returns:
  • A tuple containing the generated signature and the current block number. (tuple[bytes, int])
raises:
  • Exception: If any of the required parameters for the free call strategy are missing.