Skip to content
Python SDK

Python SDK

The Python SDK is a typed Python 3.11+ package for Phantasma applications and automation. It covers JSON-RPC access, checked address and key handling, VM script building, VM script transaction signing, and Carbon wire-format transactions.

Package name:

pip install phantasma-sdk-py

Import namespace:

import phantasma_py

The current package exposes Python-style dataclasses, exceptions, type hints, and module names under phantasma_py. Older examples that import legacy modules do not apply to this SDK.

What It Covers

AreaModuleUse it for
RPCphantasma_py.rpcCalling Phantasma JSON-RPC endpoints and decoding typed result dataclasses.
Keys and addressesphantasma_py.cryptoWIF import/export, Ed25519 signatures, address parsing, hashes.
VM scriptsphantasma_py.vmBuilding scripts for contract calls, interop calls, gas, transfers, staking, and NFT calls.
VM transactionsphantasma_py.transactionSerializing, signing, mining, and checking VM script transactions.
Carbonphantasma_py.carbonCarbon serialization, schemas, token creation payloads, series payloads, NFT mint payloads, signed Carbon messages.

Carbon Workflows

Use the Carbon workflow pages when creating native assets:

Basic RPC Example

from phantasma_py.rpc import PhantasmaRPC

rpc = PhantasmaRPC.mainnet()
info = rpc.get_account_info("P...")
soul = rpc.get_token_balance("P...", "SOUL")

print(info.address, info.name)
print(soul.decimal_amount())

Read-only calls do not require a signing key. Broadcasting helpers require funded keys and an endpoint you explicitly intend to use.

Guides