pub struct ArWallet { /* private fields */ }Expand description
The main struct that contains your Arweave wallet, and its methods and fuctions will cover most features of Arweave.
Implementations§
Source§impl ArWallet
impl ArWallet
Sourcepub fn new() -> Self
pub fn new() -> Self
Initiate a new Arweave wallet defautly. It generates a new wallet, and use the default https://arweave.net/ as gateway.
Sourcepub fn from_jwk(jwk_string: &str) -> Self
pub fn from_jwk(jwk_string: &str) -> Self
Initiate a new Arweave wallet by importing a jwk file. It generates a new wallet, and use the default https://arweave.net/ as gateway.
Sourcepub fn generate_key_from_key_data(kd: IndexMap<String, Value>) -> Rsa<Private>
pub fn generate_key_from_key_data(kd: IndexMap<String, Value>) -> Rsa<Private>
Convert an already deserialized jwk data to the type
Rsa<Private>.
Sourcepub fn import_jwk(&mut self, jwk_str: &str)
pub fn import_jwk(&mut self, jwk_str: &str)
Import a jwk. Running this method will instantly replace the original key from the wallet. Should consider export and have a backup of your original key before doing it. Otherwise, you may permanently lose your key and all the AR crypto you have.
Sourcepub fn export_jwk(&self) -> String
pub fn export_jwk(&self) -> String
Export the wallet as jwk format, return as a Rust String type. This is how we backup and save our Arweave wallet to somewhere else. You can later send this String to a server or save it as a local json file.
Sourcepub fn set_gateway(&mut self, address: &str)
pub fn set_gateway(&mut self, address: &str)
Change Arweave gateway. The format should look like
https://arweave.net/.
Sourcepub fn http_client(&self) -> &Client
pub fn http_client(&self) -> &Client
Get the current http client.
Sourcepub fn private_key(&self) -> Rsa<Private>
pub fn private_key(&self) -> Rsa<Private>
Get the current private key. do not share this key to
other. This method is more or less for internal use. For
personal key backup, you probably want to try export_jwk().
Sourcepub async fn balance(&self) -> Result<String, Box<dyn Error>>
pub async fn balance(&self) -> Result<String, Box<dyn Error>>
Check your AR crypto balance in your wallet.The HTTP API will return all amounts as Winston strings. Winston is the smallest possible unit of AR. 1 AR = 1000000000000 Winston (12 zeros) and 1 Winston = 0.000000000001 AR.
Sourcepub async fn last_tx(&self) -> Result<String, Box<dyn Error>>
pub async fn last_tx(&self) -> Result<String, Box<dyn Error>>
Get the last transaction id of this wallet.
pub async fn tx_anchor(&self) -> Result<String, Box<dyn Error>>
Sourcepub async fn ar_transaction_price(
&self,
target: &str,
) -> Result<String, Box<dyn Error>>
pub async fn ar_transaction_price( &self, target: &str, ) -> Result<String, Box<dyn Error>>
Get a price of an AR transfer transaction. The first argument is the address of the receiver. Return a Winston string.
Sourcepub async fn data_transaction_price(
&self,
size: usize,
) -> Result<String, Box<dyn Error>>
pub async fn data_transaction_price( &self, size: usize, ) -> Result<String, Box<dyn Error>>
Get a price of a data transaction. The first argument is the data size. Return a Winston string.
Sourcepub async fn ar_data_transaction_price(
&self,
target: &str,
size: usize,
) -> Result<String, Box<dyn Error>>
pub async fn ar_data_transaction_price( &self, target: &str, size: usize, ) -> Result<String, Box<dyn Error>>
Get a price of a combined AR transfer and data transaction. The first argument is the address of the receiver. The second argument is the data size. Return a Winston string.
Sourcepub async fn create_ar_transaction(
&self,
target: &str,
quantity_ar: f64,
) -> Transaction
pub async fn create_ar_transaction( &self, target: &str, quantity_ar: f64, ) -> Transaction
Create a new AR transfer transaction by using the current Arweave wallet.
Sourcepub async fn create_data_transaction(&mut self, raw_data: &[u8]) -> Transaction
pub async fn create_data_transaction(&mut self, raw_data: &[u8]) -> Transaction
Create a new Data transaction by using the current Arweave wallet.
Sourcepub async fn create_ar_data_transaction(
&mut self,
target: &str,
quantity_ar: f64,
raw_data: &[u8],
) -> Transaction
pub async fn create_ar_data_transaction( &mut self, target: &str, quantity_ar: f64, raw_data: &[u8], ) -> Transaction
Create a new combined Ar transfer **and ** Data transaction by using the current Arweave wallet.
Sourcepub fn uploader(&self) -> Uploader
pub fn uploader(&self) -> Uploader
Get the current resumable uploader. You will get an empty uploader and it will do nothing if you have not create a data transaction yet. However, you don’t have to create a data transaction if you just want to resume a previou uploading.
Sourcepub async fn upload(&mut self) -> Result<String, Box<dyn Error>>
pub async fn upload(&mut self) -> Result<String, Box<dyn Error>>
Upload a file. Make sure you create, sign, and submit a data transaction first before doing upload. You can also resume a previous upload, in such case, a data transaction is not needed.
Sourcepub async fn transaction_offset_size(
&self,
id: &str,
) -> Result<String, Box<dyn Error>>
pub async fn transaction_offset_size( &self, id: &str, ) -> Result<String, Box<dyn Error>>
Get a transaction offset and size. This method is useful for creating a resumable chunks downloader.
Sourcepub async fn chunk(&self, offset: &str) -> Result<String, Box<dyn Error>>
pub async fn chunk(&self, offset: &str) -> Result<String, Box<dyn Error>>
Get a single chunk of a file by inputting one of its offset. This method is useful for creating a resumable chunks downloader.
Sourcepub fn downloader(&self) -> &Downloader
pub fn downloader(&self) -> &Downloader
Get the reference of the downloader. You have to setup a new download or resume a previous download before it can do anything.