Autonomi
LearnBuildWho we ArePublicationsGet ANTStart a Node
  • Learn
  • Node
  • ANT Token
  • Developers
  • Developer Documentation
  • Getting Started
    • Installation Guide
  • Core Concepts
    • Data Types
    • Data Storage
    • BLS Keys
  • How To Guides
    • Quick Start Guide
    • Local Network Setup Guide
    • Payments Guide
    • Build Apps with Python
    • Build Apps with Rust
  • API Reference
    • API Reference Overview
    • Client API
      • Chunks
      • GraphEntry
      • Pointer
      • Register
      • Scratchpad
      • BLS Keys
      • Analyze
    • Node API
    • BLS Threshold Crypto
    • Self Encryption
    • Rust Crate API Reference
    • Python API Reference
Powered by GitBook

Get Involved

  • Start a Node
  • Discord
  • Forum

Follow Us

  • X
  • Reddit
  • LinkedIn
On this page
  • My first App
  • Add Autonomi as a Dependency
  • Setup a Client
  • Download a Dog Picture
Export as PDF
  1. How To Guides

Quick Start Guide

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

# Tokio is used for the async runtime, but other ones can be used as well.
cargo add tokio
# uv is used to create the virtual environment, but other ones can be used as well.
uv venv

uv pip install autonomi-client
npm install @withautonomi/autonomi

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");
}
from autonomi_client import Client
import asyncio

async def main():
    client = await Client.init()

asyncio.run(main())
import { Client } from '@withautonomi/autonomi'

const client = await Client.init()

Download a Dog Picture

What better way is there to show off the capabilities of the network? Let's download a dog picture from this public data address:

a7d2fdbb975efaea25b7ebe3d38be4a0b82c1d71e9b89ac4f37bc9f8677826e0
use autonomi::data::DataAddress;
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 =
        DataAddress::from_hex("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, DataAddress
import asyncio

async def main():
    client = await Client.init()
    
    # Data address of the dog picture
    data_address = DataAddress.from_hex("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())
import { Client, DataAddress } from '@withautonomi/autonomi'
import fs from 'node:fs/promises'

const client = await Client.init()
// Data address of the dog picture
const dataAddress = DataAddress.fromHex("a7d2fdbb975efaea25b7ebe3d38be4a0b82c1d71e9b89ac4f37bc9f8677826e0")
// Get the bytes of the dog picture
const dogPicture = await client.dataGetPublic(dataAddress)

// Write the bytes of the dog picture to a file
await fs.writeFile('lucky.jpg', dogPicture);

After running this code, you'll see a lucky.jpg file downloaded to your work directory!

PreviousBLS KeysNextLocal Network Setup Guide

Last updated 28 days ago