API

Account

class supra_sdk.account.Account(account_address, private_key)

Bases: object

Represents an account as well as the private, public key-pair for the Supra blockchain.

account_address: AccountAddress
address()

Returns the address associated with the given account

Return type:

AccountAddress

auth_key()

Returns the auth_key for the associated account

Return type:

str

static generate()
Return type:

Account

static load(path)
Return type:

Account

static load_key(key)
Return type:

Account

private_key: PrivateKey
public_key()

Returns the public key for the associated account

Return type:

PublicKey

sign(data)
Return type:

Signature

sign_simulated_transaction(transaction)
Return type:

AccountAuthenticator

sign_transaction(transaction)
Return type:

AccountAuthenticator

store(path)
class supra_sdk.account.RotationProofChallenge(sequence_number, originator, current_auth_key, new_public_key)

Bases: object

current_auth_key: AccountAddress
new_public_key: PublicKey
originator: AccountAddress
sequence_number: int
serialize(serializer)
type_info_account_address: AccountAddress = 0x1
type_info_module_name: str = 'account'
type_info_struct_name: str = 'RotationProofChallenge'

Account Address

class supra_sdk.account_address.AccountAddress(address)

Bases: object

LENGTH: int = 32
address: bytes
static deserialize(deserializer)
Return type:

AccountAddress

static for_guid_object(creator, creation_num)
Return type:

AccountAddress

static for_named_collection(creator, collection_name)
Return type:

AccountAddress

static for_named_object(creator, seed)
Return type:

AccountAddress

static for_named_token(creator, collection_name, token_name)
Return type:

AccountAddress

static for_resource_account(creator, seed)
Return type:

AccountAddress

static from_key(key)
Return type:

AccountAddress

static from_str(address)

NOTE: This function has strict parsing behavior. For relaxed behavior, please use from_string_relaxed function.

Creates an instance of AccountAddress from a hex string.

This function allows only the strictest formats defined by AIP-40. In short this means only the following formats are accepted: - LONG - SHORT for special addresses

Where: - LONG is defined as 0x + 64 hex characters. - SHORT for special addresses is 0x0 to 0xf inclusive without padding zeroes.

This means the following are not accepted: - SHORT for non-special addresses. - Any address without a leading 0x.

Learn more about the different address formats by reading AIP-40: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.

Parameters:

(str) (- address)

Returns:

- AccountAddress

Return type:

An instance of AccountAddress.

static from_str_relaxed(address)

NOTE: This function has relaxed parsing behavior. For strict behavior, please use the from_string function. Where possible, use from_string rather than this function. from_string_relaxed is only provided for backwards compatibility.

Creates an instance of AccountAddress from a hex string.

This function allows all formats defined by AIP-40. In short, this means the following formats are accepted: - LONG, with or without leading 0x - SHORT, with or without leading 0x

Where: - LONG is 64 hex characters. - SHORT is 1 to 63 hex characters inclusive. - Padding zeroes are allowed, e.g., 0x0123 is valid.

Learn more about the different address formats by reading AIP-40: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md.

Parameters:

(str) (- address)

Returns:

- AccountAddress

Return type:

An instance of AccountAddress.

is_special()

Returns whether the address is a “special” address. Addresses are considered special if the first 63 characters of the hex string are zero. In other words, an address is special if the first 31 bytes are zero and the last byte is smaller than 0b10000 (16). In other words, special is defined as an address that matches the following regex: ^0x0{63}[0-9a-f]$. In short form this means the addresses in the range from 0x0 to 0xf (inclusive) are special.

For more details see the v1 address standard defined as part of AIP-40: https://github.com/aptos-foundation/AIPs/blob/main/aips/aip-40.md

serialize(serializer)
class supra_sdk.account_address.AuthKeyScheme

Bases: object

DeriveObjectAddressFromGuid: bytes = b'\xfd'
DeriveObjectAddressFromSeed: bytes = b'\xfe'
DeriveResourceAccountAddress: bytes = b'\xff'
Ed25519: bytes = b'\x00'
MultiEd25519: bytes = b'\x01'
MultiKey: bytes = b'\x03'
SingleKey: bytes = b'\x02'
exception supra_sdk.account_address.ParseAddressError

Bases: Exception

There was an error parsing an address.

Asymmetric Crypto

class supra_sdk.asymmetric_crypto.PrivateKey(*args, **kwargs)

Bases: Deserializable, Serializable, Protocol

hex()
Return type:

str

public_key()
Return type:

PublicKey

sign(data)
Return type:

