This project provides a Solana program and client application to manage nodes and dispatch tasks across nodes, built using Solana's Rust SDK. The program defines four main instructions:
- RegisterNode: Registers a new node with a specified ID.
- RemoveNode: Removes a node based on its ID.
- DispatchTask: Dispatches a task to a node, specifying a unique task ID.
- ReturnAnswer: Returns a response or answer from a node for a given task.
The project also includes a TypeScript client for interacting with the Solana program, making it easy to manage nodes and execute tasks directly from a client environment.
- Node.js and npm: Required to run the TypeScript client.
- Rust and Cargo: Required to build and deploy the Solana program.
Note: For easy testing and deployment, you can use the Solana Playground, an in-browser development environment for Solana, eliminating the need for a full local Solana setup.
Solana Playground provides a quick, convenient way to develop on Solana without a local setup.
- Open Solana Playground.
- In the bottom left corner, create or connect a wallet, which will be used for deploying and testing the program.
- Copy or write the Rust code for your program in the Playground.
- Use the Build button to compile the program.
- Use the Deploy button to deploy the program to the Playground network, which assigns a
PROGRAM_ID
. - Copy the
PROGRAM_ID
, as you’ll need it in the client code to interact with the program.
The client provides interactions for all four instructions in the Solana program:
RegisterNode: Registers a node by providing its ID. RemoveNode: Removes a node by ID. DispatchTask: Sends a task to a specified node. ReturnAnswer: Retrieves a response from a node for a dispatched task. These instructions are serialized and sent as transactions to the program, with nodeId and taskId as parameters.