Skip to main content

Overview

The NullGraph SDK provides fully typed TypeScript interfaces for all on-chain accounts, ensuring type safety when building frontend applications.

Account Interfaces

All account types are exported from types/index.ts:

ProtocolStateAccount

The global protocol state containing counters, fees, and treasury information.

Fields

PublicKey
The protocol authority that can update fees and treasury
BN
Total number of null results submitted. Next submission will be nkaCounter + 1
BN
Total number of bounties created. Next bounty will be bountyCounter + 1
number
Protocol fee in basis points (e.g., 250 = 2.5%). Applied when bounties are fulfilled.
PublicKey
Treasury address that receives protocol fees
number
PDA bump seed for the protocol state account

Usage Example


NullResultAccount

A null result (NKA) submission containing research metadata and statistical information.

Fields

PublicKey
Public key of the researcher who submitted this null result
BN
Unique specimen number (e.g., 1 for NKA-0001)
number[]
UTF-8 encoded hypothesis string as byte array (max 256 bytes)
number[]
UTF-8 encoded methodology description as byte array (max 512 bytes)
number[]
UTF-8 encoded expected outcome as byte array (max 256 bytes)
number[]
UTF-8 encoded actual outcome as byte array (max 256 bytes)
number
Statistical p-value (0.0 to 1.0) indicating significance
number
Number of samples in the study
number[]
32-byte hash of the underlying research data for verification
number
Current status: 0 = Pending, 1 = Verified, 2 = Disputed
BN
Unix timestamp when the null result was submitted
number
PDA bump seed

Usage Example


NullBountyAccount

A bounty offering rewards for matching null results.

Fields

PublicKey
Public key of the bounty creator
BN
Unique bounty number (e.g., 1 for NB-0001)
number[]
UTF-8 encoded bounty description as byte array (max 512 bytes)
BN
Reward amount in token lamports (BIO has 6 decimals)
PublicKey
Mint address of the reward token (typically BIO token)
PublicKey
Token account holding the bounty reward
BN
Unix timestamp when the bounty expires
number
Current status: 0 = Open, 1 = Matched, 2 = Fulfilled, 3 = Closed
PublicKey
Public key of the approved submission (if status is Matched or Fulfilled)
BN
Unix timestamp when the bounty was created
number
PDA bump seed for the vault account
number
PDA bump seed for the bounty account

Usage Example


BountySubmissionAccount

A submission linking a null result to a bounty.

Fields

PublicKey
Public key of the researcher who submitted
PublicKey
Public key of the null result being submitted
PublicKey
Public key of the bounty
number
Submission status: 0 = Pending, 1 = Approved, 2 = Rejected
BN
Unix timestamp when submission was created
number
PDA bump seed

Usage Example


Extended Types with Public Keys

For convenience, the SDK provides extended interfaces that include the account’s public key:

NullResultWithKey

Returned by useNullResults() hook.

NullBountyWithKey

Returned by useBounties() hook.

BountySubmissionWithKey

Returned by useBountySubmissions() hook.

Status Enums

NKA_STATUS

Status values for null results:

Usage Example


BOUNTY_STATUS

Status values for bounties:

Status Flow

  1. OPEN (0): Bounty is accepting submissions
  2. MATCHED (1): Creator approved a submission but hasn’t transferred funds yet
  3. FULFILLED (2): Reward has been paid out to researcher
  4. CLOSED (3): Bounty was closed by creator without fulfillment

Usage Example


SUBMISSION_STATUS

Status values for bounty submissions:

Usage Example


Type Guards

Create type guards for runtime type checking:

Utility Functions

Converting Byte Arrays to Strings

Converting Strings to Byte Arrays

Formatting Timestamps

Formatting Token Amounts


Type Safety Best Practices

Always use the typed interfaces when working with account data. This prevents runtime errors from typos or incorrect field access.
When converting byte arrays to strings, always check for trailing zeros and handle empty arrays gracefully.
Use BN.toNumber() carefully with large numbers. For display purposes, consider using BN.toString() instead to avoid precision loss.

Complete Type Import

Import all types in one statement:

Next Steps

Hooks

Learn how to fetch and manipulate these types with React hooks

PDA Derivation

Understand how to derive addresses for these accounts