Aptos SDK
Project description
Aptos Python SDK
The official Python SDK for interacting with the Aptos blockchain. Get started with the integration guide.
Note: The sync client is deprecated. Please use the async client for all new projects.
Installation
pip install aptos-sdk
Quickstart
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 for packaging and dependency management:
curl -LsSf https://astral.sh/uv/install.sh | sh
uv sync --extra dev
Unit testing
make test
E2E testing and Using the Aptos CLI
- Download and install the Aptos CLI.
- Set the environment variable
APTOS_CLI_PATHto the full path of the CLI. - Retrieve the Aptos Core Github Repo (git clone https://github.com/aptos-labs/aptos-core)
- Set the environment variable
APTOS_CORE_REPOto 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):
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:
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:
make examples
Integration Testing Using the Aptos CLI:
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_URLand exclude--with-indexer-apifrom running the aptos node software.
Autoformatting
make fmt
Autolinting
make lint
Package Publishing
- Download the Aptos CLI.
- Set the environment variable
APTOS_CLI_PATHto the full path of the CLI. uv run python -m aptos_sdk.cliand set the appropriate command-line parameters
Semantic versioning
This project follows semver as closely as possible
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 Distribution
Built Distribution
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 aptos_sdk_fork-0.12.0a1.tar.gz.
File metadata
- Download URL: aptos_sdk_fork-0.12.0a1.tar.gz
- Upload date:
- Size: 74.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a6b8dc529831d6ba77237e4cefb471a36faba426473e59f8f91b1971f015c752
|
|
| MD5 |
57eaaa108d81a412bd8441af621544ff
|
|
| BLAKE2b-256 |
a7ca027a565d28fe85faa8c426bf9d680727c702a26d41d58cae97c7f34b7ac2
|
Provenance
The following attestation bundles were made for aptos_sdk_fork-0.12.0a1.tar.gz:
Publisher:
publish.yaml on Yolley/aptos-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aptos_sdk_fork-0.12.0a1.tar.gz -
Subject digest:
a6b8dc529831d6ba77237e4cefb471a36faba426473e59f8f91b1971f015c752 - Sigstore transparency entry: 1262680617
- Sigstore integration time:
-
Permalink:
Yolley/aptos-python-sdk@5de0c8cf3e1bbf1782aa7a93ebbd83b77d209959 -
Branch / Tag:
refs/tags/v0.12.0a1 - Owner: https://github.com/Yolley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@5de0c8cf3e1bbf1782aa7a93ebbd83b77d209959 -
Trigger Event:
push
-
Statement type:
File details
Details for the file aptos_sdk_fork-0.12.0a1-py3-none-any.whl.
File metadata
- Download URL: aptos_sdk_fork-0.12.0a1-py3-none-any.whl
- Upload date:
- Size: 100.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e18489f391415e9be23dc8ea0130fd56704e04b49381fcf5f3a00ef95ba3d2ac
|
|
| MD5 |
a417cfccbb911c5a0e8a9df3725cca23
|
|
| BLAKE2b-256 |
45da825adfd02ff7d504c52fb448674ca84da60fa8dc93737711e548cfb9f511
|
Provenance
The following attestation bundles were made for aptos_sdk_fork-0.12.0a1-py3-none-any.whl:
Publisher:
publish.yaml on Yolley/aptos-python-sdk
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
aptos_sdk_fork-0.12.0a1-py3-none-any.whl -
Subject digest:
e18489f391415e9be23dc8ea0130fd56704e04b49381fcf5f3a00ef95ba3d2ac - Sigstore transparency entry: 1262680645
- Sigstore integration time:
-
Permalink:
Yolley/aptos-python-sdk@5de0c8cf3e1bbf1782aa7a93ebbd83b77d209959 -
Branch / Tag:
refs/tags/v0.12.0a1 - Owner: https://github.com/Yolley
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yaml@5de0c8cf3e1bbf1782aa7a93ebbd83b77d209959 -
Trigger Event:
push
-
Statement type: