| Crates.io | lotus-client-schema-rs |
| lib.rs | lotus-client-schema-rs |
| version | 0.1.4 |
| created_at | 2024-11-01 06:28:10.49502+00 |
| updated_at | 2024-11-16 13:41:13.824892+00 |
| description | Rust client library for interacting with Lotus JSON-RPC API |
| homepage | |
| repository | |
| max_upload_size | |
| id | 1431376 |
| size | 628,097 |
A Rust client library for interacting with the Lotus JSON-RPC API. This library provides a type-safe, async interface for communicating with Lotus nodes.
This has not been rigorously tested! Contributions and feedback are welcome.
Add this to your Cargo.toml:
[dependencies]
lotus-client = "0.1.1"
use lotus_client::LotusClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Create a new client
let client = LotusClient::new(
"http://127.0.0.1:1234/rpc/v0",
Some("YOUR_AUTH_TOKEN".to_string())
).await?;
// Use the client to make API calls
let version = client.version(serde_json::Value::Null).await?;
println!("Lotus version: {:?}", version
);
Ok(())
}
The client provides comprehensive coverage of the Lotus JSON-RPC API through generated code:
CommonApi - Common methods shared across different APIsFullNodeApi - Full node API methodsStorageMinerApi - Storage miner specific methodsGatewayApi - Gateway API methodsWalletApi - Wallet management methodsWorkerApi - Worker API methodsThe API bindings are generated from the Lotus JSON-RPC API schema using a custom code generator. To regenerate the bindings:
chmod +x ./go-schemagen/generate-schema-for-api.sh
./go-schemagen/generate-schema-for-api.sh
The library uses custom error types for better error handling:
ClientError - Errors from the JSON-RPC clientSerializationError - JSON serialization/deserialization errorsJsonRpcError - Errors returned by the Lotus JSON-RPC APIContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.