Skip to main content

dweb

dweb ants tron

dweb → use the Autonomi network as a global datalake where you can just throw in data and retrieve it from anywhere.

Wrapper around autonomi-client to simplify fetching immutable public data with async and sync APIs, and to publish data using a convenient wallet flow driven by an Ethereum private key (SECRET_KEY).

  • Async: dweb.aio
  • Sync: dweb
  • Networks: from dweb import network → network.mainnet (default) or network.alpha

Install

poetry install --with test,notebooks

Usage

Sync (read)

from dweb import autonomi, network
content = autonomi.get("a7d2fdbb975efaea25b7ebe3d38be4a0b82c1d71e9b89ac4f37bc9f8677826e0", network=network.alpha)
with open("dogfile.jpg", "wb") as f:
    f.write(content)

Async (read)

import asyncio
from dweb.aio import autonomi
from dweb import network

async def main():
    data = await autonomi.get("a7d2fdbb975efaea25b7ebe3d38be4a0b82c1d71e9b89ac4f37bc9f8677826e0", network=network.mainnet)
    print(len(data))

asyncio.run(main())

Sync (write)

from dweb import autonomi, network

data = b"this is some test data"
cost, addr = autonomi.put(data, network=network.alpha)  # public by default
print(cost, addr)

# private upload (no datamap)
cost_private, _ = autonomi.put(data, network=network.alpha, private=True)

# set max fee per gas limit (wei). Default is 20_000_000 (0.02 gwei)
cost_capped, addr = autonomi.put(data, 10_000_000)
cost_capped_alpha, addr = autonomi.put(data, 10_000_000, network=network.alpha)

Async (write)

import asyncio
from dweb.aio import autonomi
from dweb import network

async def main():
    data = b"this is some test data"
    cost, addr = await autonomi.put(data, network=network.alpha)
    cost_capped, addr2 = await autonomi.put(data, 10_000_000, network=network.alpha)
    print(cost, addr)

asyncio.run(main())

Wallet & balances

Wallet initialization follows this hierarchy:

  1. If a .env in the current working directory defines SECRET_KEY (mainnet) and/or SECRET_KEY_ALPHA (alpha), those keys are used accordingly
  2. Else if the environment defines SECRET_KEY and/or SECRET_KEY_ALPHA, they are used
  3. Else you will be prompted via masked input to enter SECRET_KEY

You can also set the key programmatically (highest priority, overrides the above for both networks):

from dweb import autonomi
autonomi.set_secret_key("0xABCDEF...")

Check balances:

from dweb import autonomi, network

aut_balance = autonomi.balance  # AUTONOMI token (float)
eth_arb_balance = autonomi.gas  # ETH(Arb) (float)

# or explicitly per network / with timeout
aut_balance_alpha = autonomi.get_balance(network=network.alpha)
eth_arb_balance_alpha = autonomi.get_gas(network=network.alpha)

# wallet address (string)
addr = autonomi.wallet
addr_alpha = autonomi.get_wallet_address(network=network.alpha)

Notes:

  • Balances are normalized to human units by dividing raw on-chain values by 1e18
  • If either AUTONOMI or ETH(Arb) balance is zero, a warning is emitted; uploads may fail
  • Costs returned by put are floats (AUTONOMI), addresses are hex strings

Autocomplete:

  • The package ships with type stubs and a py.typed marker so that IDEs can offer completions for autonomi.balance, autonomi.gas, and autonomi.wallet. If completion doesn’t appear, reindex the project or ensure your environment uses the installed package (not an untyped copy).

Tests (Alpha network)

  • Provide .env with AUTONOMI_TEST_ADDRESS.
  • Run unit tests: poetry run pytest -m "not alpha"
  • Run alpha tests: poetry run pytest -m alpha

Reference: https://pypi.org/project/autonomi-client/

What is dweb (decentralized web)?

"dweb" is a small, ergonomic wrapper that lets your application interact with the decentralized Autonomi network as if it were a single, global data service. You can read from and (soon) write to globally addressable immutable data without running servers, without coordinating networks between participants, and without account-bound storage quotas or subscriptions. Producers and consumers of data do not need to be in the same local network or share infrastructure.

Key ideas:

  • Global addressing via deterministic content/data map addresses
  • Public, immutable data fetch with a single call (sync or async)
  • No app servers to manage for reads; the network serves the data
  • Writers and readers can be completely decoupled in time and space

How it works (high level)

flowchart LR
    A[Your App] -- sync/async --> B[dweb wrapper]
    B -- uses --> C[autonomi-client]
    C -- connects --> D{Autonomi Network}
    D -- mainnet/alpha --> E[(Immutable Data)]

    subgraph Notes
    N1[Data is addressed by its data map address (64-hex)]
    N2[Readers do not need to know writers or share infra]
    N3[No app server required for public reads]
    end
    B -. future .-> F[[Convenience writes]]
    F -. put helpers .-> D

With dweb, fetching public content by its data map address is one call. Think of it as pulling a blob from a global, decentralized datastore.

Concept: storing and retrieving data

  • Reading (available today): Provide a 64-hex data map address and the network (default mainnet). You receive raw bytes of the immutable object.
  • Writing (planned convenience): The wrapper will expose simple helpers to publish immutable data via the underlying autonomi-client so your app can store content without handling low-level details.

Properties:

  • Decentralized: No single server you own or operate for public reads
  • Global: Any participant can read the same address anywhere
  • Durable: Immutable data is content-addressed; readers get the exact bytes referenced

Note: Actual network policies and costs are determined by the Autonomi network and client library. The wrapper does not impose subscription fees or quotas itself.

Notebook display example

from IPython.display import Image, display
from dweb import autonomi, network

addr = "a7d2fdbb975efaea25b7ebe3d38be4a0b82c1d71e9b89ac4f37bc9f8677826e0"
content = autonomi.get(addr, network=network.alpha)
display(Image(data=content))

Metadata

Release files for dweb 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dweb 0.2.1
File Size Uploaded
dweb-0.2.1.tar.gz 10.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for dweb 0.2.1
File Interpreter ABI Platform
dweb-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 20.9 kB

Release files / dweb-0.2.1.tar.gz

Download URL dweb-0.2.1.tar.gz
Size 10.2 kB
Tags Source
SHA-256 checksum
How to use checksums
7e791461b586aaedeeb3fe609e1e0152ba53f2842bd70307ffbb36cd1beefa25
BLAKE2b-256 checksum
How to use checksums
6f2921258c7570613a0d8f33c59549ede4327961110e59bdfb1951482e2edf02
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.11.10 Darwin/24.6.0

Release files / dweb-0.2.1-py3-none-any.whl

Download URL dweb-0.2.1-py3-none-any.whl
Size 10.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6e3c02d340f27e0bf82239613eb24952d5484a0ca9fa89d475ee0f66b7304684
BLAKE2b-256 checksum
How to use checksums
7f7549687ab205a29326fb1f428edb851a290516ec14163bdb0150ceac8dff8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/2.1.3 CPython/3.11.10 Darwin/24.6.0

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page