FaucetClient
Namespace: IotaSdk
public class FaucetClient : IFaucetClient, System.IDisposable
Inheritance Object → FaucetClient
Implements IFaucetClient, IDisposable
Attributes NullableContextAttribute, NullableAttribute
Constructors
FaucetClient(UInt64)
public FaucetClient(ulong pointer)
Parameters
pointer UInt64
FaucetClient(String)
Construct a new FaucetClient with the given faucet service URL. This FaucetClient
expects that the service provides two endpoints:
/v1/gas and /v1/status. As such, do not provide the request
endpoint, just the top level service endpoint.
- /v1/gas is used to request gas
- /v1/status/task-uuid is used to check the status of the request
public FaucetClient(string faucetUrl)
Parameters
faucetUrl String
Methods
Destroy()
public void Destroy()
Dispose()
public void Dispose()
Request(Address)
Request gas from the faucet. Note that this will return the UUID of the request and not wait
until the token is received. Use request_and_wait to wait for the token.
public async Task<string?> Request(Address address)
Parameters
address Address
Returns
Exceptions
RequestAndWait(Address)
Request gas from the faucet and wait until the request is completed and token is
transferred. Returns FaucetReceipt if the request is successful, which contains the list
of tokens transferred, and the transaction digest. Returns FaucetError::Discarded if the
faucet discards the request.
Note that the faucet is heavily rate-limited, so calling repeatedly the faucet would likely result in a 429 code or 502 code.
If you intend to use the transferred tokens with the graphql client, consider using
request_and_wait_for_finalized instead to ensure the tokens are available in the indexer.
public async Task<FaucetReceipt?> RequestAndWait(Address address)
Parameters
address Address
Returns
Exceptions
RequestAndWaitForFinalized(Address, GraphQlClient)
Request gas from the faucet and wait until the request is completed and token is transferred
and finalized on the ledger. Returns FaucetReceipt if the request is successful, which
contains the list of tokens transferred, and the transaction digest. Returns
FaucetError::Discarded if the faucet discards the request.
This is a convenience method that combines request_and_wait and waiting for the funding
transactions to be finalized using the provided GraphQL GraphQLClient.
public async Task<FaucetReceipt?> RequestAndWaitForFinalized(Address address, GraphQlClient client)
Parameters
address Address
client GraphQlClient
Returns
Exceptions
RequestStatus(String)
Check the faucet request status.
Possible statuses are defined in: FaucetBatchSendStatusType
Returns an error without sending a request if id is empty or contains anything other than
ASCII letters, digits, -, {, } and :, which covers the UUID forms the faucet
accepts.
public async Task<FaucetBatchSendStatus?> RequestStatus(string id)
Parameters
id String
Returns
Exceptions
NewLocalnet()
Create a new Faucet client connected to a localnet faucet.
public static FaucetClient NewLocalnet()
Returns
NewWithHttpOptions(String, HttpClientOptions)
Construct a new FaucetClient using an HTTP client built to the given options.
public static FaucetClient NewWithHttpOptions(string faucetUrl, HttpClientOptions options)
Parameters
faucetUrl String
options HttpClientOptions