Crate autonomi

Crate autonomi 

Source
Expand description

Connect to and build on the Autonomi network.

§Example

use autonomi::{Bytes, Client, Wallet};
use autonomi::client::payment::PaymentOption;

#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
    let client = Client::init().await?;

    // Default wallet of testnet.
    let key = "0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80";
    let wallet = Wallet::new_from_private_key(Default::default(), key)?;
    let payment = PaymentOption::Wallet(wallet);

    // Put and fetch data.
    let (cost, data_addr) = client.data_put_public(Bytes::from("Hello, World"), payment.clone()).await?;
    let _data_fetched = client.data_get_public(&data_addr).await?;

    // Put and fetch directory from local file system.
    let (cost, dir_addr) = client.dir_upload_public("files/to/upload".into(), payment).await?;
    client.dir_download_public(&dir_addr, "files/downloaded".into()).await?;

    Ok(())
}

§Data types

This API gives access to the four fundamental types on the network: Chunk, Pointer, Scratchpad and GraphEntry.

When we upload data, it’s split into chunks using self-encryption, yielding a ‘datamap’ allowing us to reconstruct the data again. Any two people that upload the exact same data will get the same datamap, as all chunks are content-addressed and self-encryption is deterministic.

§Features

  • loud: Print debug information to stdout

Re-exports§

pub use client::data_types::chunk;
pub use client::data_types::graph;
pub use client::data_types::pointer;
pub use client::data_types::scratchpad;
pub use client::data;
pub use client::files;
pub use client::register;
pub use client::vault;
pub use bytes::Bytes;
pub use libp2p::Multiaddr;

Modules§

client
networking
self_encryption
version
Network versioning

Structs§

AttoTokens
An amount in SNT Atto. 10^18 Nanos = 1 SNT.
Bootstrap
Manages the flow of obtaining bootstrap peer addresses from various sources and also writes to the bootstrap cache.
BootstrapConfig
Configuration for Bootstrapping
Chunk
Chunk, an immutable chunk of data
ChunkAddress
Address of a crate::storage::chunks::Chunk.
Client
Represents a client for the Autonomi network.
ClientConfig
Configuration for the crate::Client which can be provided through: crate::Client::init_with_config.
ClientOperatingStrategy
Strategy configuration for data operations by the client.
GraphEntry
A generic GraphEntry on the Network.
GraphEntryAddress
Address of a crate::storage::graph::GraphEntry.
InitialPeersConfig
Configurations to fetch the initial peers which is used to bootstrap the network. This could optionally also be used as a command line argument struct.
Pointer
Pointer, a mutable address pointing to other data on the Network It is stored at the owner’s public key and can only be updated by the owner
PointerAddress
Address of a crate::storage::pointer::Pointer It is derived from the owner’s public key
PublicKey
A public key.
Scratchpad
Scratchpad, a mutable space for encrypted data on the Network
ScratchpadAddress
Address of a crate::storage::scratchpad::Scratchpad It is derived from the owner’s public key
SecretKey
A secret key; wraps a single prime field element. The field element is heap allocated to avoid any stack copying that result when passing SecretKeys between stack frames.
Signature
A signature.
TransactionConfig
Wallet
XorName
A 256-bit number, viewed as a point in XOR space.

Enums§

AddressParseError
BootstrapError
EvmUtilError
MaxFeePerGas
Network
PaymentMode
Payment strategy for uploads

Functions§

get_evm_network
Initialize the EVM Network.

Type Aliases§

Amount
QuoteHash
RewardsAddress