Signature

class supra_sdk.asymmetric_crypto.PublicKey(*args, **kwargs)

Bases: Deserializable, Serializable, Protocol

to_crypto_bytes()

A long time ago, someone decided that we should have both bcs and a special representation for MultiEd25519, so we use this to let keys self-define a special encoding.

Return type:

bytes

verify(data, signature)
Return type:

bool

class supra_sdk.asymmetric_crypto.Signature(*args, **kwargs)

Bases: Deserializable, Serializable, Protocol

Asymmetric Crypto Wrapper

class supra_sdk.asymmetric_crypto_wrapper.MultiPublicKey(keys, threshold)

Bases: PublicKey

MAX_KEYS = 32
MIN_KEYS = 2
MIN_THRESHOLD = 1
static deserialize(deserializer)
Return type:

MultiPublicKey

static from_crypto_bytes(indata)
Return type:

MultiPublicKey

keys: list[PublicKey]
serialize(serializer)
threshold: int
to_crypto_bytes()

A long time ago, someone decided that we should have both bcs and a special representation for MultiEd25519, so we use this to let keys self-define a special encoding.

Return type:

bytes

verify(data, signature)
Return type:

bool

class supra_sdk.asymmetric_crypto_wrapper.MultiSignature(signatures)

Bases: Signature

BITMAP_NUM_OF_BYTES: int = 4
static deserialize(deserializer)
Return type:

MultiSignature

serialize(serializer)
signatures: list[tuple[int, Signature]]
unset_signatures()
class supra_sdk.asymmetric_crypto_wrapper.PublicKey(public_key)

Bases: PublicKey

ED25519: int = 0
static deserialize(deserializer)
Return type:

PublicKey

public_key: PublicKey
serialize(serializer)
to_crypto_bytes()

A long time ago, someone decided that we should have both bcs and a special representation for MultiEd25519, so we use this to let keys self-define a special encoding.

Return type:

bytes

variant: int
verify(data, signature)
Return type:

bool

class supra_sdk.asymmetric_crypto_wrapper.Signature(signature)

Bases: Signature

ED25519: int = 0
static deserialize(deserializer)
Return type:

Signature

get_null_signature()
Return type:

Signature

serialize(serializer)
signature: Signature
variant: int
supra_sdk.asymmetric_crypto_wrapper.index_to_bitmap_value(i)
Return type:

int

Authenticator

class supra_sdk.authenticator.AccountAuthenticator(authenticator)

Bases: object

ED25519: int = 0
MULTI_ED25519: int = 1
MULTI_KEY: int = 3
SINGLE_KEY: int = 2
authenticator: Any
static deserialize(deserializer)
Return type:

AccountAuthenticator

serialize(serializer)
unset_signature()
variant: int
verify(data)
Return type:

bool

class supra_sdk.authenticator.Authenticator(authenticator)

Bases: object

Each transaction submitted to the Supra blockchain contains a TransactionAuthenticator. During transaction execution, the executor will check if every AccountAuthenticator’s signature on the transaction hash is well-formed and whether AccountAuthenticator’s matches the AuthenticationKey stored under the participating signer’s account address.

ED25519: int = 0
FEE_PAYER: int = 3
MULTI_AGENT: int = 2
MULTI_ED25519: int = 1
SINGLE_SENDER: int = 4
authenticator: Any
static deserialize(deserializer)
Return type:

Authenticator

static from_key(key)
Return type:

int

serialize(serializer)
unset_signature()
variant: int
verify(data)
Return type:

bool

class supra_sdk.authenticator.Ed25519Authenticator(public_key, signature)

Bases: object

static deserialize(deserializer)
Return type:

Ed25519Authenticator

public_key: PublicKey
serialize(serializer)
signature: Signature
unset_signature()
verify(data)
Return type:

bool

class supra_sdk.authenticator.FeePayerAuthenticator(sender, secondary_signers, fee_payer)

Bases: object

static deserialize(deserializer)
Return type:

FeePayerAuthenticator

fee_payer: tuple[AccountAddress, AccountAuthenticator]
fee_payer_address()
Return type:

AccountAddress

secondary_addresses()
Return type:

list[AccountAddress]

secondary_signers: list[tuple[AccountAddress, AccountAuthenticator]]
sender: AccountAuthenticator
serialize(serializer)
unset_signature()
verify(data)
Return type:

bool

class supra_sdk.authenticator.MultiAgentAuthenticator(sender, secondary_signers)

Bases: object

static deserialize(deserializer)
Return type:

