Skip to main content

Observer

The Observer sub-client is always available, even without a walletClient. It provides read-only access to CDR and DKG state.
The Observer reads from two backends: CDR contract state (vaults, fees, maxEncryptedDataSize, operational threshold) over the EVM publicClient, and DKG state (active round, global public key, threshold, validators, attestations) over the DATA Foundation API REST endpoint configured by apiUrl.
Round-keyed DKG snapshots are cached for the lifetime of the Observer for rounds in the stable Active and Ended stages, with in-flight request deduplication. getActiveRound() always re-fetches, since the active round can transition at any time.

Methods

  • getVault
  • getAllocateFee
  • getWriteFee
  • getReadFee
  • getMaxEncryptedDataSize
  • getOperationalThreshold
  • getActiveRound
  • getGlobalPubKey
  • getParticipantCount
  • getThreshold
  • getThresholdAt
  • getRegisteredValidators
  • getValidatorAttestations

getVault

Fetch a vault’s on-chain data by UUID. Parameters:
  • uuid: The vault’s unique identifier (uint32)
Example
Vault

getAllocateFee

Returns the current fee (in wei) required to allocate a new vault.
Example

getWriteFee

Returns the current fee (in wei) required to write data to a vault.
Example

getReadFee

Returns the current fee (in wei) required to submit a read request.
Example

getMaxEncryptedDataSize

Returns the maximum encrypted payload size (in bytes) supported by the on-chain vault path. The CDR contract treats this as a constant, so it is cached for the lifetime of the Observer.
Example

getOperationalThreshold

Returns the DKG operational threshold as a basis-points constant read from the DKG contract (e.g., 667 = 66.7%).
Example

getActiveRound

Returns the currently active DKG round number. Always hits the DATA Foundation API REST endpoint, since the active round can transition at any time, so it is never served from cache.
Example

getGlobalPubKey

Returns the DKG global public key from the active round, used for TDH2 encryption. This is an Ed25519 point with a 2-byte curve-code prefix (0x043f), 34 bytes total, so it can be passed directly to the WASM TDH2 functions.
Example

getParticipantCount

Returns the number of validators selected to participate in the active DKG round.
Example

getThreshold

Returns the absolute threshold for the currently active DKG round: the minimum number of partial decryptions needed to combine. If minThresholdRatio is set on the client, the effective value is max(network.threshold, ceil(participants * minThresholdRatio)).
Example
Use this for UI / status display. Do not use it to validate a specific partial-decryption bucket from collectPartials, since a bucket carries its own round, which can differ from the active round during DKG rollover. Use getThresholdAt for that.

getThresholdAt

Returns the absolute threshold for a specific DKG round, computed against that round’s own participant total. Used internally by collectPartials so a DKG rollover mid-poll does not measure a bucket against the wrong round. Parameters:
  • round: The DKG round number to compute the threshold for
Example

getRegisteredValidators

Returns a map of validator address → commPubKey bytes for the given DKG round (defaults to the active round). Only includes validators with Finalized status. The commPubKey is the secp256k1 public key the validator’s TEE uses to sign partial decryption responses. Parameters:
  • params.round (optional): DKG round number. Defaults to the active round.
Example

getValidatorAttestations

Returns a map of validator address → enclaveReport (raw SGX quote bytes) for the given DKG round (defaults to the active round). Only includes validators with Finalized status. Shares a per-round cache with getRegisteredValidators. Parameters:
  • params.round (optional): DKG round number. Defaults to the active round.
Example
Use with verifyAttestation() to verify each validator’s TEE enclave before trusting their partial decryptions.