TestNetDispenserApiClient
@algorandfoundation/algokit-utils / types/dispenser-client / TestNetDispenserApiClient
types/dispenser-client.TestNetDispenserApiClient
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.
Method
fund - Sends a funding request to the dispenser API to fund the specified address with the given amount of Algo.
Method
refund - Sends a refund request to the dispenser API for the specified refundTxnId.
Method
limit - Sends a request to the dispenser API to get the funding limit for the Algo asset.
Example
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');Throws
If neither the environment variable ‘ALGOKIT_DISPENSER_ACCESS_TOKEN’ nor the authToken parameter were provided.
Table of contents
Section titled “Table of contents”Constructors
Section titled “Constructors”Properties
Section titled “Properties”Accessors
Section titled “Accessors”Methods
Section titled “Methods”Constructors
Section titled “Constructors”constructor
Section titled “constructor”• new TestNetDispenserApiClient(params?): TestNetDispenserApiClient
Parameters
Section titled “Parameters”| Name | Type |
|---|---|
params? | TestNetDispenserApiClientParams |
Returns
Section titled “Returns”Defined in
Section titled “Defined in”src/types/dispenser-client.ts:76
Properties
Section titled “Properties”_authToken
Section titled “_authToken”• Private _authToken: string
Defined in
Section titled “Defined in”src/types/dispenser-client.ts:73
_requestTimeout
Section titled “_requestTimeout”• Private _requestTimeout: number
Defined in
Section titled “Defined in”src/types/dispenser-client.ts:74
Accessors
Section titled “Accessors”authToken
Section titled “authToken”• get authToken(): string
The authentication token used for API requests.
Returns
Section titled “Returns”string
Defined in
Section titled “Defined in”src/types/dispenser-client.ts:92
requestTimeout
Section titled “requestTimeout”• get requestTimeout(): number
The timeout for API requests, in seconds.
Returns
Section titled “Returns”number
Defined in
Section titled “Defined in”src/types/dispenser-client.ts:96
Methods
Section titled “Methods”▸ fund(address, amount): Promise<DispenserFundResponse>
Sends a funding request to the dispenser API to fund the specified address with the given amount of Algo.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
address | string | Address | The address to fund. |
amount | number | bigint | The amount of µAlgo to fund. |
Returns
Section titled “Returns”Promise<DispenserFundResponse>
DispenserFundResponse: An object containing the transaction ID and funded amount.
Defined in
Section titled “Defined in”src/types/dispenser-client.ts:158
getLimit
Section titled “getLimit”▸ getLimit(): Promise<DispenserLimitResponse>
Sends a request to the dispenser API to get the funding limit for the Algo asset.
Returns
Section titled “Returns”Promise<DispenserLimitResponse>
DispenserLimitResponse: An object containing the funding limit amount.
Defined in
Section titled “Defined in”src/types/dispenser-client.ts:188
processDispenserRequest
Section titled “processDispenserRequest”▸ processDispenserRequest(authToken, urlSuffix, body?, method?): Promise<Response>
Processes a dispenser API request.
Parameters
Section titled “Parameters”| Name | Type | Default value | Description |
|---|---|---|---|
authToken | string | undefined | The authentication token. |
urlSuffix | string | undefined | The URL suffix for the API request. |
body | null | Record<string, string | number> | null | The request body. |
method | string | 'POST' | The HTTP method. |
Returns
Section titled “Returns”Promise<Response>
The API response.
Defined in
Section titled “Defined in”src/types/dispenser-client.ts:110
refund
Section titled “refund”▸ refund(refundTxnId): Promise<void>
Sends a refund request to the dispenser API for the specified refundTxnId.
Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
refundTxnId | string | The transaction ID to refund. |
Returns
Section titled “Returns”Promise<void>