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 fromtypes/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 + 1BN
Total number of bounties created. Next bounty will be
bountyCounter + 1number
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 = DisputedBN
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 = ClosedPublicKey
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 = RejectedBN
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
useNullResults() hook.
NullBountyWithKey
useBounties() hook.
BountySubmissionWithKey
useBountySubmissions() hook.
Status Enums
NKA_STATUS
Status values for null results:Usage Example
BOUNTY_STATUS
Status values for bounties:Status Flow
- OPEN (0): Bounty is accepting submissions
- MATCHED (1): Creator approved a submission but hasn’t transferred funds yet
- FULFILLED (2): Reward has been paid out to researcher
- 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
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