@nimiq-faucet/sdk
Framework-agnostic TypeScript client for the Nimiq Simple Faucet. Works in browsers and Node.js.
Install
bash
npm install @nimiq-faucet/sdkUsage
ts
import { FaucetClient } from '@nimiq-faucet/sdk';
const client = new FaucetClient({ url: 'https://faucet.example.com' });
// Simple claim
const { id } = await client.claim(address);
const result = await client.waitForConfirmation(id);
// With hashcash (auto-solves the challenge)
const result = await client.solveAndClaim(address, {
hostContext: { uid: hashedUserId, kycLevel: 'email' },
});API
new FaucetClient({ url, apiKey?, hmacSecret? })— construct a clientclient.config()— fetch faucet configurationclient.claim(address, options?)— submit a claimclient.status(id)— check claim statusclient.requestChallenge(uid?)— get a hashcash challengeclient.solveAndClaim(address, options?)— end-to-end claim with hashcashclient.waitForConfirmation(id, timeoutMs?)— poll until confirmed/rejectedclient.subscribe(onEvent)— WebSocket event streamsolveHashcash(challenge, difficulty)— standalone hashcash solver
License
MIT