Class: FaucetClient
FaucetClient is a client that interacts with the faucet api. It is used to get information about the faucet and to top up the account with custom tokens. FaucetClient
Example
import { FaucetClient } from '@nilfoundation/niljs';
const faucetClient = new FaucetClient({
transport: new HttpTransport({
endpoint: FAUCET_ENDPOINT,
}),
});
Extends
Constructors
new FaucetClient()
new FaucetClient(config): FaucetClient
Parameters
Parameter | Type |
---|---|
|
Returns
Overrides
Defined
@nilfoundation/niljs/src/clients/FaucetClient.ts:33
Properties
shardId?
optional shardId: number;
The ID of the shard with which the client needs to interact. The shard with this ID will be used in every call made by the client.
Inherited from
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:26
transport
readonly transport: ITransport;
The ITransport to be used in the client. See ITransport.
Inherited from
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:18
Methods
getAllFaucets()
getAllFaucets(): Promise<Record<string, 0x${string}>>
Gets all the faucets available.
Returns
Promise
<Record
<string
, 0x${string}
>>
The list of all faucets. The key is the token name and the value is faucet address.
Defined
@nilfoundation/niljs/src/clients/FaucetClient.ts:41
getShardId()
getShardId(): undefined | number
Returns the shard ID.
Returns
undefined
| number
The shard ID.
Inherited from
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:51
request()
protected request<T>(requestObject): Promise<T>
Sends a request.
Type Parameters
Type Parameter |
---|
|
Parameters
Parameter | Type | Description |
---|---|---|
|
| The request object. It contains the request method and parameters. |
Returns
Promise
<T
>
The response.
Inherited from
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:43
setShardId()
setShardId(shardId): void
Sets the shard ID.
Parameters
Parameter | Type | Description |
---|---|---|
|
| The shard ID. |
Returns
void
Throws
Will throw an error if the provided shard ID is invalid.
Example
client.setShardId(1);
Inherited from
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:62
topUp()
topUp(param): Promise<0x${string}>
Topups the smart account with the specified amount of token which can be issued by the faucet.
Parameters
Parameter | Type | Description |
---|---|---|
| The parameters for the top up request. |
Returns
Promise
<0x${string}
>
The transaction hash of the top up transaction.
Defined
@nilfoundation/niljs/src/clients/FaucetClient.ts:56
topUpAndWaitUntilCompletion()
topUpAndWaitUntilCompletion(
param,
client,
retries?): Promise<0x${string}>
Topups the smart account with the specified amount of token which can be issued by the faucet. This function waits until the top up transaction is completed.
Parameters
Parameter | Type | Default value | Description |
---|---|---|---|
|
| The parameters for the top up request. | |
|
| Public client to fetch the data from the network. | |
|
|
| The number of retries to make. |
Returns
Promise
<0x${string}
>
The transaction hash of the top up transaction.
Defined
@nilfoundation/niljs/src/clients/FaucetClient.ts:74