ARRS
====
Introduction
------------
ARRS is a Rust API implementation of the Arweave client. It can be
used to write command line, desktop, or web programs in Rust to use
most features of Arweave, including creating, importing, and exporting
wallets, checking balance, sending transactions, uploading files,
etc..
Arweave is a permanent storage network based on P2P and crypto. For
more information, please visit: <https://arweave.org/>
Example
-------
This program needs OpenSSL. It will download the newest official
release of the OpenSSL, and automatically compiles it. Therefore your
system needs to have a C compiler, Perl (and perl-core), and make
installed.
Then you need to add `tokio` and `arrs` into your Cargo.toml:
```
[dependencies]
arrs = {path = "../arrs"}
tokio = { version = "1.35.1", features = ["full"] }
```
### Print Wallet Address and AR Balance:
```
use arrs::wallet::ArWallet;
use tokio;
#[tokio::main]
async fn main() {
let arwallet = ArWallet::new();
let balance = arwallet.balance();
let address = arwallet.address();
println!("Your Arweave Wallet Address is: ");
println!("{}", address);
println!("Your AR balance is {}: ", balance.await.unwrap());
}
```
### Import a JSON Web Key (JWK)
```
use arrs::wallet::ArWallet;
use tokio;
use std::fs::read_to_string;
#[tokio::main]
async fn main() {
let jwk = read_to_string("./test.json").unwrap();
let arwallet = ArWallet::from_jwk(&jwk);
let balance = arwallet.balance();
let address = arwallet.address();
println!("Your Arweave Wallet Address is: ");
println!("{}", address);
println!("Your AR balance is {}: ", balance.await.unwrap());
}
```
### Create a data transaction; add tags; sign; verify; submit; upload file
```
use arrs::wallet::ArWallet;
use arrs::uploader::Uploader;
use tokio;
use std::{
fs::{File, read_to_string},
io::Read
};
#[tokio::main]
async fn main() {
let jwk = read_to_string("./test.json").unwrap();
let ar = ArWallet::from_jwk(&jwk);
let mut data_file = File::open("./test_image.jpg").unwrap();
let mut raw_data = Vec::new();
data_file.read_to_end(&mut raw_data).unwrap();
let mut tx = ar.create_data_transaction(&raw_data).await;
tx.add_tag("Content-Type", "image/jpg");
tx.add_tag("Test Name 2", "Test Value 2");
tx.sign();
match tx.verify() {
Ok(ok) => println!("{}", ok),
Err(e) => println!("{:?}", e),
}
println!("{:?}", tx.submit().await);
let mut uploader = Uploader::new(&raw_data);
while uploader.current_idx() < uploader.chunk_size() {
println!("{}", uploader.upload(&ar, &raw_data).await.unwrap());
}
}
```
Copyright
---------
Copyright © 2024 IceGuye
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Lesser General Public License as
published by the Free Software Foundation, version 3 of the License.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this program. If not, see
<http://www.gnu.org/licenses/>