A Rust-based service that displays transactions sent by clients. The service provides a REST API for sending transactions and viewing transaction history.
- Transaction Display: Store and display all transactions sent by clients
- REST API: Clean HTTP endpoints for transaction operations
- Rate Limiting: Built-in rate limiting (100 TPS)
- CORS Support: Cross-origin resource sharing enabled
- Error Handling: Comprehensive error responses
- Logging: Structured logging with tracing
Health check endpoint to verify service is running.
Response:
HTTP/1.1 200 OK
Send a transaction and display it in the service.
Request Body:
{
"from_address": "sender_address",
"to_address": "recipient_address",
"amount": 1.5,
"memo": "Optional transaction memo"
}
Response:
{
"transaction_id": "uuid",
"status": "confirmed",
"message": "Transaction sent and displayed successfully",
"timestamp": "2024-01-01T12:00:00Z"
}
Get all displayed transactions.
Response:
[
{
"id": "uuid",
"transaction_id": "uuid",
"from_address": "sender_address",
"to_address": "recipient_address",
"amount": 1.5,
"memo": "Optional memo",
"status": "confirmed",
"timestamp": "2024-01-01T12:00:00Z",
"signature": "mock_signature_xxx",
"block_time": 1704110400
}
]
Get a specific transaction by ID.
Response:
{
"id": "uuid",
"transaction_id": "uuid",
"from_address": "sender_address",
"to_address": "recipient_address",
"amount": 1.5,
"memo": "Optional memo",
"status": "confirmed",
"timestamp": "2024-01-01T12:00:00Z",
"signature": "mock_signature_xxx",
"block_time": 1704110400
}
- Rust 1.70+
- Cargo
- Clone and build:
git clone <repository>
cd Node-Service-Provider
cargo build --release
- Run the service:
cargo run
The service will start on http://localhost:3000
SOLANA_RPC_URL
: Solana RPC endpoint (defaults to devnet)
A command-line client is provided in the client/
directory.
Build and run:
cd client
cargo build
cargo run
Features:
- Interactive menu for sending transactions
- View all transactions
- View specific transaction by ID
- Health check
A simple HTML web client is provided at client/web_client.html
.
Usage:
- Open
client/web_client.html
in a web browser - Fill in transaction details
- Click "Send Transaction" to send
- Click "View All Transactions" to see history
- TransactionDisplayService: Core service for handling transactions
- RateLimiter: Rate limiting implementation
- Models: Data structures for requests/responses
- Errors: Error handling and custom error types
Transactions are stored in memory using DashMap
for thread-safe concurrent access. In a production environment, you would want to use a persistent database.
- Client sends transaction request
- Service validates request
- Rate limiter checks limits
- Transaction is processed (currently mock implementation)
- Transaction is stored and displayed
- Response is returned to client
.
├── src/
│ ├── main.rs # Main service entry point
│ ├── transaction_display_service.rs # Core transaction service
│ ├── models.rs # Data models
│ ├── errors.rs # Error handling
│ └── rate_limiter.rs # Rate limiting
├── client/
│ ├── src/main.rs # Rust CLI client
│ ├── Cargo.toml # Client dependencies
│ └── web_client.html # Web client
├── tests/ # Integration tests
└── Cargo.toml # Service dependencies
Run the integration tests:
cargo test
To integrate with real Solana transactions:
- Update
create_mock_transaction()
intransaction_display_service.rs
- Add proper Solana transaction creation and signing
- Submit to actual Solana network
- Store real transaction signatures and block times
Send a transaction:
curl -X POST http://localhost:3000/sendTransaction \
-H "Content-Type: application/json" \
-d '{
"from_address": "sender123",
"to_address": "recipient456",
"amount": 1.5,
"memo": "Payment for services"
}'
Get all transactions:
curl http://localhost:3000/transactions
Get specific transaction:
curl http://localhost:3000/transactions/uuid-here
The service returns appropriate HTTP status codes and error messages:
400 Bad Request
: Invalid request data429 Too Many Requests
: Rate limit exceeded404 Not Found
: Transaction not found500 Internal Server Error
: Server error
Error responses include:
{
"error": "Error type",
"message": "Detailed error message"
}
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
This project is licensed under the MIT License.