Crate safeapi

Source
Expand description

Alternative API to access Autonomi Network. Focusing on being as simple as possible and cover most common usecases.

use safeapi::{Network, Safe, XorNameBuilder};

// connect to mainnet
let mut safe = Safe::connect(Network::Mainnet, None, "INFO").await?;

// [...] read key_data from a file
let secret_key = Safe::decrypt(&key_data, "password")?;
safe.login(Some(secret_key))?;

let data_name = safe.upload(&[10, 11, 12]).await?;
let related_reg_name = XorNameBuilder::from(&data_name).with_str("related").build();

safe.reg_create(&[1, 2, 3], &related_reg_name).await?;

// if you store data_name somewhere, also related_reg_name could be recreated to read both data and Reg.

Structs§

EvmAddress
An Ethereum address, 20 bytes in length.
Multiaddr
Representation of a Multiaddr.
Safe
An alternative Autonomi API
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.
XorName
A 256-bit number, viewed as a point in XOR space.
XorNameBuilder
This can be used to easily generate XorNames by chaining text and bytes fragments to derive from a given XorName or a random one.

Enums§

Error
Network

Constants§

ROOT_SK

Type Aliases§

Result
U256