Skip to main content
This guide walks you through building, deploying, and running NullGraph locally.

Installation

1
Clone the Repository
2
Clone the NullGraph repository and navigate to the project directory:
3
git clone <repository-url>
cd nullgraph
4
Install Root Dependencies
5
Install the root-level dependencies for Anchor testing and scripts:
6
npm install
7
This installs:
8
  • @coral-xyz/anchor (v0.31.1) - Anchor framework for Solana
  • @solana/spl-token (v0.4.14) - SPL Token utilities
  • Testing dependencies (Mocha, Chai, TypeScript)
  • 9
    Install Frontend Dependencies
    10
    Navigate to the frontend directory and install dependencies:
    11
    cd app
    npm install
    cd ..
    
    12
    The frontend uses:
    13
  • React 19.2 with TypeScript 5.9
  • Vite 7.3 for build tooling
  • Tailwind CSS 4.2 for styling
  • Solana wallet adapter libraries
  • React Router 7.13 for routing
  • 14
    Configure Solana CLI
    15
    Set your Solana CLI to point to devnet:
    16
    solana config set --url devnet
    
    17
    Verify the configuration:
    18
    solana config get
    
    19
    You should see:
    20
    RPC URL: https://api.devnet.solana.com
    

    Build and Deploy

    1
    Build the Anchor Program
    2
    Compile the Solana program:
    3
    anchor build
    
    4
    This compiles the Rust program in programs/nullgraph/src/lib.rs and generates:
    5
  • Program binary in target/deploy/nullgraph.so
  • IDL in target/idl/nullgraph.json
  • TypeScript types in target/types/nullgraph.ts
  • 6
    The build process may take several minutes on the first run as it downloads and compiles dependencies.
    7
    Deploy to Devnet
    8
    Deploy the compiled program to Solana devnet:
    9
    anchor deploy --provider.cluster devnet
    
    10
    This uploads the program to devnet and returns a program ID. The default program ID is:
    11
    2u3DXQq9A6UgMryeVSWCNdYLy3Fjh391R5hcfWYkCgZK
    
    12
    Deployment requires SOL for transaction fees and rent. Ensure your wallet has at least 2 SOL. Use solana airdrop 2 --url devnet to get devnet SOL.
    13
    Initialize the Protocol
    14
    Run the one-time initialization script to create the protocol state account:
    15
    npx ts-node scripts/init-protocol.ts
    
    16
    This script:
    17
  • Derives the ProtocolState PDA from seed ["protocol_state"]
  • Calls initialize_protocol with fee set to 250 basis points (2.5%)
  • Sets your wallet as the protocol authority and treasury
  • Initializes NKA and bounty counters to zero
  • 18
    Expected output:
    19
    Authority: <your-public-key>
    Protocol State PDA: <protocol-state-address>
    Treasury (same as authority): <your-public-key>
    Initializing protocol with fee_basis_points = 250 (2.5%)...
    Transaction signature: <signature>
    Protocol initialized successfully!
    
    20
    If the protocol is already initialized, the script will detect the existing account and skip initialization.

    Run the Frontend

    1
    Start the Development Server
    2
    Navigate to the app directory and start Vite:
    3
    cd app
    npm run dev
    
    4
    The development server starts at:
    5
    http://localhost:5173
    
    6
    Connect Your Wallet
    7
  • Open http://localhost:5173 in your browser
  • Click “Connect Wallet” in the navigation bar
  • Select Phantom from the wallet list
  • Approve the connection in the Phantom popup
  • Ensure Phantom is set to Devnet
  • 8
    If you see wallet connection errors, verify that:
    • Phantom is installed and unlocked
    • Phantom is set to Devnet network
    • You’re using a supported browser (Chrome, Firefox, Brave, Edge)

    Configuration

    Environment Variables

    The frontend accepts optional environment variables. Create app/.env if you need custom configuration:
    # Optional: Custom RPC endpoint
    VITE_RPC_URL=https://api.devnet.solana.com
    
    # Optional: Custom program ID (if you deployed your own)
    VITE_PROGRAM_ID=2u3DXQq9A6UgMryeVSWCNdYLy3Fjh391R5hcfWYkCgZK
    

    Update IDL After Program Changes

    If you modify the Anchor program, rebuild and sync the IDL to the frontend:
    # Rebuild the program
    anchor build
    
    # Copy IDL and types to frontend
    cp target/idl/nullgraph.json app/src/lib/nullgraph.json
    cp target/types/nullgraph.ts app/src/lib/nullgraph_types.ts
    

    Testing

    Run Anchor Tests

    Test the program using the Anchor test suite:
    # Run against local validator (auto-starts/stops)
    anchor test
    
    # Run against existing devnet deployment
    anchor test --skip-local-validator --provider.cluster devnet
    
    The test suite (tests/nullgraph.ts) covers:
    • Protocol initialization
    • NKA submission and counter increment
    • Bounty creation with BIO escrow
    • Bounty submissions and approvals
    • Fee calculation and distribution
    • Error cases (invalid status, duplicate init, etc.)

    Architecture Overview

    NullGraph runs entirely on Solana with no backend server:
    React Frontend (Vite)
           |
           v
      Wallet Adapter
           |
           v
     Solana Devnet RPC
           |
           v
    NullGraph Program (Anchor)
      - ProtocolState PDA
      - NullResult PDAs (NKAs)
      - NullBounty PDAs
      - BountySubmission PDAs
      - Vault Token Accounts
    
    Key Components:
    • Program ID: 2u3DXQq9A6UgMryeVSWCNdYLy3Fjh391R5hcfWYkCgZK
    • BIO Token Mint: GkjGV1ZF5BsMs6oAvk8jZiuXM8KwuygFCHLBpqR5Q14j
    • RPC Endpoint: https://api.devnet.solana.com
    • Network: Solana Devnet

    Troubleshooting

    Build Errors

    Error: anchor: command not found Solution: Ensure Anchor CLI is installed and in your PATH:
    anchor --version
    
    Error: failed to get recent blockhash: FetchError Solution: Check your internet connection and verify Solana CLI config:
    solana config get
    

    Deployment Errors

    Error: Insufficient SOL balance Solution: Airdrop devnet SOL:
    solana airdrop 2 --url devnet
    
    Error: Transaction simulation failed Solution: The program may already be deployed. Check the program account:
    solana program show 2u3DXQq9A6UgMryeVSWCNdYLy3Fjh391R5hcfWYkCgZK --url devnet
    

    Frontend Errors

    Error: Failed to connect to wallet Solution: Ensure Phantom is installed, unlocked, and set to Devnet. Error: Program account does not exist Solution: Deploy the program or use the existing devnet deployment.

    Next Steps

    Now that NullGraph is running, proceed to the Quickstart Guide to submit your first NKA and create a bounty.

    Build docs developers (and LLMs) love