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 currencies. FaucetClient
Example
import { FaucetClient } from '@nilfoundation/niljs';
const faucetClient = new FaucetClient({
transport: new HttpTransport({
endpoint: FAUCET_ENDPOINT,
}),
});
Extends
BaseClient
Constructors
new FaucetClient()
new FaucetClient(config): FaucetClient
Parameters
Parameter | Type |
---|---|
|
Returns
Overrides
BaseClient.constructor
Defined
@nilfoundation/niljs/src/clients/FaucetClient.ts:32
Properties
shardId?
protected 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
BaseClient.shardId
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:26
transport
protected transport: ITransport;
The ITransport to be used in the client. See ITransport.
Inherited from
BaseClient.transport
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 currency name and the value is faucet address.
Defined
@nilfoundation/niljs/src/clients/FaucetClient.ts:40
getShardId()
getShardId(): undefined | number
Returns the shard ID.
Returns
undefined
| number
The shard ID.
Inherited from
BaseClient.getShardId
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
BaseClient.request
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
BaseClient.setShardId
Defined
@nilfoundation/niljs/src/clients/BaseClient.ts:62
topUp()
topUp(param): Promise<0x${string}>
Topups the wallet with the specified amount of currency 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:55
topUpAndWaitUntilCompletion()
topUpAndWaitUntilCompletion(
param,
client,
retries?): Promise<0x${string}>
Topups the wallet with the specified amount of currency 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:73