ao-js-sdk - v0.2.11
    Preparing search index...

    Interface ITokenGrantClient

    Interface for interacting with ao token processes. Implements the standard token interface specification for managing transferable assets.

    interface ITokenGrantClient {
        balance(identifier: string): Promise<string>;
        balances(limit?: number, cursor?: string): Promise<DryRunResult>;
        dryrun(
            data: any,
            tags: Tags,
            anchor?: string,
            id?: string,
            owner?: string,
        ): Promise<DryRunResult>;
        getCallingWalletAddress(): Promise<string>;
        getInfo(token?: string): Promise<TokenInfo>;
        getProcessId(): string;
        getProcessInfo(): Promise<Partial<FullArweaveTransaction>>;
        getWallet(): any;
        grant(quantity: string, recipient?: string): Promise<boolean>;
        isReadOnly(): boolean;
        isRunningDryRunsAsMessages(): boolean;
        message(data?: string, tags?: Tags, anchor?: string): Promise<string>;
        mint(quantity: string): Promise<boolean>;
        result(messageId: string): Promise<MessageResult>;
        results(
            from?: string,
            to?: string,
            limit?: number,
            sort?: string,
        ): Promise<ResultsResponse>;
        setDryRunAsMessage(enabled: boolean): void;
        setWallet(wallet: any): void;
        transfer(
            recipient: string,
            quantity: string,
            forwardedTags?: Tags,
        ): Promise<boolean>;
    }

    Hierarchy (View Summary)

    Index

    Methods

    • Gets the balance of a specific identifier (address) in the token ledger. This is a read-only operation that queries the current state of the ledger.

      Parameters

      • identifier: string

        The address to check the balance for

      Returns Promise<string>

      Promise resolving to the current balance as a string

    • Gets a paginated list of all balances in the token ledger. This is a read-only operation that returns all ledger/account balances.

      Parameters

      • Optionallimit: number

        Optional maximum number of balances to return per page

      • Optionalcursor: string

        Optional pagination cursor for fetching subsequent pages

      Returns Promise<DryRunResult>

      Promise resolving to the dry run result containing the balances

      If ever used should refactor to return the balances in a list format

    • Performs a dry run, executing the logic of a message without actually persisting the result. When useDryRunAsMessage is false (default), this performs a simulation. When useDryRunAsMessage is true, this executes as a real message.

      Parameters

      • data: any

        Optional data to be passed to the message.

      • tags: Tags

        Optional tags to be passed to the message.

      • Optionalanchor: string

        Optional anchor to be passed to the message.

      • Optionalid: string

        Optional ID to be passed to the message.

      • Optionalowner: string

        Optional owner to be passed to the message.

      Returns Promise<DryRunResult>

      A DryRunResult object containing the output of the message, including the result of any computations, and any spawned messages. Or a MessageResult if useDryRunAsMessage is true.

      DryRunError if there is an error performing the dry run.

    • Gets information about a token process including name, ticker, logo, and denomination. These are immutable parameters set when the token process was spawned.

      Parameters

      • Optionaltoken: string

        Optional token process ID to get information for. If not provided, uses the current process ID.

      Returns Promise<TokenInfo>

      Promise resolving to TokenInfo with token information

    • Retrieves the transaction that created this process. This transaction contains the initial state and configuration of the process in its tags.

      Returns Promise<Partial<FullArweaveTransaction>>

      Promise resolving to the transaction data containing process creation details

      ArweaveGraphQLError if there is an error retrieving the transaction

    • Grants tokens to a recipient address

      Parameters

      • quantity: string

        The amount of tokens to grant

      • Optionalrecipient: string

        The recipient address, defaults to the calling wallet address

      Returns Promise<boolean>

      Promise resolving to boolean indicating success

    • A Readonly Client can only perform dry run and result operations, however does not require a wallet to be used. If a wallet is specified on instantiation the client will additionally be able to use write operations (messages).

      Returns boolean

      Boolean indicating whether or not the client is for read operations only.

    • Send a message to an ao Message Unit (mu) targeting an ao process.

      Parameters

      • Optionaldata: string

        Optional data to be passed to the message

      • Optionaltags: Tags

        Optional tags to be passed to the message

      • Optionalanchor: string

        Optional 32 byte anchor to be set on the DataItem

      Returns Promise<string>

      Promise resolving to the message ID

      MessageError if there is an error sending the message

    • Mints new tokens, increasing the total supply. This operation can only be performed on the root token process.

      Parameters

      • quantity: string

        The amount of new tokens to create

      Returns Promise<boolean>

      Promise resolving to true if minting was successful

    • Read the result of a message evaluation from an ao Compute Unit (cu).

      Parameters

      • messageId: string

        ID of the message to get result for

      Returns Promise<MessageResult>

      Promise resolving to MessageResult containing Messages, Spawns, Output, Error

      ResultError if there is an error fetching the result

    • Read a batch of results from a process. Can be used as a polling mechanism for new results.

      Parameters

      • Optionalfrom: string

        Optional cursor starting point

      • Optionalto: string

        Optional cursor ending point

      • Optionallimit: number

        Optional number of results to return (default: 25)

      • Optionalsort: string

        Optional sort order ('ASC' or 'DESC', default: 'ASC')

      Returns Promise<ResultsResponse>

      Promise resolving to ResultsResponse containing the batch of results

      ResultsError if there is an error fetching results

    • Controls whether dryrun executes as a message or simulation.

      Parameters

      • enabled: boolean

        When true, dryrun will execute as a real message. When false (default), executes as a simulation.

      Returns void

    • Sets the wallet being used for this client. If the client is readonly it will now have write abilities.

      Parameters

      • wallet: any

        the wallet to use with this client.

      Returns void

    • Transfers tokens from the caller's balance to one or more target addresses. This operation modifies the ledger state by updating balances.

      Parameters

      • recipient: string

        The target address to receive the tokens

      • quantity: string

        The amount of tokens to transfer

      • OptionalforwardedTags: Tags

        Optional tags to include with the transfer message for additional metadata or notifications

      Returns Promise<boolean>

      Promise resolving to true if the transfer was successful