DIRNGClient

@buff-beacon-project/curby-clientDocs


@buff-beacon-project/curby-client / DIRNGClient

Class: DIRNGClient

A client for the Device Independent Randomness Generation (DIRNG) chain

Example

import { DIRNGClient } from '@buff-beacon-project/curby-client'

const client = DIRNGClient.create()
const randomness = await client.randomness()
console.log(randomness)

Constructors

new DIRNGClient()

new DIRNGClient(options?): DIRNGClient

Create a new client

Parameters

Parameter
Type
Description

options?

The options for the client

Returns

DIRNGClient

Defined in

src/dirng.ts:407

Methods

fetchRound()

fetchRound(round?): Promise<RoundData>

Fetch and validate the round data for a round

Parameters

Parameter
Type

round?

number | "latest" | "pending"

Returns

Promise<RoundData>

Defined in

src/dirng.ts:470


fetchRoundData()

fetchRoundData(round): Promise<string>

Fetch the raw bell data for a round

Will validate the hash of the data

Parameters

Parameter
Type

Returns

Promise<string>

Defined in

src/dirng.ts:446


fetchRoundParams()

fetchRoundParams(round): Promise<any>

Fetch the parameters for a round

Will validate the hash of the parameters

Parameters

Parameter
Type

Returns

Promise<any>

Defined in

src/dirng.ts:422


latest()

latest(): Promise<RoundData>

Get the latest round data

Returns

Promise<RoundData>

Defined in

src/dirng.ts:523


randomness()

randomness(): Promise<ByteHelper>

Get the latest randomness

Returns

Promise<ByteHelper>

Defined in

src/dirng.ts:515


refresh()

refresh(): Promise<void>

Refresh the internal state of the client

Returns

Promise<void>

Defined in

src/dirng.ts:502


waitForNext()

waitForNext(__namedParameters): Promise<undefined | RoundData>

Wait for the next round

Parameters

Parameter
Type

__namedParameters

Returns

Promise<undefined | RoundData>

Defined in

src/dirng.ts:531


watch()

watch(options?): AsyncGenerator<RoundData, void, unknown>

Watch for new rounds

Parameters

Parameter
Type
Description

options?

The options for waiting

Returns

AsyncGenerator<RoundData, void, unknown>

Example

const client = DIRNGClient.create()
for await (const round of client.watch()){
  console.log(round)
}

#### Defined in

[src/dirng.ts:568](https://github.com/buff-beacon-project/curby-js-client/blob/95397f5e9fcc8ad57ef410c54473862e0b83bc59/src/dirng.ts#L568)

***

### create()

> `static` **create**(`options`?): [`DIRNGClient`](DIRNGClient.md)

Create a new client

#### Parameters

| Parameter | Type |
| ------ | ------ |
| `options`? | [`DIRNGClientOptions`](../type-aliases/DIRNGClientOptions.md) |

#### Returns

[`DIRNGClient`](DIRNGClient.md)

#### Defined in

[src/dirng.ts:399](https://github.com/buff-beacon-project/curby-js-client/blob/95397f5e9fcc8ad57ef410c54473862e0b83bc59/src/dirng.ts#L399)

Last updated