Overview
Deploying NullGraph to devnet involves three key steps:- Build and deploy the Anchor program to Solana devnet
- Initialize the protocol by creating the ProtocolState singleton
- Update the frontend IDL to match the deployed program
The deployed program ID on devnet is:
2u3DXQq9A6UgMryeVSWCNdYLy3Fjh391R5hcfWYkCgZKPrerequisites
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:
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
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_protocolwith 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 inAnchor.toml:
Protocol Initialization Details
Theinitialize_protocol instruction creates the global ProtocolState account:
Updating the Frontend IDL
After deploying or updating the program, synchronize the frontend IDL: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:Troubleshooting
”Insufficient funds” error
Solution: Request more devnet SOL:“Program already deployed” error
Solution: Useanchor 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
- Run the test suite against devnet
- Explore program architecture
- Learn about accounts and instructions
- Connect the frontend to your deployment