Skip to content

algokit_subscriber.types.subscription

BalanceChangeRoleCreate a collection of name/value pairs.
TransactionSubscriptionResultThe result of a single subscription pull/poll.
BlockMetadataMetadata about a block that was retrieved from algod.
BlockRewardsdict() -> new empty dictionary
BlockUpgradeStatedict() -> new empty dictionary
SubscribedTransactionThe common model used to expose a transaction that is returned from a subscription.
BalanceChangeRepresents a balance change effect for a transaction.
BeforePollMetadataMetadata about an impending subscription poll.
TransactionFilterdict() -> new empty dictionary
NamedTransactionFilterSpecify a named filter to apply to find transactions of interest.
CoreTransactionSubscriptionParamsdict() -> new empty dictionary
TransactionSubscriptionParamsdict() -> new empty dictionary
WatermarkPersistencedict() -> new empty dictionary
AlgorandSubscriberConfigConfiguration for the subscriber.
SubscriberConfigFilterA single event to subscribe to / emit.

Bases: enum.Enum

Create a collection of name/value pairs.

Example enumeration:

class Color(Enum):
RED = 1
BLUE = 2
GREEN = 3

Access them by:

  • attribute access:
    Color.RED
    <Color.RED: 1>
  • value lookup:
    Color(1)
    <Color.RED: 1>
  • name lookup:
    Color['RED']
    <Color.RED: 1>

Enumerations can be iterated over, and know how many members they have:

len(Color)
3
list(Color)
[<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]

Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.

Bases: TypedDict

The result of a single subscription pull/poll.

The round range that was synced from/to

The current detected tip of the configured Algorand blockchain.

The watermark value that was retrieved at the start of the subscription poll.

The new watermark value to persist for the next call to get_subscribed_transactions to continue the sync. Will be equal to synced_round_range[1]. Only persist this after processing (or in the same atomic transaction as) subscribed transactions to keep it reliable.

Any transactions that matched the given filter within the synced round range. This substantively uses the indexer transaction format to represent the data with some additional fields.

The metadata about any blocks that were retrieved from algod as part of the subscription poll.

Bases: TypedDict

Metadata about a block that was retrieved from algod.

The base64 block hash.

The round of the block.

Block creation timestamp in seconds since epoch

The genesis ID of the chain.

The base64 genesis hash of the chain.

previous_block_hash : NotRequired[str | None]

Section titled “previous_block_hash : NotRequired[str | None]”

The base64 previous block hash.

The base64 seed of the block.

Fields relating to rewards

Count of parent transactions in this block

Full count of transactions and inner transactions (recursively) in this block.

Number of the next transaction that will be committed after this block. It is 0 when no transactions have ever been committed (since TxnCounter started being supported).

Root of transaction merkle tree using SHA512_256 hash function. This commitment is computed based on the PaysetCommit type specified in the block’s consensus protocol.

TransactionsRootSHA256 is an auxiliary TransactionRoot, built using a vector commitment instead of a merkle tree, and SHA256 hash function instead of the default SHA512_256. This commitment can be used on environments where only the SHA256 function exists.

Fields relating to a protocol upgrade.

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via: : d = {} for k, v in iterable:

d[k] = v

dict(

**

kwargs) -> new dictionary initialized with the name=value pairs : in the keyword argument list. For example: dict(one=1, two=2)

FeeSink is an address that accepts transaction fees, it can only spend to the incentive pool.

number of leftover MicroAlgos after the distribution of rewards-rate MicroAlgos for every reward unit in the next round.

How many rewards, in MicroAlgos, have been distributed to each RewardUnit of MicroAlgos since genesis.

RewardsPool is an address that accepts periodic injections from the fee-sink and continually redistributes them as rewards.

Number of new MicroAlgos added to the participation stake from rewards at the next round.

Number of leftover MicroAlgos after the distribution of RewardsRate/rewardUnits MicroAlgos for every reward unit in the next round.

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via: : d = {} for k, v in iterable:

d[k] = v

dict(

**

kwargs) -> new dictionary initialized with the name=value pairs : in the keyword argument list. For example: dict(one=1, two=2)

Current protocol version

The next proposed protocol version.

next_protocol_approvals : NotRequired[None | int]

Section titled “next_protocol_approvals : NotRequired[None | int]”

Number of blocks which approved the protocol upgrade.

next_protocol_vote_before : NotRequired[None | int]

Section titled “next_protocol_vote_before : NotRequired[None | int]”

Deadline round for this protocol upgrade (No votes will be consider after this round).

next_protocol_switch_on : NotRequired[None | int]

Section titled “next_protocol_switch_on : NotRequired[None | int]”

Round on which the protocol upgrade will take effect.

Bases: algokit_subscriber.types.indexer.TransactionResult

The common model used to expose a transaction that is returned from a subscription.

Substantively, based on the Indexer TransactionResult model format with some modifications to: * Add the parent_transaction_id field so inner transactions have a reference to their parent * Override the type of inner_txns to be SubscribedTransaction[] so inner transactions

(recursively) get these extra fields too

  • Add emitted ARC-28 events via arc28_events
  • Balance changes in algo or assets

parent_transaction_id : NotRequired[None | str]

Section titled “parent_transaction_id : NotRequired[None | str]”

The transaction ID of the parent of this transaction (if it’s an inner transaction).

Inner transactions produced by application execution.

Any ARC-28 events emitted from an app call.

The names of any filters that matched the given transaction to result in it being ‘subscribed’.

The balance changes in the transaction.

Bases: TypedDict

Represents a balance change effect for a transaction.

The address that the balance change is for.

