The Akave SDK is a Rust-based software development kit that provides a unified interface for interacting with the Akave blockchain storage system. It supports both native Rust applications and WebAssembly (WASM) environments, making it versatile for various use cases.
- Dual Platform Support
- Native Rust applications
- WebAssembly (WASM) for browser-based applications
- Bucket Management
- Create and delete buckets
- List buckets
- View bucket details
- File Operations
- Upload files with optional encryption
- Download files
- List files within buckets
- Delete files
- Blockchain Integration
- Seamless interaction with Akave blockchain
- Transaction management
- Wallet integration (MetaMask for WASM)
See the examples directory for complete usage examples and ready to use base boilerplates:
native-demo/- Native Rust e2e exampleweb-demo/- Browser-based example applicationweb-demo-react/- Real world browser-based typescript React example project:- TanStack Query for robust, declarative data fetching and state management.
- RainbowKit for seamless wallet connection and a polished user experience.
- Wagmi & Viem for type-safe, high-performance Ethereum (EVM) blockchain interactions, including integration with the Akave blockchain.
- All components are written in TypeScript and designed for real-world scalability and maintainability.
Add the following to your Cargo.toml:
[dependencies]
akave-rs = "0.1.1"Install the WASM package via npm:
npm install @akave/akave-rsuse akave_rs::AkaveSDK;
use std::fs::File;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Initialize SDK
let mut sdk = AkaveSDK::new("http://23.227.172.82:7001/grpc").await?;
// Create a bucket
let bucket_name = "my-bucket";
let bucket = sdk.create_bucket(bucket_name).await?;
// Upload a file
let file = File::open("path/to/file")?;
sdk.upload_file(bucket_name, "file.txt", file, None).await?;
// List files
let files = sdk.list_files(bucket_name).await?;
// Download a file
let output_file = File::create("/path/to/save/file.txt")?;
sdk.download_file(bucket_name, "file.txt", output_file, None).await?;
Ok(())
}import init, { AkaveWebSDKBuilder } from "@akave/akave-web-sdk";
async function initialize() {
// Initialize WASM
await init();
// Create SDK instance with builder pattern
const sdk = await new AkaveWebSDKBuilder("http://23.227.172.82:7001/grpc")
.withDefaultEncryption("encryption-key")
.withErasureCoding(4, 2)
.build();
// Create bucket
await sdk.createBucket("my-bucket");
// List buckets
const buckets = await sdk.listBuckets();
// Upload file
const fileInput = document.querySelector('input[type="file"]');
const file = fileInput.files[0];
const arrayBuffer = await file.arrayBuffer();
await sdk.uploadFile("my-bucket", "file.txt", arrayBuffer);
// List files
const files = await sdk.listFiles("my-bucket");
// Download file
const result = await sdk.downloadFile("my-bucket", "file.txt", "download");
if (result) {
const blob = new Blob([result]);
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = "file.txt";
a.click();
URL.revokeObjectURL(url);
}
}git clone [email protected]:lightshiftdev/akave-rs.git
cd akave-rscargo buildwasm-pack build --target web
wasm-bindgen target/wasm32-unknown-unknown/release/akave_rs.wasm \
--out-dir ./pkg \
--target webcreate_bucket(name: &str) -> Result<BucketResponse>- Creates a new bucket with the specified name.delete_bucket(name: &str) -> Result<()>- Deletes the specified bucket.list_buckets(&mut self) -> Result<BucketListResponse>- Lists all buckets for the current user.view_bucket(name: &str) -> Result<BucketViewResponse>- Retrieves details of the specified bucket.
upload_file<R: Read>(bucket_name: &str, file_name: &str, file: R, password: Option<&str>) -> Result<TransactionReceipt>- Uploads a file to the specified bucket with optional encryption.download_file<W: Write>(bucket_name: &str, file_name: &str, writer: W, password: Option<&str>) -> Result<()>- Downloads the specified file from the bucket to the given writer with optional decryption.list_files(bucket_name: &str) -> Result<FileListResponse>- Lists all files within the specified bucket.delete_file(bucket_name: &str, file_name: &str) -> Result<()>- Deletes the specified file from the given bucket.
build() -> Promise<AkaveWebSDK>- Builds the SDK with the configured options.new_with_endpoint(endpoint: string) -> Promise<AkaveWebSDK>- Creates an SDK instance with a custom endpoint.
The native SDK can be configured with:
- Server endpoint
- Poll interval for transaction confirmation
- Number of confirmations required
- Private key for signing transactions
The WASM SDK requires:
- MetaMask or compatible Web3 wallet
- Server endpoint
- Browser with WebAssembly support
Additional configuration options via the builder pattern:
withErasureCoding(dataBlocks, parityBlocks)- Configure erasure coding parameterswithDefaultEncryption(key)- Set default encryption keywithBlockSize(size)- Set block sizewithMinBucketLength(length)- Set minimum bucket name lengthwithMaxBlocksInChunk(blocks)- Set maximum blocks in chunkwithBlockPartSize(size)- Set block part size
The SDK provides comprehensive error handling for both platforms:
- Network errors
- Transaction failures
- File operation errors
- Wallet connection issues
- Invalid input validation
- File encryption support with password protection
- Secure wallet integration
- TLS encryption for all network communications
- Transaction signing and verification
Contributions are welcome!
Thanks to the Lightshift team for their contributions to the SDK: @CondeGil, @essamhassan, @krzysztof-ls. 👏