MultiAgentAuthenticator

secondary_addresses()
Return type:

list[AccountAddress]

secondary_signers: list[tuple[AccountAddress, AccountAuthenticator]]
sender: AccountAuthenticator
serialize(serializer)
unset_signature()
verify(data)
Return type:

bool

class supra_sdk.authenticator.MultiEd25519Authenticator(public_key, signature)

Bases: object

static deserialize(deserializer)
Return type:

MultiEd25519Authenticator

public_key: MultiPublicKey
serialize(serializer)
signature: MultiSignature
unset_signature()
verify(data)
Return type:

bool

class supra_sdk.authenticator.MultiKeyAuthenticator(public_key, signature)

Bases: object

static deserialize(deserializer)
Return type:

MultiKeyAuthenticator

public_key: MultiPublicKey
serialize(serializer)
signature: MultiSignature
unset_signature()
verify(data)
Return type:

bool

class supra_sdk.authenticator.SingleKeyAuthenticator(public_key, signature)

Bases: object

static deserialize(deserializer)
Return type:

SingleKeyAuthenticator

public_key: PublicKey
serialize(serializer)
signature: Signature
unset_signature()
verify(data)
Return type:

bool

class supra_sdk.authenticator.SingleSenderAuthenticator(sender)

Bases: object

static deserialize(deserializer)
Return type:

SingleSenderAuthenticator

sender: AccountAuthenticator
serialize(serializer)
unset_signature()
verify(data)
Return type:

bool

BCS

This is a simple BCS serializer and deserializer. Learn more at https://github.com/diem/bcs

class supra_sdk.bcs.Deserializable(*args, **kwargs)

Bases: Protocol

static deserialize(deserializer)
Return type:

Deserializable

classmethod from_bytes(indata)
Return type:

Deserializable

class supra_sdk.bcs.Deserializer(data)

Bases: object

bool()
Return type:

bool

fixed_bytes(length)
Return type:

bytes

map(key_decoder, value_decoder)
Return type:

dict[Any, Any]

remaining()
Return type:

int

sequence(value_decoder)
Return type:

list[Any]

str()
Return type:

str

struct(struct)
Return type:

Any

to_bytes()
Return type:

bytes

u128()
Return type:

int

u16()
Return type:

int

u256()
Return type:

int

u32()
Return type:

int

u64()
Return type:

int

u8()
Return type:

int

uleb128()
Return type:

int

class supra_sdk.bcs.Serializable(*args, **kwargs)

Bases: Protocol

serialize(serializer)
to_bytes()
Return type:

bytes

class supra_sdk.bcs.Serializer

Bases: object

bool(value)
fixed_bytes(value)
map(values, key_encoder, value_encoder)
output()
Return type:

bytes

sequence(values, value_encoder)
static sequence_serializer(value_encoder)
str(value)
struct(value)
to_bytes(value)
u128(value)
u16(value)
u256(value)
u32(value)
u64(value)
u8(value)
uleb128(value)
supra_sdk.bcs.encoder(value, encoder)
Return type:

bytes

ED25519

class supra_sdk.ed25519.MultiPublicKey(keys, threshold)

Bases: PublicKey

MAX_KEYS = 32
MIN_KEYS = 2
MIN_THRESHOLD = 1
static deserialize(deserializer)
Return type:

MultiPublicKey

static from_crypto_bytes(indata)
Return type:

MultiPublicKey

keys: list[PublicKey]
serialize(serializer)
threshold: int
to_crypto_bytes()

A long time ago, someone decided that we should have both bcs and a special representation for MultiEd25519, so we use this to let keys self-define a special encoding.

Return type:

bytes

verify(data, signature)
Return type:

bool

class supra_sdk.ed25519.MultiSignature(signatures)

Bases: Signature

BITMAP_NUM_OF_BYTES: int = 4
static deserialize(deserializer)
Return type:

MultiSignature

static from_key_map(public_key, signatures_map)
Return type:

MultiSignature

serialize(serializer)
signatures: list[tuple[int, Signature]]
unset_signatures()
class supra_sdk.ed25519.PrivateKey(key)

Bases: PrivateKey

LENGTH: int = 32
static deserialize(deserializer)
Return type:

PrivateKey

static from_str(value)
Return type:

PrivateKey

hex()
Return type:

str

key: SigningKey
public_key()
Return type:

PublicKey

static random()
Return type:

PrivateKey

serialize(serializer)
sign(data)
Return type:

Signature

class supra_sdk.ed25519.PublicKey(key)

