Metadata-Version: 2.5
Name: aptos-sdk
Version: 0.12.2
Summary: Aptos SDK
Project-URL: Homepage, https://aptos.dev/en/build/sdks/python-sdk
Project-URL: Repository, https://github.com/aptos-labs/aptos-python-sdk
Author-email: Aptos Labs <opensource@aptoslabs.com>
License: # Innovation-Enabling Source Code License
        
        Copyright © Aptos Foundation
        Parts of the project are originally copyright © Meta Platforms, Inc.
        
        -----------------------------------------------------------------------------
        
        "Licensed Work" shall mean the work of authorship, whether in source code or
        object code form or otherwise, made available under this license, as
        indicated by a notice that is included in or attached to the work.
        
        Aptos Foundation (the "Licensor") hereby grants you the right to copy,
        modify, create derivative works, redistribute, and make non-production and
        non-commercial use of the Licensed Work solely for your internal purposes.
        Without limiting the generality of the foregoing, you may not use the
        Licensed Work (or any information therein) for the purpose of creating,
        publishing, deploying, launching or offering any blockchain or protocols
        (whether in mainnet, testnet, devnet, beta or alpha versions) outside of
        personal, non-production and non-commercial environments.
        
        Notwithstanding the foregoing, on the date that is 4 years after the date
        that the Licensor has publicly uploaded the specific code of the Licensed
        Work that you are using (the "Change Date"), the license herein shall
        automatically terminate and you shall have the right to then use the
        Licensed Work pursuant to the terms of the Apache 2.0 license.
        
        In addition, notwithstanding the foregoing, you may additionally use the
        software included in the repositories available at this link
        (https://docs.google.com/spreadsheets/d/1YXfK8bpXNbXUhRtH1hZAaZGdDPyM-ppoKuh6hoLC3Cs/edit?gid=0#gid=0)
        for production commercial uses (the "Additional Use Grant Software"), but
        solely to the extent if such uses are (i) for an application built
        exclusively on the Aptos protocol and (ii) not Competing Uses. "Competing
        Use" means any use of the Additional Use Grant Software in any product,
        protocol, application or service that is made available to third parties and
        that (i) (a) substitutes for use of Aptos protocol or (b) is related to the
        development of a layer 1 or layer 2 blockchain, (ii) offers similar
        functionality as the Aptos protocol or (iii) is built on or using a protocol
        other than Aptos protocol.
        
        All copies of the original and modified Licensed Work, and derivative works
        of the Licensed Work, are subject to this License. This License applies
        separately for each version of the Licensed Work and the Change Date may
        vary for each version of the Licensed Work released by Licensor.
        
        You must conspicuously display this License on each original or modified
        copy of the Licensed Work. If you receive the Licensed Work in original or
        modified form from a third party, the terms and conditions set forth in this
        License apply to your use of that work.
        
        Any use of the Licensed Work in violation of this License will automatically
        terminate your rights under this License for the current and all other
        versions of the Licensed Work. You may contact Aptos Foundation if you are
        interested in seeking a commercial license.
        
        This License does not grant you any right in any trademark or logo of
        Licensor or its affiliates (provided that you may use a trademark or logo of
        Licensor as expressly required by this License).
        
        TO THE EXTENT PERMITTED BY APPLICABLE LAW, THE LICENSED WORK IS PROVIDED ON
        AN "AS IS" BASIS. LICENSOR HEREBY DISCLAIMS ALL WARRANTIES AND CONDITIONS,
        EXPRESS OR IMPLIED, INCLUDING (WITHOUT LIMITATION) WARRANTIES OF
        MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, NON-INFRINGEMENT, AND
        TITLE. TO THE FULLEST EXTENT PERMITTED UNDER APPLICABLE LAW, LICENSOR SHALL
        NOT BE LIABLE TO YOU OR ANY OTHER PERSON FOR ANY LOST PROFITS, LOSS OF
        REVENUE OR BUSINESS, COST OF COVER OR ANY INCIDENTAL, SPECIAL OR
        CONSEQUENTIAL DAMAGES OF ANY KIND AND NATURE.
License-File: LICENSE
Keywords: aptos,blockchain,sdk,web3
Classifier: License :: Other/Proprietary License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12
Requires-Dist: aiohttp<4,>=3.14.3
Requires-Dist: bip-utils<3,>=2.9
Requires-Dist: cryptography<51,>=50.0.0
Requires-Dist: h11<0.17,>=0.16.0
Requires-Dist: h2<5,>=4.4.1
Requires-Dist: httpx[http2]<0.29,>=0.28.0
Requires-Dist: pynacl<2,>=1.6.2
Requires-Dist: python-graphql-client<0.5,>=0.4.3
Requires-Dist: requests<3,>=2.32.5
Requires-Dist: tomli<3,>=2.4.0
Requires-Dist: typing-extensions<5,>=4.15.0
Requires-Dist: urllib3<3,>=2.6.3
Provides-Extra: dev
Requires-Dist: behave<2,>=1.2.6; extra == 'dev'
Requires-Dist: coverage<8,>=7.6.12; extra == 'dev'
Requires-Dist: mypy-extensions<2,>=1.1.0; extra == 'dev'
Requires-Dist: mypy<2,>=1.16.0; extra == 'dev'
Requires-Dist: ruff==0.14.14; extra == 'dev'
Requires-Dist: types-six>=1.17.0.20250515; extra == 'dev'
Description-Content-Type: text/markdown

# Aptos Python SDK
[![Discord][discord-image]][discord-url]
[![PyPI Package Version][pypi-image-version]][pypi-url]
[![PyPI Package Downloads][pypi-image-downloads]][pypi-url]
[![codecov][codecov-image]][codecov-url]

The official Python SDK for interacting with the [Aptos](https://github.com/aptos-labs/aptos-core/) blockchain. Get started with the [integration guide](https://aptos.dev/guides/system-integrators-guide/#getting-started).

> **Note:** The sync client is deprecated. Please use the async client for all new projects.

## Installation

```bash
pip install aptos-sdk
```

## Quickstart

```python
import asyncio
from aptos_sdk.account import Account
from aptos_sdk.async_client import FaucetClient, RestClient

async def main():
    rest_client = RestClient("https://fullnode.devnet.aptoslabs.com/v1")
    faucet_client = FaucetClient("https://faucet.devnet.aptoslabs.com", rest_client)

    # Create and fund two accounts
    alice = Account.generate()
    bob = Account.generate()
    await faucet_client.fund_account(alice.address(), 100_000_000)
    await faucet_client.fund_account(bob.address(), 0)

    # Transfer 1_000 octas from Alice to Bob
    txn_hash = await rest_client.bcs_transfer(alice, bob.address(), 1_000)
    await rest_client.wait_for_transaction(txn_hash)

    print(f"Bob's balance: {await rest_client.account_balance(bob.address())}")
    await rest_client.close()

asyncio.run(main())
```

## API Overview

| Class | Description |
|-------|-------------|
| `RestClient` | Async client for the Aptos REST API (accounts, transactions, events, blocks). |
| `FaucetClient` | Funds accounts on devnet/testnet via the faucet service. |
| `Account` | Represents a keypair and address; supports Ed25519 and Secp256k1. |
| `AccountAddress` | 32-byte account address with AIP-40 compliant formatting. |
| `EntryFunction` | Constructs Move entry function payloads for submission. |
| `PackagePublisher` | Publishes and upgrades Move packages, with large-package chunking support. |

## Development

### Requirements
This SDK uses [uv](https://docs.astral.sh/uv/) for packaging and dependency management:

```bash
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync --extra dev
```

### Unit testing
```bash
make test
```

### Quick devnet smoke test

A single command that verifies node, faucet, transaction submission, simulation,
balance reads, and indexer (gracefully skipped on rate-limit) all work end-to-end:

```bash
make smoke           # uses public devnet by default
APTOS_NODE_URL=http://127.0.0.1:8080/v1 \
APTOS_FAUCET_URL=http://127.0.0.1:8081  \
make smoke           # against a local testnet
```

### Test coverage

```bash
make test-coverage
```

The legacy `aptos_sdk/` package targets ≥ 90 % unit-test coverage. The standalone
v2 package under `v2/` targets ≥ 95 %. Coverage from both is uploaded to
[Codecov][codecov-url] under the `v1-sdk` and `v2-sdk` flags respectively.

### E2E testing and Using the Aptos CLI

* Download and install the [Aptos CLI](https://aptos.dev/tools/aptos-cli/use-cli/running-a-local-network).
* Set the environment variable `APTOS_CLI_PATH` to the full path of the CLI.
* Retrieve the [Aptos Core Github Repo](https://github.com/aptos-labs/aptos-core) (git clone https://github.com/aptos-labs/aptos-core)
* Set the environment variable `APTOS_CORE_REPO` to the full path of the Repository.
* `make integration_test`

You can do this a bit more manually by:

First, run a local testnet (run this from the root of aptos-core):

```bash
aptos node run-local-testnet --force-restart --assume-yes --with-indexer-api
```

Next, tell the end-to-end tests to talk to this locally running testnet:

```bash
export APTOS_CORE_REPO="/path/to/repo"
export APTOS_FAUCET_URL="http://127.0.0.1:8081"
export APTOS_INDEXER_URL="http://127.0.0.1:8090/v1/graphql"
export APTOS_NODE_URL="http://127.0.0.1:8080/v1"
```

Finally run the tests:

```bash
make examples
```

Integration Testing Using the Aptos CLI:

```bash
make integration_test
```

> [!NOTE]
> The Python SDK does not require the Indexer, if you would prefer to test without it, unset or do not set the environmental variable `APTOS_INDEXER_URL` and exclude `--with-indexer-api` from running the aptos node software.

### Autoformatting
```bash
make fmt
```

### Autolinting
```bash
make lint
```

### Package Publishing

* Download the [Aptos CLI](https://aptos.dev/tools/aptos-cli/install-cli/).
* Set the environment variable `APTOS_CLI_PATH` to the full path of the CLI.
* `uv run python -m aptos_sdk.cli` and set the appropriate command-line parameters

## Semantic versioning
This project follows [semver](https://semver.org/) as closely as possible

[repo]: https://github.com/aptos-labs/aptos-core
[pypi-image-version]: https://img.shields.io/pypi/v/aptos-sdk.svg
[pypi-image-downloads]: https://img.shields.io/pypi/dm/aptos-sdk.svg
[pypi-url]: https://pypi.org/project/aptos-sdk
[discord-image]: https://img.shields.io/discord/945856774056083548?label=Discord&logo=discord&style=flat~~~~
[discord-url]: https://discord.gg/aptosnetwork
[codecov-image]: https://codecov.io/gh/aptos-labs/aptos-python-sdk/branch/main/graph/badge.svg
[codecov-url]: https://codecov.io/gh/aptos-labs/aptos-python-sdk
