Import
Signature
Reader for Algorand blockchain state via an Indexer client. Provides high-level queries for account payment history, recurring subscription asset holdings, and time-bounded vendor passes.

Constructor parameters

str
default:"'http://localhost:8980'"
Base URL of the Algorand Indexer REST API.
str
default:"''"
Authentication token header for the indexer API.
Any
default:"None"
Pre-configured algosdk.v2client.indexer.IndexerClient instance. If provided, overrides indexer_url and indexer_token.

Attributes

algosdk.v2client.indexer.IndexerClient
Underlying indexer client used for network queries.

Examples

Methods

for_network

Construct a ChainReader configured for a specific Algorand network. Resolves public indexer endpoints for "mainnet" and "testnet" (AlgoNode), or localhost for "localnet". Custom URLs/tokens override network defaults. Parameters
str
required
Network name, alias, or CAIP-2 identifier (e.g., "mainnet", "testnet", "localnet").
str | None
default:"None"
Custom indexer endpoint URL. If None, uses default endpoint for the network.
str | None
default:"None"
Custom indexer token. If None, uses default token for the network.
Returns
ChainReader
Instantiated reader pointing to the appropriate indexer.
Example

past_usage

Calculate total amount paid by an address to a recipient within a time window. Searches indexed transactions where address was the sender and pay_to was the receiver for payment (ALGO) or asset transfer (ASA) transactions. Notes Paginates through all matching indexer transactions and tallies successful payments matching the target recipient and asset ID. Parameters
str
required
Algorand address of the sender/buyer.
str
required
Algorand address of the service recipient/vendor.
int | str
required
Asset ID: 0 for native ALGO (microALGO), or positive ASA ID.
int
default:"30"
Number of days prior to now to inspect.
float | int | None
default:"None"
Current unix timestamp. If None, uses system time (time.time()).
Returns
int
Sum of transaction amounts transferred within the window, in base units (microALGO for ALGO, or base atomic units for ASAs). Returns 0 on query errors.
Example

has_active_subscription

Check whether an account holds a subscription asset received within a time window. Verifies that address currently holds a non-zero balance of asset_id, and that the most recent incoming transfer of that asset occurred within the last max_age_days days. Parameters
str
required
Algorand address of the subscriber.
int | str | None
required
ASA ID of the subscription token. Returns False if 0 or None.
float
default:"30.0"
Maximum age in days of the latest incoming asset transfer.
float | int | None
default:"None"
Reference unix timestamp. Defaults to time.time().
str | None
default:"None"
If provided, only transfers originating from this sender address count as valid subscription issuances.
Returns
bool
True if the subscriber currently holds the asset and the latest transfer is within max_age_days, False otherwise.
Example

active_passes

Find valid passes purchased by an address from a vendor. A pass is an on-chain payment from the buyer to the vendor’s pay_to address with note prefix x402-pass:<scope> whose transfer amount is at least the price specified for that scope in scopes. Notes If multiple payments exist for the same scope, the newest payment within the validity window takes precedence. Parameters
str
required
Algorand address of the pass holder (buyer).
str
required
Vendor receiver address.
int | str
required
Asset ID used to purchase the pass (0 for ALGO, or ASA ID).
dict[str, int]
required
Mapping of pass scope names (e.g., {"listing:tts-1": 50000}) to their minimum purchase prices.
float
default:"30.0"
Pass validity window in days from the round time of payment.
float | int | None
default:"None"
Reference unix timestamp. Defaults to time.time().
Returns
list of dict[str, Any]
Sorted list of active pass records ordered by round time. Each dictionary contains: "scope" (str), "txid" (str), "amount" (int), "round_time" (int), and "expires" (float).
Example

has_pass

Check whether an account holds at least one active pass for the specified vendor. Parameters
str
required
Algorand address of the buyer/caller.
str
required
Vendor receiver address.
int | str
required
Asset ID used for pass payment (0 for ALGO, or positive ASA ID).
dict[str, int]
required
Mapping of eligible pass scope names to minimum prices.
float
default:"30.0"
Pass validity duration in days.
float | int | None
default:"None"
Reference unix timestamp. Defaults to time.time().
Returns
bool
True if any active pass matches the criteria, False otherwise.
Example

See also

  • for_network: Factory constructor resolving indexer endpoints by network name.
Source: ai_economy_sdk/chain.py