Bases: PublicKey

LENGTH: int = 32
static deserialize(deserializer)
Return type:

PublicKey

key: VerifyKey
serialize(serializer)
to_crypto_bytes()

A long time ago, someone decided that we should have both bcs and a special representation for MultiEd25519, so we use this to let keys self-define a special encoding.

Return type:

bytes

verify(data, signature)
Return type:

bool

class supra_sdk.ed25519.Signature(signature)

Bases: Signature

LENGTH: int = 64
data()
Return type:

bytes

static deserialize(deserializer)
Return type:

Signature

static get_null_signature()
Return type:

Signature

serialize(serializer)
signature: bytes

Metadata

class supra_sdk.metadata.Metadata

Bases: object

Represents the metadata related to the SDK sent to the rpc_node in header during API call.

The main objective of this is to provide additional information to the rpc_node to track the source of the incoming requests.

SUPRA_HEADER = 'x-supra-client'
static get_supra_header_val()

Transactions

This translates Supra transactions to and from BCS for signing and submitting to the REST API.

class supra_sdk.transactions.AutomationRegistrationParams(registration_params)

Bases: object

V1: int = 0
static deserialize(deserializer)
Return type:

AutomationRegistrationParams

registration_params: Any
serialize(serializer)
Return type:

None

variant: int
class supra_sdk.transactions.AutomationRegistrationParamsV1(automated_function, max_gas_amount, gas_price_cap, automation_fee_cap_for_epoch, expiration_timestamp_secs, aux_data)

Bases: object

static deserialize(deserializer)
Return type:

AutomationRegistrationParamsV1

serialize(serializer)
Return type:

None

class supra_sdk.transactions.EntryFunction(module, function, ty_args, args)

Bases: object

args: list[bytes]
static deserialize(deserializer)
Return type:

EntryFunction

function: str
module: ModuleId
static natural(module, function, ty_args, args)
Return type:

EntryFunction

serialize(serializer)
Return type:

None

ty_args: list[TypeTag]
class supra_sdk.transactions.FeePayerRawTransaction(raw_transaction, secondary_signers, fee_payer)

Bases: RawTransactionWithData

fee_payer: AccountAddress | None
secondary_signers: list[AccountAddress]
serialize(serializer)
Return type:

None

class supra_sdk.transactions.ModuleBundle

Bases: object

static deserialize(deserializer)
Return type:

ModuleBundle

serialize(serializer)
Return type:

None

class supra_sdk.transactions.ModuleId(address, name)

Bases: object

address: AccountAddress
static deserialize(deserializer)
Return type:

ModuleId

static from_str(module_id)
Return type:

ModuleId

name: str
serialize(serializer)
Return type:

None

class supra_sdk.transactions.MultiAgentRawTransaction(raw_transaction, secondary_signers)

Bases: RawTransactionWithData

secondary_signers: list[AccountAddress]
serialize(serializer)
Return type:

None

class supra_sdk.transactions.Multisig(multisig_address, transaction_payload=None)

Bases: object

static deserialize(deserializer)
Return type:

Multisig

multisig_address: AccountAddress
serialize(serializer)
Return type:

None

transaction_payload: MultisigTransactionPayload | None
class supra_sdk.transactions.MultisigTransactionPayload(transaction_payload)

Bases: object

ENTRY_FUNCTION: int = 0
static deserialize(deserializer)
Return type:

MultisigTransactionPayload

payload_variant: int
serialize(serializer)
Return type:

None

transaction_payload: EntryFunction

Currently MultisigTransactionPayload only supports EntryFunction type payload

class supra_sdk.transactions.RawTransaction(sender, sequence_number, payload, max_gas_amount, gas_unit_price, expiration_timestamps_secs, chain_id)

Bases: Deserializable, RawTransactionInternal, Serializable

chain_id: int
static deserialize(deserializer)
Return type:

RawTransaction

expiration_timestamps_secs: int
gas_unit_price: int
max_gas_amount: int
payload: TransactionPayload
prehash()
Return type:

bytes

sender: AccountAddress
sequence_number: int
serialize(serializer)
Return type:

None

class supra_sdk.transactions.RawTransactionInternal(*args, **kwargs)

Bases: Protocol

keyed()
Return type:

bytes

prehash()
Return type:

bytes

serialize(serializer)
Return type:

None

sign(key)
Return type:

AccountAuthenticator

sign_simulated(key)
Return type:

AccountAuthenticator

verify(key, signature)
Return type:

bool

