Autonomi client API
Project description
Autonomi Python Bindings
The Autonomi client library provides Python bindings for easy integration with Python applications.
Installation
We recommend using uv for Python environment management:
Make sure you have installed:
Pythonuv
Quick Start
# make sure you are in the autonomi directory
cd autonomi/
# make a virtual environment
uv venv
source .venv/bin/activate
uv sync
maturin develop --uv
# Then you can test with pytest
pytest tests/python/test_bindings.py
# or you can run the examples or your own scripts!
python python/examples/autonomi_pointers.py
from autonomi_client import *
Client, Wallet, PaymentOption *
# Initialize a wallet with a private key
wallet = Wallet.new_from_private_key(Network(True),
"0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80")
print(f"Wallet address: {wallet.address()}")
print(f"Wallet balance: {await wallet.balance()}")
# Connect to the network
client = await Client.init()
# Create payment option using the wallet
payment = PaymentOption.wallet(wallet)
# Upload some data
data = b"Hello, Safe Network!"
[cost, addr] = await client.data_put_public(data, payment)
print(f"Data uploaded to address: {addr}")
# Download the data back
downloaded = await client.data_get_public(addr)
print(f"Downloaded data: {downloaded.decode()}")
API Reference
Client
The main interface to interact with the Autonomi network.
Connection Methods
connect(peers: List[str]) -> Client- Connect to network nodes
peers: List of multiaddresses for initial network nodes
Data Operations
-
data_put_public(data: bytes, payment: PaymentOption) -> str- Upload public data to the network
- Returns address where data is stored
-
data_get_public(addr: str) -> bytes- Download public data from the network
addr: Address returned fromdata_put_public
-
data_put(data: bytes, payment: PaymentOption) -> DataMapChunk- Store private (encrypted) data
- Returns access information for later retrieval
-
data_get(access: DataMapChunk) -> bytes- Retrieve private data
access: DataMapChunk from previousdata_put
Pointer Operations
-
pointer_get(address: str) -> Pointer- Retrieve pointer from network
address: Hex-encoded pointer address
-
pointer_put(pointer: Pointer, wallet: Wallet)- Store pointer on network
- Requires payment via wallet
-
pointer_cost(key: VaultSecretKey) -> str- Calculate pointer storage cost
- Returns cost in atto tokens
Scratchpad
Manage mutable encrypted data on the network.
Scratchpad Class
-
Scratchpad(owner: SecretKey, data_encoding: int, unencrypted_data: bytes, counter: int) -> Scratchpad- Create a new scratchpad instance
owner: Secret key for encrypting and signingdata_encoding: Custom value to identify data type (app-defined)unencrypted_data: Raw data to be encryptedcounter: Version counter for tracking updates
-
address() -> ScratchpadAddress- Get the address of the scratchpad
-
decrypt_data(sk: SecretKey) -> bytes- Decrypt the data using the given secret key
Client Methods for Scratchpad
-
scratchpad_get_from_public_key(public_key: PublicKey) -> Scratchpad- Retrieve a scratchpad using owner's public key
-
scratchpad_get(addr: ScratchpadAddress) -> Scratchpad- Retrieve a scratchpad by its address
-
scratchpad_check_existance(addr: ScratchpadAddress) -> bool- Check if a scratchpad exists on the network
-
scratchpad_put(scratchpad: Scratchpad, payment: PaymentOption) -> Tuple[str, ScratchpadAddress]- Store a scratchpad on the network
- Returns (cost, address)
scratchpad_create(owner: SecretKey, content_type: int, initial_data: bytes, payment: PaymentOption) -> Tuple[str, ScratchpadAddress]
-
Create a new scratchpad with a counter of 0
-
Returns (cost, address)
-
scratchpad_update(owner: SecretKey, content_type: int, data: bytes) -> None- Update an existing scratchpad
- Note: Counter is automatically incremented by 1 during update
- The scratchpad must exist before updating
-
scratchpad_cost(public_key: PublicKey) -> str- Calculate the cost to store a scratchpad
- Returns cost in atto tokens
Important Notes on Scratchpad Counter
- When creating a new scratchpad with
scratchpad_create, the counter starts at 0 - When updating with
scratchpad_update, the counter is automatically incremented - If you need to set a specific counter value, create a new Scratchpad instance and use
scratchpad_put - Only the scratchpad with the highest counter is kept on the network when there are conflicts
Vault Operations
-
vault_cost(key: VaultSecretKey) -> str- Calculate vault storage cost
-
write_bytes_to_vault(data: bytes, payment: PaymentOption, key: VaultSecretKey, content_type: int) -> str- Write data to vault
- Returns vault address
-
fetch_and_decrypt_vault(key: VaultSecretKey) -> Tuple[bytes, int]- Retrieve vault data
- Returns (data, content_type)
-
get_user_data_from_vault(key: VaultSecretKey) -> UserData- Get user data from vault
-
put_user_data_to_vault(key: VaultSecretKey, payment: PaymentOption, user_data: UserData) -> str- Store user data in vault
- Returns vault address
Wallet
Ethereum wallet management for payments.
-
new(private_key: str) -> Wallet- Create wallet from private key
private_key: 64-char hex string without '0x' prefix
-
address() -> str- Get wallet's Ethereum address
-
balance() -> str- Get wallet's token balance
-
balance_of_gas() -> str- Get wallet's gas balance
-
set_transaction_config(config: TransactionConfig)- Set the transaction config for the wallet (see
TransactionConfig)
- Set the transaction config for the wallet (see
TransactionConfig
Transaction configuration for wallets.
config = TransactionConfig(max_fee_per_gas=MaxFeePerGas.limited_auto(200000000))
MaxFeePerGas
Control the maximum fee per gas (gas price bid) for transactions:
-
MaxFeePerGas.auto(): Use current network gas price. No gas price limit. Use with caution.MaxFeePerGas.auto()
-
MaxFeePerGas.limited_auto(limit): Use current gas price with an upper limit. This is the recommended preset.# Limit to 0.2 gwei MaxFeePerGas.limited_auto(200000000)
-
MaxFeePerGas.unlimited(): No gas price limit. Use with caution.MaxFeePerGas.unlimited()
-
MaxFeePerGas.custom(wei_amount): Set exact gas price in wei.# Set to exactly 0.2 gwei MaxFeePerGas.custom(200000000)
PaymentOption
Configure payment methods.
wallet(wallet: Wallet) -> PaymentOption- Create payment option from wallet
Pointer
Handle network pointers for referencing data.
-
new(target: str) -> Pointer- Create new pointer
target: Hex-encoded target address
-
address() -> str- Get pointer's network address
-
target() -> str- Get pointer's target address
VaultSecretKey
Manage vault access keys.
-
new() -> VaultSecretKey- Generate new key
-
from_hex(hex: str) -> VaultSecretKey- Create from hex string
-
to_hex() -> str- Convert to hex string
UserData
Manage user data in vaults.
-
new() -> UserData- Create new user data
-
add_file_archive(archive: str) -> Optional[str]- Add file archive
- Returns archive ID if successful
-
add_private_file_archive(archive: str) -> Optional[str]- Add private archive
- Returns archive ID if successful
-
file_archives() -> List[Tuple[str, str]]- List archives as (id, address) pairs
-
private_file_archives() -> List[Tuple[str, str]]- List private archives as (id, address) pairs
DataMapChunk
Handle private data storage references.
-
from_hex(hex: str) -> DataMapChunk- Create from hex string
-
to_hex() -> str- Convert to hex string
-
address() -> str- Get short reference address
Utility Functions
encrypt(data: bytes) -> Tuple[bytes, List[bytes]]- Self-encrypt data
- Returns (data_map, chunks)
Examples
See the examples/ directory for complete examples:
autonomi_example.py: Basic data operationsautonomi_pointers.py: Working with pointersautonomi_vault.py: Vault operationsautonomi_private_data.py: Private data handlingautonomi_private_encryption.py: Data encryptionautonomi_scratchpad.py: Scratchpad creation and updates (with counter management)autonomi_advanced.py: Advanced usage scenarios
Best Practices
- Always handle wallet private keys securely
- Check operation costs before executing
- Use appropriate error handling
- Monitor wallet balance for payments
- Use appropriate content types for vault storage
- Consider using pointers for updatable references
- Properly manage and backup vault keys
For more examples and detailed usage, see the examples in the repository.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file autonomi_client-0.5.3-cp38-abi3-win_amd64.whl.
File metadata
- Download URL: autonomi_client-0.5.3-cp38-abi3-win_amd64.whl
- Upload date:
- Size: 7.6 MB
- Tags: CPython 3.8+, Windows x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e98a3e370bc20d52837b7cd5251389a885ae9c0f1ed2f84f7d1ae3007bc6bd26
|
|
| MD5 |
e5a8512c9e2eee83540925fa3184a01a
|
|
| BLAKE2b-256 |
0b04beb866371f7a699c9763fa99df462a53b1d310135364847b8ac592367b57
|
Provenance
The following attestation bundles were made for autonomi_client-0.5.3-cp38-abi3-win_amd64.whl:
Publisher:
python-publish-client.yml on dirvine/autonomi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autonomi_client-0.5.3-cp38-abi3-win_amd64.whl -
Subject digest:
e98a3e370bc20d52837b7cd5251389a885ae9c0f1ed2f84f7d1ae3007bc6bd26 - Sigstore transparency entry: 337818189
- Sigstore integration time:
-
Permalink:
dirvine/autonomi@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Branch / Tag:
refs/heads/stable - Owner: https://github.com/dirvine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish-client.yml@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_x86_64.whl.
File metadata
- Download URL: autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_x86_64.whl
- Upload date:
- Size: 9.3 MB
- Tags: CPython 3.8+, musllinux: musl 1.2+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a2528e66bba25179eecd3647d8d6c2bd32586a83be93d5509d220a131ae3d215
|
|
| MD5 |
806b9a22550b995cd585a236329c5202
|
|
| BLAKE2b-256 |
5d94909ce58834d9acd9a782b2150e0081367adba44fe99d570ea38c8babf3a2
|
Provenance
The following attestation bundles were made for autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_x86_64.whl:
Publisher:
python-publish-client.yml on dirvine/autonomi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_x86_64.whl -
Subject digest:
a2528e66bba25179eecd3647d8d6c2bd32586a83be93d5509d220a131ae3d215 - Sigstore transparency entry: 337818171
- Sigstore integration time:
-
Permalink:
dirvine/autonomi@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Branch / Tag:
refs/heads/stable - Owner: https://github.com/dirvine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish-client.yml@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_armv7l.whl.
File metadata
- Download URL: autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_armv7l.whl
- Upload date:
- Size: 9.0 MB
- Tags: CPython 3.8+, musllinux: musl 1.2+ ARMv7l
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
74b74cadb5171ae1682e984d242bd2ab41fca351116d976797d063deb5610dcf
|
|
| MD5 |
9378e37f2880316b05321c48d638f825
|
|
| BLAKE2b-256 |
b5dbec23a72af6d8cb39b282842441a4c5446256eca983e7ca250bfba0c784a5
|
Provenance
The following attestation bundles were made for autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_armv7l.whl:
Publisher:
python-publish-client.yml on dirvine/autonomi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_armv7l.whl -
Subject digest:
74b74cadb5171ae1682e984d242bd2ab41fca351116d976797d063deb5610dcf - Sigstore transparency entry: 337818132
- Sigstore integration time:
-
Permalink:
dirvine/autonomi@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Branch / Tag:
refs/heads/stable - Owner: https://github.com/dirvine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish-client.yml@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_aarch64.whl.
File metadata
- Download URL: autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_aarch64.whl
- Upload date:
- Size: 9.1 MB
- Tags: CPython 3.8+, musllinux: musl 1.2+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
14c096e419d28133237e9336e9f2c9b549da8372d8c31d078141bc2f3706e2c9
|
|
| MD5 |
34ade9821ec5b82af07f0684e4062318
|
|
| BLAKE2b-256 |
9463204761ccfc11b09156506a868d000f0492b0ec53659dc2a81da9ace55e3a
|
Provenance
The following attestation bundles were made for autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_aarch64.whl:
Publisher:
python-publish-client.yml on dirvine/autonomi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autonomi_client-0.5.3-cp38-abi3-musllinux_1_2_aarch64.whl -
Subject digest:
14c096e419d28133237e9336e9f2c9b549da8372d8c31d078141bc2f3706e2c9 - Sigstore transparency entry: 337818090
- Sigstore integration time:
-
Permalink:
dirvine/autonomi@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Branch / Tag:
refs/heads/stable - Owner: https://github.com/dirvine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish-client.yml@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file autonomi_client-0.5.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: autonomi_client-0.5.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 9.1 MB
- Tags: CPython 3.8+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bd93923ab4086f0640ced507556bbc07e3b201b85866f528c56aa932a4b73a3
|
|
| MD5 |
2adca147be34b2ff19f078d79c7a28b1
|
|
| BLAKE2b-256 |
dff93e5377688dc7acf7ca1c9ebb0d3e14b8cf796f4b10b2c7fe8c1a0e17ee4e
|
Provenance
The following attestation bundles were made for autonomi_client-0.5.3-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl:
Publisher:
python-publish-client.yml on dirvine/autonomi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autonomi_client-0.5.3-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl -
Subject digest:
4bd93923ab4086f0640ced507556bbc07e3b201b85866f528c56aa932a4b73a3 - Sigstore transparency entry: 337818154
- Sigstore integration time:
-
Permalink:
dirvine/autonomi@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Branch / Tag:
refs/heads/stable - Owner: https://github.com/dirvine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish-client.yml@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file autonomi_client-0.5.3-cp38-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: autonomi_client-0.5.3-cp38-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 8.0 MB
- Tags: CPython 3.8+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c628c971e3a38d8c63be194a47551cd7bcea69499e988b59ee430346a3780af0
|
|
| MD5 |
a273d5e07980452bbe4b773fcbfa93c2
|
|
| BLAKE2b-256 |
f9c1b728c02819467c261f0cd9702f3daa9271dc53d2e11c6b39d0f4e661b6f5
|
Provenance
The following attestation bundles were made for autonomi_client-0.5.3-cp38-abi3-macosx_11_0_arm64.whl:
Publisher:
python-publish-client.yml on dirvine/autonomi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autonomi_client-0.5.3-cp38-abi3-macosx_11_0_arm64.whl -
Subject digest:
c628c971e3a38d8c63be194a47551cd7bcea69499e988b59ee430346a3780af0 - Sigstore transparency entry: 337818103
- Sigstore integration time:
-
Permalink:
dirvine/autonomi@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Branch / Tag:
refs/heads/stable - Owner: https://github.com/dirvine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish-client.yml@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file autonomi_client-0.5.3-cp38-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: autonomi_client-0.5.3-cp38-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 8.2 MB
- Tags: CPython 3.8+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5535584f62afaf25d2edd63b6d1a972a15e0e468e430f46c3961a0da3798ec07
|
|
| MD5 |
9e452fe0deec4788861e0c8ad5edb6a0
|
|
| BLAKE2b-256 |
18b8b0c8f8b5627ec47b3a51f31143d7afcd6d12e2a8b4efdc96b0ef4caf052d
|
Provenance
The following attestation bundles were made for autonomi_client-0.5.3-cp38-abi3-macosx_10_12_x86_64.whl:
Publisher:
python-publish-client.yml on dirvine/autonomi
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
autonomi_client-0.5.3-cp38-abi3-macosx_10_12_x86_64.whl -
Subject digest:
5535584f62afaf25d2edd63b6d1a972a15e0e468e430f46c3961a0da3798ec07 - Sigstore transparency entry: 337818123
- Sigstore integration time:
-
Permalink:
dirvine/autonomi@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Branch / Tag:
refs/heads/stable - Owner: https://github.com/dirvine
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish-client.yml@09b99476e611abc3c16f681c1fe47dc98ad82f0e -
Trigger Event:
workflow_dispatch
-
Statement type: