This section will help you get started on your Autonomi adventure as quickly as possible. It will walk you through setting up your development environment and writing a simple Autonomi app.
My first App
Let's get right to it and build your first Autonomi app!
Add Autonomi as a Dependency
First import our Autonomi dependency using the language you love:
cargo add autonomi
pip install autonomi-client
Setup a Client
To connect to the Autonomi network, we'll need a `Client`:
use autonomi::Client;
#[tokio::main]
async fn main() {
let client = Client::init()
.await
.expect("Could not initialize the client");
}
use autonomi::client::address::str_to_addr;
use autonomi::Client;
#[tokio::main]
async fn main() {
let client = Client::init()
.await
.expect("Could not initialize the client");
// Data address of the dog picture
let data_address =
str_to_addr("a7d2fdbb975efaea25b7ebe3d38be4a0b82c1d71e9b89ac4f37bc9f8677826e0")
.expect("Invalid data address");
// Get the bytes of the dog picture
let bytes = client
.data_get_public(&data_address)
.await
.expect("Could not fetch data from the network");
// Write the bytes of the dog picture to a file
std::fs::write("lucky.jpg", bytes).expect("Failed to write the file");
}
from autonomi_client import Client
import asyncio
async def main():
client = await Client.init()
# Data address of the dog picture
data_address = "a7d2fdbb975efaea25b7ebe3d38be4a0b82c1d71e9b89ac4f37bc9f8677826e0"
# Get the bytes of the dog picture
dog_picture = await client.data_get_public(data_address)
# Write the bytes of the dog picture to a file
with open("lucky.jpg", "wb") as f:
f.write(dog_picture)
asyncio.run(main())
After running this code, you'll see a lucky.jpg file downloaded to your work directory!