class supra_sdk.transactions.RawTransactionWithData(*args, **kwargs)

Bases: RawTransactionInternal, Protocol

inner()
Return type:

RawTransaction

prehash()
Return type:

bytes

raw_transaction: RawTransaction
class supra_sdk.transactions.Script(code, ty_args, args)

Bases: object

args: list[ScriptArgument]
code: bytes
static deserialize(deserializer)
Return type:

Script

serialize(serializer)
Return type:

None

ty_args: list[TypeTag]
class supra_sdk.transactions.ScriptArgument(variant, value)

Bases: object

ADDRESS: int = 3
BOOL: int = 5
U128: int = 2
U16: int = 6
U256: int = 8
U32: int = 7
U64: int = 1
U8: int = 0
U8_VECTOR: int = 4
static deserialize(deserializer)
Return type:

ScriptArgument

serialize(serializer)
Return type:

None

value: Any
variant: int
class supra_sdk.transactions.SignedTransaction(transaction, authenticator)

Bases: object

authenticator: Authenticator
bytes()
Return type:

bytes

static deserialize(deserializer)
Return type:

SignedTransaction

serialize(serializer)
Return type:

None

transaction: RawTransaction
verify()
Return type:

bool

class supra_sdk.transactions.SupraTransaction(transaction)

Bases: object

MOVE: int = 1
static deserialize(deserializer)
Return type:

SupraTransaction

serialize(serializer)
Return type:

None

to_bytes()

Provides BCS serialized bytes

Return type:

bytes

value: Any
variant: int
class supra_sdk.transactions.TransactionArgument(value, encoder)

Bases: object

encode()
Return type:

bytes

encoder: Callable[[Serializer, Any], None]
value: Any
class supra_sdk.transactions.TransactionPayload(payload)

Bases: object

AUTOMATION_REGISTRATION: int = 4
ENTRY_FUNCTION: int = 2
MODULE_BUNDLE: int = 1
MULTISIG: int = 3
SCRIPT: int = 0
static deserialize(deserializer)
Return type:

TransactionPayload

serialize(serializer)
Return type:

None

value: Any
variant: int

Type Tag

class supra_sdk.type_tag.AccountAddressTag(value)

Bases: Deserializable, Serializable

static deserialize(deserializer)
Return type:

AccountAddressTag

serialize(serializer)
value: AccountAddress
variant()
class supra_sdk.type_tag.BoolTag(value)

Bases: Deserializable, Serializable

static deserialize(deserializer)
Return type:

BoolTag

serialize(serializer)
value: bool
variant()
class supra_sdk.type_tag.StructTag(address, module, name, type_args)

Bases: Deserializable, Serializable

address: AccountAddress
static deserialize(deserializer)
Return type:

StructTag

static from_str(type_tag)
Return type:

StructTag

module: str
name: str
serialize(serializer)
type_args: list[TypeTag]
variant()
class supra_sdk.type_tag.TypeTag(value)

Bases: Deserializable, Serializable

TypeTag represents a primitive in Move.

ACCOUNT_ADDRESS: int = 4
BOOL: int = 0
SIGNER: int = 5
STRUCT: int = 7
U128: int = 3
U16: int = 8
U256: int = 10
U32: int = 9
U64: int = 2
U8: int = 1
VECTOR: int = 6
static deserialize(deserializer)
Return type:

TypeTag

serialize(serializer)
value: Any
class supra_sdk.type_tag.U128Tag(value)

Bases: Deserializable, Serializable

static deserialize(deserializer)
Return type:

U128Tag

serialize(serializer)
value: int
variant()
class supra_sdk.type_tag.U16Tag(value)

Bases: Deserializable, Serializable

static deserialize(deserializer)
Return type:

U16Tag

serialize(serializer)
value: int
variant()
class supra_sdk.type_tag.U256Tag(value)

Bases: Deserializable, Serializable

static deserialize(deserializer)
Return type:

U256Tag

serialize(serializer)
value: int
variant()
class supra_sdk.type_tag.U32Tag(value)

Bases: Deserializable, Serializable

static deserialize(deserializer)
Return type:

U32Tag

serialize(serializer)
value: int
variant()
class supra_sdk.type_tag.U64Tag(value)

Bases: Deserializable, Serializable

static deserialize(deserializer)
Return type:

U64Tag

serialize(serializer)
value: int
variant()
class supra_sdk.type_tag.U8Tag(value)

Bases: Deserializable, Serializable

static deserialize(deserializer)
Return type:

U8Tag

serialize(serializer)
value: int
variant()