Skip to content

TestNetDispenserApiClient

Defined in: src/dispenser-client.ts:73

TestNetDispenserApiClient is a class that provides methods to interact with the Algorand TestNet Dispenser API. It allows you to fund an address with Algo, refund a transaction, and get the funding limit for the Algo asset.

The class requires an authentication token and a request timeout to be initialized. The authentication token can be provided either directly as a parameter or through an ALGOKIT_DISPENSER_ACCESS_TOKEN environment variable. If neither is provided, an error is thrown.

The request timeout can be provided as a parameter. If not provided, a default value is used.

const client = new TestNetDispenserApiClient({ authToken: 'your_auth_token', requestTimeout: 30 });
const fundResponse = await client.fund('your_address', 100);
const limitResponse = await client.getLimit();
await client.refund('your_transaction_id');

If neither the environment variable ‘ALGOKIT_DISPENSER_ACCESS_TOKEN’ nor the authToken parameter were provided.

new TestNetDispenserApiClient(params?): TestNetDispenserApiClient

Defined in: src/dispenser-client.ts:77

TestNetDispenserApiClientParams

TestNetDispenserApiClient

get authToken(): string

Defined in: src/dispenser-client.ts:93

string

The authentication token used for API requests.


get requestTimeout(): number

Defined in: src/dispenser-client.ts:97

number

The timeout for API requests, in seconds.

Methods:

  • fund - Sends a funding request to the dispenser API to fund the specified address with the given amount of Algo.
  • refund - Sends a refund request to the dispenser API for the specified refundTxnId.
  • limit - Sends a request to the dispenser API to get the funding limit for the Algo asset.

fund(address, amount): Promise<DispenserFundResponse>

Defined in: src/dispenser-client.ts:159

Sends a funding request to the dispenser API to fund the specified address with the given amount of Algo.

The address to fund.

string | Address

The amount of µAlgo to fund.

number | bigint

Promise<DispenserFundResponse>

DispenserFundResponse: An object containing the transaction ID and funded amount.


getLimit(): Promise<DispenserLimitResponse>

Defined in: src/dispenser-client.ts:189

Sends a request to the dispenser API to get the funding limit for the Algo asset.

Promise<DispenserLimitResponse>

DispenserLimitResponse: An object containing the funding limit amount.


refund(refundTxnId): Promise<void>

Defined in: src/dispenser-client.ts:180

Sends a refund request to the dispenser API for the specified refundTxnId.

string

The transaction ID to refund.

Promise<void>