ts-algochat
    Preparing search index...

    Class AlgorandService

    Index

    Constructors

    Methods

    • Clears the public key cache, or removes a specific address.

      Parameters

      • Optionaladdress: string

      Returns void

    • Discovers a user's encryption public key from their transaction history.

      Uses paginated indexer queries to search exhaustively. Results are cached in an LRU cache to avoid repeated full scans for the same address.

      Parameters

      • address: string

        Algorand address to discover key for

      • OptionalsearchDepth: number

        Max transactions to search (default: undefined = exhaustive)

      Returns Promise<Uint8Array<ArrayBufferLike>>

    • Discovers a user's encryption public key with full metadata.

      Uses paginated indexer queries with the next-token cursor to walk the full transaction history. Falls back to a single batch when searchDepth is provided for backward compatibility.

      Parameters

      • address: string

        Algorand address to discover key for

      • OptionalsearchDepth: number

        Max transactions to search (default: undefined = exhaustive)

      Returns Promise<DiscoveredKey>

    • Fetches messages with a participant

      Parameters

      • chatAccount: ChatAccount

        The user's chat account

      • participantAddress: string

        Address of the conversation participant

      • OptionalafterRound: number

        Only fetch messages after this round (for polling new messages)

      • limit: number = 50

        Maximum number of messages to fetch

      • OptionalbeforeRound: number

        Only fetch messages before this round (for pagination/loading older)

      Returns Promise<Message[]>

    • Sends an encrypted message to a recipient

      Parameters

      • chatAccount: ChatAccount

        The sender's chat account

      • recipientAddress: string

        Recipient's Algorand address

      • recipientPublicKey: Uint8Array

        Recipient's encryption public key

      • message: string

        Message content

      • options: SendOptions = {}

        Send options (waitForConfirmation, waitForIndexer, etc.)

      Returns Promise<SendResult>

    • Sends a reply to a message

      Parameters

      • chatAccount: ChatAccount

        The sender's chat account

      • recipientAddress: string

        Recipient's Algorand address

      • recipientPublicKey: Uint8Array

        Recipient's encryption public key

      • message: string

        Message content

      • replyToTxid: string

        Transaction ID of the message being replied to

      • replyToPreview: string

        Preview text of the message being replied to

      • options: SendOptions = {}

        Send options (waitForConfirmation, waitForIndexer, etc.)

      Returns Promise<SendResult>

    • Checks if a transaction exists in the indexer

      Parameters

      • txid: string

        Transaction ID to check

      Returns Promise<boolean>

    • Waits for transaction confirmation

      Parameters

      • txid: string

        Transaction ID to wait for

      • timeout: number = 10

        Timeout in rounds (default: 10)

      Returns Promise<number>

      Confirmed round number

    • Waits for a transaction to be indexed

      Uses exponential backoff with jitter for efficient polling.

      Parameters

      • txid: string

        Transaction ID to wait for

      • timeout: number = 30000

        Timeout in milliseconds (default: 30000)

      • initialInterval: number = 500

        Initial polling interval (default: 500ms)

      • maxInterval: number = 5000

        Maximum polling interval (default: 5000ms)

      • backoffMultiplier: number = 1.5

        Backoff multiplier (default: 1.5)

      Returns Promise<boolean>

      true if indexed, false if timeout