ArWallet

Struct ArWallet 

Source
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

Source

pub fn new() -> Self

Initiate a new Arweave wallet defautly. It generates a new wallet, and use the default https://arweave.net/ as gateway.

Source

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.

Source

pub fn generate_key_from_key_data(kd: IndexMap<String, Value>) -> Rsa<Private>

Convert an already deserialized jwk data to the type Rsa<Private>.

Source

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.

Source

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.

Source

pub fn ar_public(&self) -> &ArPublic

Get the reference of the arweave public client.

Source

pub fn gateway(&self) -> String

Get the current gateway.

Source

pub fn set_gateway(&mut self, address: &str)

Change Arweave gateway. The format should look like https://arweave.net/.

Source

pub fn http_client(&self) -> &Client

Get the current http client.

Source

pub fn address(&self) -> String

Return the Arweave address (id) of the wallet.

Source

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().

Source

pub fn owner(&self) -> String

Return the owner of the Arweave wallet.

Source

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.

Source

pub async fn last_tx(&self) -> Result<String, Box<dyn Error>>

Get the last transaction id of this wallet.

Source

pub async fn tx_anchor(&self) -> Result<String, Box<dyn Error>>

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn create_data_transaction(&mut self, raw_data: &[u8]) -> Transaction

Create a new Data transaction by using the current Arweave wallet.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

pub async fn new_download(&mut self, id: &str) -> Result<(), Box<dyn Error>>

Setup a new download by inputting a data transaction id. This can be anyone’s data transaction. It is not neccessary to belong the current wallet.

Source

pub async fn download(&mut self) -> Result<String, Box<dyn Error>>

Download the current chunk based on the information of the Downloader. You have to setup a new download or resume a previous download before it can actually download anything.

Trait Implementations§

Source§

impl Clone for ArWallet

Source§

fn clone(&self) -> ArWallet

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for ArWallet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more