Skip to main content

Python SDK for IOTA Rebased

Project description

pyiota

CI

Python SDK for IOTA Rebased -- the Move-based Layer 1 blockchain.

pyiota provides a developer-friendly Python interface for interacting with IOTA Rebased nodes via JSON-RPC. It supports client-side transaction building with BCS serialization, Ed25519 signing, and typed responses.

Status: Alpha (v0.1.0) -- API may change before 1.0.

Features

  • Async-first client with sync wrapper (powered by httpx)
  • Client-side Programmable Transaction Block building with BCS serialization
  • Ed25519 keypair generation, import, and transaction signing
  • Typed responses using Pydantic v2 models
  • Coin, object, balance, and event queries
  • Testnet faucet integration
  • API aligned with the IOTA TypeScript SDK conventions

Installation

pip install pyiota

Optional extras:

pip install pyiota[secp256k1]   # Secp256k1 signing support
pip install pyiota[mnemonic]    # BIP-39 mnemonic key derivation

Requires Python 3.12+.

Quick Start

import asyncio
from pyiota import IotaClient, Network, Transaction, NANOS_PER_IOTA
from pyiota.crypto import Ed25519Keypair

async def main():
    sender = Ed25519Keypair.generate()
    recipient = Ed25519Keypair.generate()

    async with IotaClient(Network.TESTNET) as client:
        # Fund the sender from the testnet faucet
        await client.request_testnet_tokens(sender.address)
        await asyncio.sleep(3)

        # Check balance
        balance = await client.get_balance(owner=sender.address)
        print(f"Balance: {balance.total_balance_int / NANOS_PER_IOTA} IOTA")

        # Transfer 0.1 IOTA
        tx = Transaction()
        coin = tx.split_coins(tx.gas, [NANOS_PER_IOTA // 10])
        tx.transfer_objects([coin], recipient.address)

        tx_bytes = await tx.build(client=client, signer=sender)
        result = await client.sign_and_execute_transaction(
            signer=sender, tx_bytes=tx_bytes
        )
        print(f"Transaction: {result.digest}")

asyncio.run(main())

Sync Usage

from pyiota import SyncIotaClient, Network, Transaction
from pyiota.crypto import Ed25519Keypair

keypair = Ed25519Keypair.generate()

with SyncIotaClient(Network.TESTNET) as client:
    balance = client.get_balance(owner=keypair.address)
    print(f"Balance: {balance.total_balance_int}")

Move Call

tx = Transaction()
tx.move_call(
    target="0xPACKAGE::module::function",
    arguments=[tx.pure_string("hello"), tx.object("0xOBJECT_ID")],
    type_arguments=["0x2::coin::Coin<0x2::iota::IOTA>"],
)

API Reference

Client Methods

Method Description
get_balance(owner, coin_type?) Get coin balance for an address
get_all_balances(owner) Get all coin type balances
get_coins(owner, coin_type?, cursor?, limit?) Get coin objects (paginated)
get_object(object_id, show_*?) Get an object by ID
get_owned_objects(owner, ...) Get objects owned by address
multi_get_objects(object_ids, ...) Batch get objects
execute_transaction_block(tx_bytes, signatures, ...) Submit signed transaction
sign_and_execute_transaction(signer, tx_bytes, ...) Sign and submit
dev_inspect_transaction_block(sender, tx_bytes) Dry-run (no gas)
dry_run_transaction_block(tx_bytes) Dry-run (with gas estimation)
query_events(query, ...) Query emitted events
wait_for_transaction(digest, ...) Poll until indexed
get_reference_gas_price() Current gas price
get_chain_identifier() Chain genesis digest
request_testnet_tokens(recipient) Faucet (test networks only)

Transaction Builder

Method Description
tx.split_coins(coin, amounts) Split a coin into new coins
tx.transfer_objects(objects, recipient) Transfer objects to address
tx.merge_coins(destination, sources) Merge coins together
tx.move_call(target, arguments?, type_arguments?) Call a Move function
tx.pure(value, type_hint?) Create a pure input value
tx.object(object_id, ...) Create an object reference input
tx.build(client, signer?) Build to BCS bytes (async)
tx.build_sync(client, signer?) Build to BCS bytes (sync)

Development

git clone https://github.com/Consensix-Labs/pyiota.git
cd pyiota
pip install -e ".[dev]"

# Run unit tests
pytest tests/unit/

# Run integration tests (requires network)
pytest tests/integration/ -m integration

# Lint and format
ruff check src/ tests/
ruff format src/ tests/

# Type check
mypy src/pyiota/

Docker

# Unit tests
docker compose run --rm test-unit

# Integration tests (hits IOTA testnet)
docker compose run --rm test-integration

License

MIT -- see LICENSE.

Links

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

iota_rebased-0.1.0.tar.gz (42.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

iota_rebased-0.1.0-py3-none-any.whl (33.9 kB view details)

Uploaded Python 3

File details

Details for the file iota_rebased-0.1.0.tar.gz.

File metadata

  • Download URL: iota_rebased-0.1.0.tar.gz
  • Upload date:
  • Size: 42.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for iota_rebased-0.1.0.tar.gz
Algorithm Hash digest
SHA256 e61e0d870d92120a621bfd29e6bd95dc500136972efd84d35e3350746882a979
MD5 dbe59448d086f7b3699fb140c60c9e58
BLAKE2b-256 7008f5a4d1474c43a9e1ed1bc07e5074d57a0f3b402ac95e02d0a745da51882b

See more details on using hashes here.

Provenance

The following attestation bundles were made for iota_rebased-0.1.0.tar.gz:

Publisher: release.yml on Consensix-Labs/pyiota

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file iota_rebased-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: iota_rebased-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 33.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for iota_rebased-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 dbff1a730afa7649c791e1f866e0affd3e343ef34cf8eb1a11e6ba39d5b1963f
MD5 70c80d97b3666e31e83141f071705b2e
BLAKE2b-256 5da10405a3bd9894cc2754903db95b8bea758350bfba7d57ee0dd22d34b36774

See more details on using hashes here.

Provenance

The following attestation bundles were made for iota_rebased-0.1.0-py3-none-any.whl:

Publisher: release.yml on Consensix-Labs/pyiota

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page