Skip to main content

Overview

Deploying NullGraph to devnet involves three key steps:
  1. Build and deploy the Anchor program to Solana devnet
  2. Initialize the protocol by creating the ProtocolState singleton
  3. Update the frontend IDL to match the deployed program
The deployed program ID on devnet is: 2u3DXQq9A6UgMryeVSWCNdYLy3Fjh391R5hcfWYkCgZK

Prerequisites

Before deploying, ensure you have:
  • Completed the local setup
  • Built the program with anchor build
  • At least 2 SOL in your devnet wallet for deployment
  • Configured Solana CLI to devnet: solana config set --url devnet

Deployment Steps

1

Build the program

Compile the Anchor program and generate the IDL:
This creates:
  • Compiled program binary: target/deploy/nullgraph.so
  • IDL file: target/idl/nullgraph.json
  • TypeScript types: target/types/nullgraph.ts
2

Fund your wallet

Ensure your wallet has sufficient devnet SOL:
Program deployment requires ~2 SOL. Make sure you have enough before proceeding.
3

Deploy to devnet

Deploy the program to the Solana devnet cluster:
This command:
  • Uploads the compiled program to devnet
  • Uses the program ID from Anchor.toml: 2u3DXQq9A6UgMryeVSWCNdYLy3Fjh391R5hcfWYkCgZK
  • Deducts deployment costs from your wallet
Expected output:
4

Initialize the protocol

Run the one-time initialization script to create the ProtocolState singleton:
This script:
  • Derives the ProtocolState PDA: ["protocol_state"]
  • Calls initialize_protocol with fee rate of 250 basis points (2.5%)
  • Sets the treasury address
  • Initializes counters (nka_counter, bounty_counter) to zero
This script only needs to run once per deployment. If the PDA already exists, it will fail with “already in use”.
5

Verify deployment

Verify the program deployed successfully:
You can also view the program on Solana Explorer:https://explorer.solana.com/address/2u3DXQq9A6UgMryeVSWCNdYLy3Fjh391R5hcfWYkCgZK?cluster=devnet

Anchor Configuration

The deployment configuration is defined in Anchor.toml:

Protocol Initialization Details

The initialize_protocol instruction creates the global ProtocolState account:
ProtocolState Fields:

Updating the Frontend IDL

After deploying or updating the program, synchronize the frontend IDL:
This ensures the frontend’s Anchor client uses the correct program interface.
If you modify the program and redeploy, you must update the IDL files in the frontend. Mismatched IDLs will cause transaction failures.

Program Upgrades

To upgrade an existing deployment with new program code:
1

Make your code changes

Edit programs/nullgraph/src/lib.rs with your updates.
2

Rebuild the program

3

Deploy the upgrade

4

Update the frontend IDL

Only the upgrade authority (the wallet that deployed the program) can upgrade it. Check the upgrade authority with:

Deployment Checklist

  • Built program: anchor build
  • Funded wallet with 2+ SOL: solana balance
  • Deployed program: anchor deploy --provider.cluster devnet
  • Initialized protocol: npx ts-node scripts/init-protocol.ts
  • Verified deployment: solana program show <program-id>
  • Updated frontend IDL: cp target/idl/nullgraph.json app/src/lib/
  • Tested frontend connection: cd app && npm run dev

Deployment Costs

Costs are for devnet and may vary. Mainnet costs will be similar but use real SOL.

Verifying On-Chain State

After initialization, verify the ProtocolState account:
Or query directly via the frontend hooks:

Troubleshooting

”Insufficient funds” error

Solution: Request more devnet SOL:

“Program already deployed” error

Solution: Use anchor upgrade instead of anchor deploy:

“PDA already in use” during initialization

Solution: The protocol is already initialized. Skip the initialization step.

”Transaction simulation failed” on frontend

Solution: Ensure the frontend IDL matches the deployed program:

Next Steps