### Irys Client CLI Examples
Source: https://github.com/irys-xyz/rust-sdk/blob/master/README.md
Provides example commands for interacting with the Irys client CLI. These cover balance checks, price inquiries, funding, withdrawals, and uploads.
```bash
./cli balance
--host --token
```
```bash
./cli price --host --token
```
```bash
./cli fund --host --token --wallet
```
```bash
./cli withdraw --host --token --wallet
```
```bash
./cli upload --host --token --wallet
```
--------------------------------
### Install Node.js Dependencies for Bundle Generation
Source: https://github.com/irys-xyz/rust-sdk/blob/master/README.md
Installs the necessary Node.js packages for generating random bundles. This is a prerequisite for running tests.
```bash
npm install
```
--------------------------------
### Get Upload Cost with Irys SDK
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Calculates the cost in base units for uploading a specified number of bytes to the Irys network. Requires a URL, token type, HTTP client, and byte count.
```rust
use irys_sdk::{bundler::get_price, token::TokenType};
use reqwest::Url;
#[tokio::main]
async fn main() {
let url = Url::parse("https://uploader.irys.xyz").unwrap();
let token = TokenType::Solana;
let bytes_to_upload = 256000; // 256 KB
let client = reqwest::Client::new();
let result = get_price(&url, token, &client, bytes_to_upload).await;
match result {
Ok(price) => println!("Cost for {} bytes: {} lamports", bytes_to_upload, price),
Err(err) => println!("Error getting price: {}", err),
}
}
```
--------------------------------
### CLI - Command Line Interface
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
The SDK includes a CLI binary for common operations. Build it with the `build-binary` feature flag.
```APIDOC
## CLI Commands
### Description
Provides command-line tools for common Irys SDK operations. Build with the `build-binary` feature flag.
### Build Command
```bash
cargo build --release --features="build-binary"
```
### Commands
#### `balance`
##### Description
Checks the balance for a given address.
##### Usage
`./target/release/cli balance --host --token `
##### Parameters
- **address** (String) - Required - The wallet address to check.
- **--host** (String) - Required - The Irys host URL (e.g., `https://uploader.irys.xyz`).
- **--token** (String) - Required - The type of token (e.g., `solana`, `ethereum`).
#### `price`
##### Description
Checks the price for uploading a specified number of bytes.
##### Usage
`./target/release/cli price --host --token `
##### Parameters
- **bytes** (Integer) - Required - The number of bytes to check the price for.
- **--host** (String) - Required - The Irys host URL (e.g., `https://uploader.irys.xyz`).
- **--token** (String) - Required - The type of token (e.g., `solana`, `ethereum`).
```
--------------------------------
### SolanaBuilder - Solana Token Configuration
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Illustrates how to set up a Solana token using the `SolanaBuilder`. This requires providing a base58-encoded private key for signing transactions.
```APIDOC
## PUT /api/users/{id}
### Description
Updates the details of an existing user identified by their unique ID.
### Method
PUT
### Endpoint
/api/users/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the user to update.
#### Request Body
- **username** (string) - Optional - The new username for the user.
- **email** (string) - Optional - The new email address for the user.
### Request Example
```json
{
"email": "john.doe.updated@example.com"
}
```
### Response
#### Success Response (200)
- **id** (string) - The unique identifier for the updated user.
- **username** (string) - The updated username of the user.
- **email** (string) - The updated email address of the user.
#### Response Example
```json
{
"id": "user-12345",
"username": "johndoe",
"email": "john.doe.updated@example.com"
}
```
```
--------------------------------
### BundlerClientBuilder - Creating a Client Instance
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Demonstrates how to create an Irys bundler client using the `BundlerClientBuilder`. This involves configuring the bundler URL, specifying a token (e.g., Solana), and fetching public information from the bundler node.
```APIDOC
## POST /api/users
### Description
This endpoint allows for the creation of a new user in the system.
### Method
POST
### Endpoint
/api/users
### Parameters
#### Query Parameters
- **limit** (integer) - Optional - The maximum number of users to return.
#### Request Body
- **username** (string) - Required - The desired username for the new user.
- **email** (string) - Required - The email address of the new user.
### Request Example
```json
{
"username": "johndoe",
"email": "john.doe@example.com"
}
```
### Response
#### Success Response (201)
- **id** (string) - The unique identifier for the newly created user.
- **username** (string) - The username of the created user.
- **email** (string) - The email address of the created user.
#### Response Example
```json
{
"id": "user-12345",
"username": "johndoe",
"email": "john.doe@example.com"
}
```
```
--------------------------------
### Create Irys Bundler Client with Solana Token
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Use BundlerClientBuilder to configure the Irys bundler URL, create a Solana token with wallet credentials, and build the client. Requires fetching public info from the bundler node.
```rust
use irys_sdk::{BundlerClientBuilder, token::solana::SolanaBuilder};
use reqwest::Url;
#[tokio::main]
async fn main() -> Result<(), irys_sdk::error::BundlerError> {
// Configure the bundler URL
let url = Url::parse("https://uploader.irys.xyz").unwrap();
// Create a Solana token with wallet credentials
let token = SolanaBuilder::new()
.wallet("kNykCXNxgePDjFbDWjPNvXQRa8U12Ywc19dFVaQ7tebUj3m7H4sF4KKdJwM7yxxb3rqxchdjezX9Szh8bLcQAjb")
.build()
.expect("Could not create Solana instance");
// Build the client with token and fetch public info
let bundler_client = BundlerClientBuilder::new()
.url(url)
.token(token)
.fetch_pub_info()
.await?
.build()?;
println!("Bundler client created successfully");
Ok(())
}
```
--------------------------------
### Build and Use Irys CLI
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Build the Irys SDK CLI binary using the `build-binary` feature flag. The CLI supports common operations like checking balance and price for uploads.
```bash
# Build the CLI binary
cargo build --release --features="build-binary"
# Check balance for an address
./target/release/cli balance --host https://uploader.irys.xyz --token solana
# Check price for uploading bytes
./target/release/cli price 256000 --host https://uploader.irys.xyz --token solana
```
--------------------------------
### Build Irys Rust SDK Client
Source: https://github.com/irys-xyz/rust-sdk/blob/master/README.md
Build the client binary for the Irys Rust SDK. This command enables the 'build-binary' feature.
```bash
cargo build --release --features="build-binary"
```
--------------------------------
### Irys Client CLI Usage
Source: https://github.com/irys-xyz/rust-sdk/blob/master/README.md
Displays the available subcommands and options for the Irys client binary. Use this to understand the CLI's capabilities.
```bash
USAGE:
cli
OPTIONS:
-h, --help Print help information
SUBCOMMANDS:
balance Gets the specified user's balance for the current Irys bundler node
fund Funds your account with the specified amount of atomic units
help Print this message or the help of the given subcommand(s)
price Check how much of a specific token is required for an upload of
bytes
upload Uploads a specified file
upload-dir Uploads a folder (with a manifest)
withdraw Sends a fund withdrawal request
```
--------------------------------
### Configure Solana Token from Private Key
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Instantiate a Solana token using SolanaBuilder with a base58-encoded private key. This token is then ready for signing Solana-based transactions.
```rust
use irys_sdk::token::solana::SolanaBuilder;
fn main() {
// Create Solana token from base58 private key
let token = SolanaBuilder::new()
.wallet("kNykCXNxgePDjFbDWjPNvXQRa8U12Ywc19dFVaQ7tebUj3m7H4sF4KKdJwM7yxxb3rqxchdjezX9Szh8bLcQAjb")
.build()
.expect("Could not create Solana instance");
// Token is ready for signing transactions
println!("Solana token configured");
}
```
--------------------------------
### Manual Transaction Creation and Signing with Irys SDK
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Allows manual creation of transactions with custom data and tags, followed by separate signing and sending. Useful for more control over uploads. Requires URL, wallet path, and token configuration.
```rust
use irys_sdk::{
BundlerClientBuilder,
token::arweave::ArweaveBuilder,
tags::Tag,
error::BuilderError
};
use std::{path::PathBuf, str::FromStr};
use reqwest::Url;
#[tokio::main]
async fn main() -> Result<(), BuilderError> {
let url = Url::parse("https://uploader.irys.xyz").unwrap();
let wallet = PathBuf::from_str("path/to/wallet.json").expect("Invalid wallet path");
let token = ArweaveBuilder::new()
.keypair_path(wallet)
.build()
.expect("Could not create token instance");
let mut bundler_client = BundlerClientBuilder::new()
.url(url)
.token(token)
.fetch_pub_info()
.await?
.build()?;
// Create transaction with custom data and tags
let data = b"Hello, Irys!".to_vec();
let tags = vec![
Tag::new("Content-Type", "text/plain"),
Tag::new("App-Name", "MyApp"),
Tag::new("Version", "1.0"),
];
let mut tx = bundler_client.create_transaction(data, tags).unwrap();
// Sign the transaction
bundler_client.sign_transaction(&mut tx).await?;
// Send the signed transaction
let response = bundler_client.send_transaction(tx).await;
match response {
Ok(res) => println!("Transaction sent! ID: {}", res.id),
Err(err) => println!("Error: {}", err),
}
Ok(())
}
```
--------------------------------
### Run Irys Rust SDK Tests
Source: https://github.com/irys-xyz/rust-sdk/blob/master/README.md
Executes the test suite for the Irys Rust SDK. Ensure random bundles have been generated prior to running this command.
```bash
cargo test
```
--------------------------------
### Fund Account with Atomic Units
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Use this command to fund your Irys account with a specified amount of atomic units. Ensure you have a valid wallet file and specify the correct host and token type.
```bash
./target/release/cli fund 10000 --host https://uploader.irys.xyz --token arweave --wallet path/to/wallet.json
```
--------------------------------
### get_balance - Query Account Balance
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Explains how to use the `get_balance` function to retrieve an account's balance from an Irys bundler node. It requires the bundler URL, token type, and the address to query.
```APIDOC
## DELETE /api/users/{id}
### Description
Deletes a user from the system based on their unique identifier.
### Method
DELETE
### Endpoint
/api/users/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the user to delete.
### Response
#### Success Response (204)
No content is returned upon successful deletion.
#### Response Example
(No content)
```
--------------------------------
### ArweaveBuilder - Arweave Token Configuration
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Shows how to configure an Arweave token for use with the Irys SDK. This involves specifying the path to the Arweave wallet keypair file.
```APIDOC
## GET /api/users/{id}
### Description
Retrieves the details of a specific user based on their unique identifier.
### Method
GET
### Endpoint
/api/users/{id}
### Parameters
#### Path Parameters
- **id** (string) - Required - The unique identifier of the user to retrieve.
### Response
#### Success Response (200)
- **id** (string) - The unique identifier for the user.
- **username** (string) - The username of the user.
- **email** (string) - The email address of the user.
#### Response Example
```json
{
"id": "user-12345",
"username": "johndoe",
"email": "john.doe@example.com"
}
```
```
--------------------------------
### Generate Random Bundles
Source: https://github.com/irys-xyz/rust-sdk/blob/master/README.md
Executes the script to generate random bundles, which are stored in the 'res/gen_bundles' directory. This is required for testing.
```bash
npm run generate-bundles
```
--------------------------------
### Configure Arweave Token for Irys Client
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Utilize ArweaveBuilder to create an Arweave token instance from a keypair file. This token is then used to build the Irys BundlerClient, requiring the bundler URL and fetching public info.
```rust
use irys_sdk::{BundlerClientBuilder, token::arweave::ArweaveBuilder};
use reqwest::Url;
use std::{path::PathBuf, str::FromStr};
#[tokio::main]
async fn main() -> Result<(), irys_sdk::error::BuilderError> {
let url = Url::parse("https://uploader.irys.xyz").unwrap();
let wallet = PathBuf::from_str("path/to/wallet.json").expect("Invalid wallet path");
// Build Arweave token from keypair file
let token = ArweaveBuilder::new()
.keypair_path(wallet)
.build()
.expect("Could not create Arweave token instance");
let bundler_client = BundlerClientBuilder::new()
.url(url)
.token(token)
.fetch_pub_info()
.await?
.build()?;
println!("Arweave client ready");
Ok(())
}
```
--------------------------------
### Upload File to Irys with SDK
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
Uploads a file from the local filesystem to an Irys bundler node. Automatically detects and sets the Content-Type tag based on the file extension. Requires a URL, token configuration, and file path.
```rust
use irys_sdk::{BundlerClientBuilder, token::solana::SolanaBuilder, error::BundlerError};
use reqwest::Url;
use std::{path::PathBuf, str::FromStr};
#[tokio::main]
async fn main() -> Result<(), BundlerError> {
let url = Url::parse("https://uploader.irys.xyz").unwrap();
let token = SolanaBuilder::new()
.wallet("kNykCXNxgePDjFbDWjPNvXQRa8U12Ywc19dFVaQ7tebUj3m7H4sF4KKdJwM7yxxb3rqxchdjezX9Szh8bLcQAjb")
.build()
.expect("Could not create Solana instance");
let mut bundler_client = BundlerClientBuilder::new()
.url(url)
.token(token)
.fetch_pub_info()
.await?
.build()?;
let file = PathBuf::from_str("path/to/image.jpg").unwrap();
let result = bundler_client.upload_file(file).await;
match result {
Ok(response) => {
println!("Uploaded successfully!");
println!("Transaction ID: {}", response.id);
println!("URL: https://uploader.irys.xyz/{}", response.id);
println!("Timestamp: {}", response.timestamp);
println!("Block: {}", response.block);
}
Err(err) => println!("Upload failed: {}", err),
}
Ok(())
}
```
--------------------------------
### Verify File Bundle
Source: https://context7.com/irys-xyz/rust-sdk/llms.txt
The `verify_file_bundle` function validates all transaction signatures within a bundle file, supporting multiple signature types.
```APIDOC
## verify_file_bundle
### Description
Validates all transaction signatures within a bundle file, supporting multiple signature types including Ed25519, Secp256k1, and RSA4096.
### Method
POST (Implied by SDK function)
### Endpoint
/verify/bundle (Implied by SDK function)
### Parameters
#### Path Parameters
- **bundle_path** (String) - Required - The path to the bundle file to verify.
### Request Example
```rust
// Example usage within the SDK
let result = verify_file_bundle(bundle_path).await;
```
### Response
#### Success Response (200)
- **items** (Array