A REST API server for Solana blockchain operations built with Rust and Warp. This server provides endpoints for common Solana operations including keypair generation, token operations, message signing/verification, and transaction instruction creation.
- 🔑 Keypair Generation: Generate new Solana keypairs
- 🪙 Token Operations: Create and mint SPL tokens
- ✍️ Message Signing: Sign messages with private keys
- ✅ Signature Verification: Verify message signatures
- 💸 SOL Transfers: Create SOL transfer instructions
- 🔄 Token Transfers: Create SPL token transfer instructions
- Rust 1.70+
- Cargo package manager
- Clone the repository:
git clone <repository-url>
cd solana-harkirat
- Install dependencies:
cargo build
- Run the server:
cargo run
The server will start on http://localhost:3030
POST /keypair
Generates a new Solana keypair.
Response:
{
"success": true,
"data": {
"pubkey": "11111111111111111111111111111112",
"secret": "base58-encoded-private-key"
}
}
POST /token/create
Creates a new SPL token initialization instruction.
Request Body:
{
"mintAuthority": "public-key-string",
"mint": "mint-public-key-string",
"decimals": 9
}
Response:
{
"success": true,
"data": {
"program_id": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
"accounts": [
{
"pubkey": "account-public-key",
"is_signer": false,
"is_writable": true
}
],
"instruction_data": "base64-encoded-instruction-data"
}
}
POST /token/mint
Creates a mint-to instruction for SPL tokens.
Request Body:
{
"mint": "mint-public-key",
"destination": "destination-account-public-key",
"authority": "mint-authority-public-key",
"amount": 1000000000
}
POST /message/sign
Signs a message with a private key.
Request Body:
{
"message": "Hello, Solana!",
"secret": "base58-encoded-private-key"
}
Response:
{
"success": true,
"data": {
"signature": "base64-encoded-signature",
"public_key": "signer-public-key",
"message": "Hello, Solana!"
}
}
POST /message/verify
Verifies a message signature.
Request Body:
{
"message": "Hello, Solana!",
"signature": "base64-encoded-signature",
"pubkey": "signer-public-key"
}
Response:
{
"success": true,
"data": {
"valid": true,
"message": "Hello, Solana!",
"pubkey": "signer-public-key"
}
}
POST /send/sol
Creates a SOL transfer instruction.
Request Body:
{
"from": "sender-public-key",
"to": "recipient-public-key",
"lamports": 1000000000
}
Response:
{
"success": true,
"data": {
"program_id": "11111111111111111111111111111112",
"accounts": [
"sender-public-key",
"recipient-public-key"
],
"instruction_data": "base64-encoded-instruction-data"
}
}
POST /send/token
Creates an SPL token transfer instruction.
Request Body:
{
"destination": "destination-token-account",
"mint": "token-mint-public-key",
"owner": "token-owner-public-key",
"amount": 1000000
}
All endpoints return error responses in the following format:
{
"success": false,
"error": "Error description"
}
Common errors:
- Invalid public key format
- Invalid secret key format
- Missing required fields
- Failed instruction creation
├── main.rs # Main server code
├── Cargo.toml # Dependencies and project configuration
├── Cargo.lock # Dependency lock file
└── README.md # This file
tokio
- Async runtimewarp
- Web frameworkserde
- Serialization/deserializationsolana-sdk
- Solana blockchain SDKspl-token
- SPL token programspl-associated-token-account
- Associated token accountsbs58
- Base58 encodingbase64
- Base64 encoding
cargo build --release
The binary will be available at target/release/solana-http-server
- Generate a keypair:
curl -X POST http://localhost:3030/keypair
- Sign a message:
curl -X POST http://localhost:3030/message/sign \
-H "Content-Type: application/json" \
-d '{
"message": "Hello Solana",
"secret": "your-base58-private-key"
}'
- Create SOL transfer:
curl -X POST http://localhost:3030/send/sol \
-H "Content-Type: application/json" \
-d '{
"from": "sender-pubkey",
"to": "recipient-pubkey",
"lamports": 1000000000
}'
- This server is designed for development and testing purposes
- Never expose private keys or run this server with real funds in production
- Always validate and sanitize inputs in production environments
- Consider implementing authentication and rate limiting for production use
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
This project is licensed under the MIT License.
For issues and questions, please open an issue on the GitHub repository.