githubEdit

Python SDK

Introduction

The supra-python-sdk provides a seamless interface for interacting with the Supra-L1 network. It offers comprehensive support for Move VM operations and transactions, enabling developers to both build on-chain and submit MoveVM-based transactions with ease.

Key Features

  • Complete Move VM Support - Full compatibility with Move VM operations

  • On-chain Data Queries - Efficient methods to query blockchain state

  • Transaction Management - Submit and manage transactions seamlessly

  • Cryptographic Operations - Built-in support for ED25519 and multi-signature operations

  • Token Operations - Native support for token creation and management

  • BCS Serialization - Efficient Binary Canonical Serialization support

For detailed API documentation of all modules, see the Official Python SDK Referencearrow-up-right and for some more reference examples, you can check official examples repo here.arrow-up-right


Installation

Install via pip:

python -m pip install supra-sdk

Verify installation:

import supra_sdk
print(supra_sdk.__version__)

Quick Start

Initialize the Client

Request Testnet Tokens

Submit Your First Transaction


API Reference - SupraClient

SupraClient is the main interface for interacting with the Supra blockchain.

Constructor

Parameters:

  • base_url: RPC endpoint URL

  • client_config: Optional configuration for the client

Example:

Core Methods

faucet(address: AccountAddress, wait_for_faucet: bool = True) -> Optional[str]

Request testnet tokens from the faucet.

Parameters:

  • address: Recipient address

  • wait_for_faucet: Whether to wait for transaction confirmation (default: True)

Returns: Transaction hash or None if failed

Example:

wait_for_faucet(tx_hash: str) -> None

Wait for faucet transaction to complete.

Parameters:

  • tx_hash: Faucet transaction hash

create_signed_transaction(sender: Account, payload: TransactionPayload) -> SignedTransaction

Create a signed transaction ready for submission.

Parameters:

  • sender: Account signing the transaction

  • payload: Transaction payload (EntryFunction, Script, etc.)

Returns: Signed transaction object

Example:

submit_signed_transaction(signed_transaction: SignedTransaction) -> str

Submit a signed transaction to the blockchain.

Parameters:

  • signed_transaction: Signed transaction object

Returns: Transaction hash


API Reference - Account

Account class manages cryptographic keys and signing operations.

Creating Accounts


API Reference - Token Clients

SupraTokenClient

High-level client for fungible token operations.

Constructor

Key Methods

create_collection(account: Account, name: str, description: str, uri: str) -> str

Create a new token collection.

Example:

create_token(account: Account, collection_name: str, name: str, description: str, supply: int, uri: str, royalty_points_numerator: int) -> str

Mint a new token in a collection.

Example:

offer_token(sender: Account, receiver: AccountAddress, creator: AccountAddress, collection_name: str, token_name: str, property_version: int, amount: int) -> str

Offer a token to another account.

claim_token(receiver: Account, sender: AccountAddress, creator: AccountAddress, collection_name: str, token_name: str, property_version: int) -> str

Claim an offered token.

get_token_balance(owner: AccountAddress, creator: AccountAddress, collection_name: str, token_name: str, property_version: int) -> int

Get token balance for an account.

get_collection(creator: AccountAddress, collection_name: str) -> dict

Get collection data.

get_token_data(creator: AccountAddress, collection_name: str, token_name: str) -> dict

Get token metadata.


API Reference - Transactions

Creating Transaction Payloads

EntryFunction

natural(module: str, function: str, ty_args: list[TypeTag], args: list[TransactionArgument]) -> EntryFunction (static)

Create an entry function with natural argument encoding.

Parameters:

  • module: Module identifier (e.g., "0x1::coin")

  • function: Function name

  • ty_args: Type arguments

  • args: Function arguments as TransactionArgument objects

TransactionArgument

Wraps an argument with its serializer function.

Common serializers from Serializer:

  • Serializer.u8, Serializer.u64, Serializer.u128, Serializer.u256

  • Serializer.bool

  • Serializer.struct (for addresses and complex types)

  • Serializer.str (for strings)


API Reference - Type System

TypeTag & StructTag

StructTag

from_str(type_tag: str) -> StructTag (static)

Parse a struct type from string representation.

Example:


API Reference - BCS Serialization

Binary Canonical Serialization (BCS) is the format used by Move VM.

Serializer

Deserializer

Common Serialization Methods

  • u8(value: int), u16(value: int), u32(value: int), u64(value: int)

  • u128(value: int), u256(value: int)

  • bool(value: bool)

  • str(value: str)

  • struct(value: Serializable)

  • sequence(values: list, encoder: Callable)


NFT Collection Example:

This example demonstrates how to create and manage an NFT collection using the Supra Python SDK.

circle-check

Last updated