This project presents a comprehensive solution for backend integration with the Solana blockchain, employing Rust and the Rocket framework. The system offers essential endpoints for tracking and employing blockchain operations. Prometheus metrics measuring request numbers and response times are added to ensure effective monitoring. Integration tests are implemented for each endpoint using Wiremock for Solana RPC Endpoints to enable offline testing. Project is dockerized and supported with Gitlab CI/CD pipelines.
- Build the project:
cargo build- Run the project:
cargo run- Run tests:
cargo test- Dockerize the project:
docker build . -t blockchain-solana
docker run --rm -p 8000:8000 blockchain-solanaNote: Address and port numbers are obtained from the environment (include .env file with ROCKET_PORT and ROCKET_ADDRESS to specify)
| Endpoints | Description |
|---|---|
[GET] /blocks/latest |
Get latest block information on the chain |
[GET] /blocks/\<slot> |
Get block details including transactions on the specified block |
[POST] /transactions/sign |
Generate signed transaction with given parameters in the request body |
[POST] /transactions/send |
Send signed transaction to the chain |
[GET] /transactions/\<txnHash>/detail |
Get detailed information of the specified transaction |
[GET] /transactions/\<txnHash>/confirmations |
Get confirmation count of the given transaction |
[POST] /address |
Generate wallet address |
[GET] /address/\<address>/balance?\<contract> |
Get wallet SOL/token balance |
[GET] /fee/estimate?\<contract> |
Get a fee estimate for SOL/token transactions |
Endpoint: [GET] /blocks/latest
Request body: None
Response:
{
"height": Int
"hash": String
}
Endpoint: [GET] /blocks/\<slot>
Request body: None
Response:
{
"hash": String,
"height": Int,
transactions: [
{
"from": [
{
"adress": String,
"amount": Float,
"contract": String
},
{
"adress": String,
"amount": Float,
"contract": String
}
, ...
],
"to": [
{
"adress": String,
"amount": Float,
"contract": String
}
, ...
],
"hash": String,
"status": String,
}
]
}
Endpoint: [POST] /transactions/sign
Request body:
{
"from": [
{
"adress": String,
"amount": Float,
"contract": String
},
{
"adress": String,
"amount": Float,
"contract": String
}
, ...
],
"to": [
{
"adress": String,
"amount": Float,
"contract": String
}
, ...
],
"privateKey": String
}
Response:
{
"signedTransaction": String,
"txnHash": String
}
Endpoint: [POST] /transactions/send
Request body:
{
"signedTransaction": String
}
Response:
{
"txnHash": String
}
Endpoint: [GET] /transactions/\<txnHash>/detail
Request body: None
Response:
{
"from":[
{
"adress": String,
"amount": Float,
"contract": String
},
{
"adress": String,
"amount": Float,
"contract": String
}
, ...
],
"to":[
{
"adress": String,
"amount": Float,
"contract": String
}
, ...
],
"hash": String,
"status": String,
"fee": Float,
"blockHash": String,
"blockHeight": Int
}
Endpoint: [GET] /transactions/\<txnHash>/confirmations
Request body: None
Response:
{
"confirmationsCount": Int
}
Endpoint: [POST] /address
Request body: None
Response:
{
"address": String,
"privateKey": String
}
Endpoint: [GET] /address/{address}/balance?{contract}
Request body: None
Response:
{
"balance": Float
}
Endpoint: [GET] /fee/estimate?{contract}
Request body: None
Response:
{
"calculatedFee": Int
}
-
Onur Sezen (onursezen@sabanciuniv.edu)
-
Doğa Demirtürk (ddemirturk18@ku.edu.tr)