The asset ID of the balance change, or 0 for Algos.

The amount of the balance change in smallest divisible unit or microAlgos.

The roles the account was playing that led to the balance change

Bases: TypedDict

Metadata about an impending subscription poll.

The current watermark of the subscriber

The current round of algod

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via: : d = {} for k, v in iterable:

d[k] = v

dict(

**

kwargs) -> new dictionary initialized with the name=value pairs : in the keyword argument list. For example: dict(one=1, two=2)

Filter based on the given transaction type(s).

Filter to transactions sent from the specified address(es).

Filter to transactions being received by the specified address(es).

Filter to transactions with a note having the given prefix.

Filter to transactions against the app with the given ID(s).

Filter to transactions that are creating an app.

app_on_complete : NotRequired[str | list[str]]

Section titled “app_on_complete : NotRequired[str | list[str]]”

Filter to transactions that have given on complete(s).

Filter to transactions against the asset with the given ID(s).

Filter to transactions that are creating an asset.

Filter to transactions where the amount being transferred is greater than or equal to the given minimum (microAlgos or decimal units of an ASA if type: axfer).

Filter to transactions where the amount being transferred is less than or equal to the given maximum (microAlgos or decimal units of an ASA if type: axfer).

method_signature : NotRequired[str | list[str]]

Section titled “method_signature : NotRequired[str | list[str]]”

Filter to app transactions that have the given ARC-0004 method selector(s) for the given method signature as the first app argument.

app_call_arguments_match : NotRequired[collections.abc.Callable[[list[bytes] | None], bool]]

Section titled “app_call_arguments_match : NotRequired[collections.abc.Callable[[list[bytes] | None], bool]]”

Filter to app transactions that meet the given app arguments predicate.

arc28_events : NotRequired[list[dict[str, str]]]

Section titled “arc28_events : NotRequired[list[dict[str, str]]]”

Filter to app transactions that emit the given ARC-28 events. Note: the definitions for these events must be passed in to the subscription config via arc28_events.

Filter to transactions that result in balance changes that match one or more of the given set of balance changes.

custom_filter : NotRequired[collections.abc.Callable[[TransactionResult], bool]]

Section titled “custom_filter : NotRequired[collections.abc.Callable[[TransactionResult], bool]]”

Catch-all custom filter to filter for things that the rest of the filters don’t provide.

Bases: TypedDict

Specify a named filter to apply to find transactions of interest.

The name to give the filter.

The filter itself.

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via: : d = {} for k, v in iterable:

d[k] = v

dict(

**

kwargs) -> new dictionary initialized with the name=value pairs : in the keyword argument list. For example: dict(one=1, two=2)

The filter(s) to apply to find transactions of interest.

Any ARC-28 event definitions to process from app call logs

max_rounds_to_sync : NotRequired[int | None]

Section titled “max_rounds_to_sync : NotRequired[int | None]”

The maximum number of rounds to sync from algod for each subscription pull/poll. Defaults to 500.

max_indexer_rounds_to_sync : NotRequired[int | None]

Section titled “max_indexer_rounds_to_sync : NotRequired[int | None]”

The maximum number of rounds to sync from indexer when using sync_behaviour: ‘catchup-with-indexer’.

sync_behaviour : Literal[‘catchup-with-algod’, ‘catchup-with-indexer’, ‘fail’, ‘skip-sync-newest’, ‘sync-oldest’, ‘sync-oldest-start-now’]

Section titled “sync_behaviour : Literal[‘catchup-with-algod’, ‘catchup-with-indexer’, ‘fail’, ‘skip-sync-newest’, ‘sync-oldest’, ‘sync-oldest-start-now’]”

If the current tip of the configured Algorand blockchain is more than max_rounds_to_sync past watermark then how should that be handled.

fail: Immediately fail skip-sync-newest: Skip catchup and start syncing from the latest block regardless of the watermark. sync-oldest: Start syncing from the watermark sync-oldest-start-now: If the watermark is 0, start syncing from round 0. Otherwise skip to the latest block. catchup-with-indexer: Use indexer to get missing transactions that match the filters starting from the watermark. Filters will be used in the indexer request to reduce the total amount of requests needed (relative to getting every block)

Bases: CoreTransactionSubscriptionParams

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via: : d = {} for k, v in iterable:

d[k] = v

dict(

**

kwargs) -> new dictionary initialized with the name=value pairs : in the keyword argument list. For example: dict(one=1, two=2)

The current round watermark that transactions have previously been synced to.

The current tip of the configured Algorand blockchain. If not provided, it will be resolved on demand.

Bases: TypedDict

dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object’s

(key, value) pairs

dict(iterable) -> new dictionary initialized as if via: : d = {} for k, v in iterable:

d[k] = v

dict(

**

kwargs) -> new dictionary initialized with the name=value pairs : in the keyword argument list. For example: dict(one=1, two=2)

Method to retrieve the current watermark

Method to persist the new watermark

Bases: CoreTransactionSubscriptionParams

Configuration for the subscriber.

The set of filters to subscribe to / emit events for, along with optional data mappers.

The frequency to poll for new blocks in seconds; defaults to 1s

wait_for_block_when_at_tip : NotRequired[bool]

Section titled “wait_for_block_when_at_tip : NotRequired[bool]”

Whether to wait via algod /status/wait-for-block-after endpoint when at the tip of the chain; reduces latency of subscription

Methods to retrieve and persist the current watermark so syncing is resilient and maintains its position in the chain

Bases: NamedTransactionFilter

A single event to subscribe to / emit.

An optional data mapper if you want the event data to take a certain shape when subscribing to events with this filter name.