bundler crate is Rust SDK to interact with Arweave (ANS-104) bundling services. This crate is designed to be backward compatible with existing legacy bundlers. for HyperBEAM bundlers, check this example.
[dependencies]
# main library
bundles_rs = { git = "https://github.com/permaweb/bundles-rs", branch = "main" }
# bundler only
bundler = { git = "https://github.com/permaweb/bundles-rs", branch = "main" }use bundles_rs::bundler::BundlerClient;
use bundles_rs::ans104::{data_item::DataItem, tags::Tag};
use bundles_rs::crypto::arweave::ArweaveSigner;let client = BundlerClient::default().build().unwrap();
let signer = ArweaveSigner::random().unwrap();
let tags = vec![Tag::new("content-type", "text/plain")];
let dataitem = DataItem::build_and_sign(&signer, None, None, tags, b"hello world".to_vec()).unwrap();
let tx = client.send_transaction(dataitem).await.unwrap();
println!("tx: {:?}", tx);BundlerClient::hyperbeam() auto-selects an active HyperBEAM uploader from the
PermawebOS bundlers network when no uploader URL is set. It filters unusable entries and checks that the selected
node has spendable AR before upload.
let signer = ArweaveSigner::from_jwk_file("wallet.json").unwrap();
let tags = vec![Tag::new("Content-Type", "text/plain")];
let dataitem = DataItem::build_and_sign(
&signer,
None,
None,
tags,
b"hello world hyperbeam".to_vec(),
)
.unwrap();
let client = BundlerClient::hyperbeam()
.auto_fund(signer)
.build()
.unwrap();
let tx = client.send_transaction(dataitem).await.unwrap();
println!("tx: {:?}", tx);To force a specific HyperBEAM uploader instead of auto-selection, set .url(...):
let client = BundlerClient::hyperbeam()
.url("https://lapee.hyperzine.xyz")
.build()
.unwrap();let client = BundlerClient::turbo().build().unwrap();
let signer = SolanaSigner::random();
let tags = vec![Tag::new("content-type", "text/plain")];
let dataitem = DataItem::build_and_sign(&signer, None, None, tags, b"hello world turbo".to_vec()).unwrap();
let tx = client.send_transaction(dataitem).await.unwrap();
println!("tx: {:?}", tx);let client = BundlerClient::turbo().build().unwrap();
let info = client.info().await.unwrap();
println!("{:?}", info);let client = BundlerClient::turbo().build().unwrap();
let price = client.bytes_price(99999).await.unwrap();
println!("{:?}", price);let client = BundlerClient::turbo().build().unwrap();
let rates = client.get_rates().await.unwrap();
println!("{:?}", rates);let client = BundlerClient::turbo().build().unwrap();
let status = client.status("w5n6r6PvqBRph2or4WiyjLumL9HE-IR_JgEcnct_3b0").await.unwrap();
println!("{:?}", status);- upload api: https://upload.ardrive.io/api-docs
- payment api: https://payment.ardrive.io/api-docs