Drand Client
class DrandClient(api: DrandApi, cache: Cache<String, ChainInfo> = SimpleCache(), verifier: BeaconVerificationService = BeaconVerificationService()) : Closeable
Client for interacting with the drand distributed randomness network.
This client provides verified access to drand beacons with automatic cryptographic verification of all received randomness.
Example usage:
// Create client
val client = DrandClient()
// Get latest verified randomness
val beacon = client.getVerifiedLatestBeacon().getOrThrow()
println("Randomness: ${beacon.randomness}")
// Get specific round
val round1000 = client.getVerifiedBeacon(1000).getOrThrow()
// Clean up
client.close()Content copied to clipboard
Or use with Kotlin's use:
DrandClient().use { client ->
val beacon = client.getVerifiedLatestBeacon().getOrThrow()
// ...
}Content copied to clipboard
Parameters
api
The underlying API implementation for network transport (default: HTTP)
cache
Thread-safe cache for storing chain information to reduce network calls
verifier
Service for cryptographic verification of beacons
Constructors
Link copied to clipboard
constructor(baseUrl: String = "https://api.drand.sh", httpConfig: HttpConfig = HttpConfig(), enableCache: Boolean = true)
Creates a client using HTTP transport with the specified base URL.
constructor(api: DrandApi, cache: Cache<String, ChainInfo> = SimpleCache(), verifier: BeaconVerificationService = BeaconVerificationService())