Skip to main content

Overview

The NullGraph SDK provides 9 React hooks for interacting with the Solana program:
  • Read Hooks: Fetch on-chain data with automatic updates
  • Write Hooks: Submit transactions and modify state

Read Hooks

useProtocolState

Fetch the global protocol state including counters, fees, and treasury.

Usage Example

Return Fields

ProtocolStateAccount | null
The protocol state account data, or null if not yet loaded
boolean
True while fetching data from the blockchain
string | null
Error message if the fetch failed
() => Promise<void>
Function to manually refresh the data

useNullResults

Fetch all null result (NKA) submissions, sorted by specimen number descending.

Usage Example

Return Fields

NullResultWithKey[]
Array of null result accounts, each with a publicKey field
boolean
True while fetching data
string | null
Error message if fetch failed
() => Promise<void>
Manually refresh the data

useBounties

Fetch all bounties, sorted by bounty number descending.

Usage Example


useBountySubmissions

Fetch submissions for a specific bounty, or all submissions if no bounty is specified.

Usage Example

Parameters

PublicKey
Public key of the bounty to filter submissions. If omitted, returns all submissions.

Write Hooks

useSubmitNullResult

Submit a new null result (NKA) to the protocol.

Usage Example

Parameters

number[]
required
UTF-8 encoded hypothesis string as byte array
number[]
required
UTF-8 encoded methodology description as byte array
number[]
required
UTF-8 encoded expected outcome as byte array
number[]
required
UTF-8 encoded actual outcome as byte array
number
required
Statistical p-value (0.0 to 1.0)
number
required
Number of samples in the study
number[]
required
32-byte hash of the underlying data

Return Value

Returns the specimen number (e.g., 1, 2, 3) on success, or null if the transaction failed.

useCreateBounty

Create a new bounty with BIO token rewards.

Usage Example

The hook automatically handles BIO token transfers from the creator’s associated token account to the bounty vault.

useSubmitToBounty

Submit an existing null result to a bounty.

Usage Example


useApproveBountySubmission

Approve a bounty submission and transfer rewards to the researcher.

Usage Example

This hook automatically creates associated token accounts for the researcher and treasury if they don’t exist. The creator pays for account rent.

useCloseBounty

Close an open bounty and refund BIO tokens to the creator.

Usage Example


Hook Patterns

Error Handling

All write hooks display toast notifications automatically. Read hooks return error messages:

Loading States

All hooks provide a loading boolean for UI feedback:

Refetching Data

Read hooks provide a refetch function for manual updates:

Next Steps

PDA Derivation

Learn how to derive Program Derived Addresses for accounts

Types

Explore TypeScript interfaces for type-safe development