API
Account
- class supra_sdk.account.Account(account_address, private_key)
Bases:
objectRepresents 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:
- auth_key()
Returns the auth_key for the associated account
- Return type:
str
-
private_key:
PrivateKey
- sign_simulated_transaction(transaction)
- Return type:
- sign_transaction(transaction)
- Return type:
- store(path)
-
account_address:
- class supra_sdk.account.RotationProofChallenge(sequence_number, originator, current_auth_key, new_public_key)
Bases:
object-
current_auth_key:
AccountAddress
-
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'
-
current_auth_key:
Account Address
- class supra_sdk.account_address.AccountAddress(address)
Bases:
object-
LENGTH:
int= 32
-
address:
bytes
- static deserialize(deserializer)
- Return type:
- static for_guid_object(creator, creation_num)
- Return type:
- static for_named_collection(creator, collection_name)
- Return type:
- static for_named_object(creator, seed)
- Return type:
- static for_named_token(creator, collection_name, token_name)
- Return type:
- static for_resource_account(creator, seed)
- Return type:
- static from_key(key)
- Return type:
- 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)
-
LENGTH:
- 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'
-
DeriveObjectAddressFromGuid:
- exception supra_sdk.account_address.ParseAddressError
Bases:
ExceptionThere was an error parsing an address.
Asymmetric Crypto
- class supra_sdk.asymmetric_crypto.PrivateKey(*args, **kwargs)
Bases:
Deserializable,Serializable,Protocol- hex()
- Return type:
str
- 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:
- static from_crypto_bytes(indata)
- Return type:
- 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:
- serialize(serializer)
- unset_signatures()
-
BITMAP_NUM_OF_BYTES:
- class supra_sdk.asymmetric_crypto_wrapper.PublicKey(public_key)
Bases:
PublicKey-
ED25519:
int= 0
- 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
-
ED25519:
- class supra_sdk.asymmetric_crypto_wrapper.Signature(signature)
Bases:
Signature-
ED25519:
int= 0
- serialize(serializer)
-
variant:
int
-
ED25519:
- 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:
- serialize(serializer)
- unset_signature()
-
variant:
int
- verify(data)
- Return type:
bool
-
ED25519:
- class supra_sdk.authenticator.Authenticator(authenticator)
Bases:
objectEach 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:
- static from_key(key)
- Return type:
int
- serialize(serializer)
- unset_signature()
-
variant:
int
- verify(data)
- Return type:
bool
-
ED25519:
- class supra_sdk.authenticator.Ed25519Authenticator(public_key, signature)
Bases:
object- static deserialize(deserializer)
- Return type:
- serialize(serializer)
- unset_signature()
- verify(data)
- Return type:
bool
- class supra_sdk.authenticator.FeePayerAuthenticator(sender, secondary_signers, fee_payer)
Bases:
object- static deserialize(deserializer)
- Return type:
-
fee_payer:
tuple[AccountAddress,AccountAuthenticator]
- fee_payer_address()
- Return type:
- 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:
- 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:
-
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:
-
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:
- 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:
- classmethod from_bytes(indata)
- Return type:
- class supra_sdk.bcs.Deserializer(data)
Bases:
object- 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]
- 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:
- static from_crypto_bytes(indata)
- Return type:
- 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:
- static from_key_map(public_key, signatures_map)
- Return type:
- serialize(serializer)
- unset_signatures()
-
BITMAP_NUM_OF_BYTES:
- class supra_sdk.ed25519.PrivateKey(key)
Bases:
PrivateKey-
LENGTH:
int= 32
- static deserialize(deserializer)
- Return type:
- static from_str(value)
- Return type:
- hex()
- Return type:
str
-
key:
SigningKey
- static random()
- Return type:
- serialize(serializer)
-
LENGTH:
- class supra_sdk.ed25519.PublicKey(key)
Bases:
PublicKey-
LENGTH:
int= 32
-
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
-
LENGTH:
Metadata
- class supra_sdk.metadata.Metadata
Bases:
objectRepresents 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:
-
registration_params:
Any
- serialize(serializer)
- Return type:
None
-
variant:
int
-
V1:
- 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:
- 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:
-
function:
str
- static natural(module, function, ty_args, args)
- Return type:
- serialize(serializer)
- Return type:
None
-
args:
- 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
-
fee_payer:
- class supra_sdk.transactions.ModuleBundle
Bases:
object- static deserialize(deserializer)
- Return type:
- serialize(serializer)
- Return type:
None
- class supra_sdk.transactions.ModuleId(address, name)
Bases:
object-
address:
AccountAddress
-
name:
str
- serialize(serializer)
- Return type:
None
-
address:
- class supra_sdk.transactions.MultiAgentRawTransaction(raw_transaction, secondary_signers)
Bases:
RawTransactionWithData-
secondary_signers:
list[AccountAddress]
- serialize(serializer)
- Return type:
None
-
secondary_signers:
- class supra_sdk.transactions.Multisig(multisig_address, transaction_payload=None)
Bases:
object-
multisig_address:
AccountAddress
- serialize(serializer)
- Return type:
None
-
transaction_payload:
MultisigTransactionPayload|None
-
multisig_address:
- class supra_sdk.transactions.MultisigTransactionPayload(transaction_payload)
Bases:
object-
ENTRY_FUNCTION:
int= 0
- static deserialize(deserializer)
- Return type:
-
payload_variant:
int
- serialize(serializer)
- Return type:
None
-
transaction_payload:
EntryFunction Currently MultisigTransactionPayload only supports EntryFunction type payload
-
ENTRY_FUNCTION:
- 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:
-
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
-
chain_id:
- 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:
- sign_simulated(key)
- Return type:
- verify(key, signature)
- Return type:
bool
- class supra_sdk.transactions.RawTransactionWithData(*args, **kwargs)
Bases:
RawTransactionInternal,Protocol- inner()
- Return type:
- prehash()
- Return type:
bytes
-
raw_transaction:
RawTransaction
- class supra_sdk.transactions.Script(code, ty_args, args)
Bases:
object-
args:
list[ScriptArgument]
-
code:
bytes
- serialize(serializer)
- Return type:
None
-
args:
- 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:
- serialize(serializer)
- Return type:
None
-
value:
Any
-
variant:
int
-
ADDRESS:
- class supra_sdk.transactions.SignedTransaction(transaction, authenticator)
Bases:
object-
authenticator:
Authenticator
- static deserialize(deserializer)
- Return type:
- serialize(serializer)
- Return type:
None
-
transaction:
RawTransaction
- verify()
- Return type:
bool
-
authenticator:
- class supra_sdk.transactions.SupraTransaction(transaction)
Bases:
object-
MOVE:
int= 1
- static deserialize(deserializer)
- Return type:
- serialize(serializer)
- Return type:
None
- to_bytes()
Provides BCS serialized bytes
- Return type:
bytes
-
value:
Any
-
variant:
int
-
MOVE:
- 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:
- serialize(serializer)
- Return type:
None
-
value:
Any
-
variant:
int
-
AUTOMATION_REGISTRATION:
Type Tag
- class supra_sdk.type_tag.AccountAddressTag(value)
Bases:
Deserializable,Serializable- static deserialize(deserializer)
- Return type:
- serialize(serializer)
-
value:
AccountAddress
- variant()
- class supra_sdk.type_tag.BoolTag(value)
Bases:
Deserializable,Serializable- serialize(serializer)
-
value:
bool
- variant()
- class supra_sdk.type_tag.StructTag(address, module, name, type_args)
Bases:
Deserializable,Serializable-
address:
AccountAddress
-
module:
str
-
name:
str
- serialize(serializer)
- variant()
-
address:
- class supra_sdk.type_tag.TypeTag(value)
Bases:
Deserializable,SerializableTypeTag 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
- serialize(serializer)
-
value:
Any
-
ACCOUNT_ADDRESS:
- class supra_sdk.type_tag.U128Tag(value)
Bases:
Deserializable,Serializable- serialize(serializer)
-
value:
int
- variant()
- class supra_sdk.type_tag.U16Tag(value)
Bases:
Deserializable,Serializable- serialize(serializer)
-
value:
int
- variant()
- class supra_sdk.type_tag.U256Tag(value)
Bases:
Deserializable,Serializable- serialize(serializer)
-
value:
int
- variant()
- class supra_sdk.type_tag.U32Tag(value)
Bases:
Deserializable,Serializable- serialize(serializer)
-
value:
int
- variant()
- class supra_sdk.type_tag.U64Tag(value)
Bases:
Deserializable,Serializable- serialize(serializer)
-
value:
int
- variant()
- class supra_sdk.type_tag.U8Tag(value)
Bases:
Deserializable,Serializable- serialize(serializer)
-
value:
int
- variant()