pysui.sui.sui_txn package
Submodules
pysui.sui.sui_txn.async_transaction module
Sui asynchronous Transaction for building Programmable Transactions.
- class pysui.sui.sui_txn.async_transaction.SuiTransactionAsync(*args, **kwargs)
Bases:
_SuiTransactionBase
.
Deprecated since version 0.54.0: Transitioning to sui_pgql
Changed in version 0.30.0: Separated sync and async SuiTransaction.
- __init__(**kwargs) None
__init__ Initialize the asynchronous SuiTransaction.
- Parameters:
client (AsyncClient) – The asynchronous SuiClient
merge_gas_budget (bool, optional) – If True will take available gas not in use for paying for transaction, defaults to False
initial_sender (Union[SuiAddress, SigningMultiSig], optional) – The address of the sender of the transaction, defaults to None
compress_inputs (bool,optional) – Reuse identical inputs, defaults to False
deserialize_from (Union[str, bytes], optional) – Will rehydrate SuiTransaction state from serialized base64 str or bytes, defaults to None
Changed in version 0.39.0: keyword arguments
Changed in version 0.39.0: Added compress_inputs option
Changed in version 0.33.0: Added deserialize_from optional argument
Changed in version 0.29.1: Eliminated redundant gas price RPC call
- async get_transaction_data(*, gas_budget: str | None = None) TransactionData
Returns the BCS TransactionKind.
Changed in version 0.35.1: gas_budget is optional.
New in version 0.17.0: Convenience for serializing and dry-running.
- async execute(*, gas_budget: str | SuiString | None = '', options: dict | None = None, use_gas_object: str | ObjectID | None = None, run_verification: bool | None = False) SuiRpcResult | ValueError
execute Finalizes transaction and submits for execution on the chain.
- Parameters:
gas_budget (Optional[Union[str, SuiString]], optional) – The gas budget to use. If set, it will be used in transaction. Otherwise a dry-run is peformed to set budget, default to empty string (None)
options (Optional[dict], optional) – An options dictionary to pass to sui_executeTransactionBlock to control the information results, defaults to None
use_gas_object (Optional[Union[str, ObjectID]], optional) – Explicit gas object to use for payment, defaults to None Will fail if provided object is marked as ‘in use’ in commands
run_verification (Optional[bool], optional) – Will run validation on transaction using Sui ProtocolConfig constraints, defaults to False. Will fail if validation errors (SuiRpcResult.is_err()).
- Returns:
The result of running the transaction or a failing verification
- Return type:
Changed in version 0.31.0: Added optional ‘run_verification’ argument.
Changed in version 0.28.0: Added optional ‘use_gas_object’ argument.
- async deferred_execution(*, gas_budget: str | SuiString | None = '', use_gas_object: str | ObjectID | None = None, run_verification: bool | None = False) str | ValueError
deferred_execution Finalizes transaction and returns base64 string for signing.
The result can then be signed (single, multisig, etc) and then executed
- Parameters:
gas_budget (Optional[Union[str, SuiString]], optional) – The gas budget to use. If set, it will be used in transaction. Otherwise a dry-run is peformed to set budget, default to empty string (None)
use_gas_object (Optional[Union[str, ObjectID]], optional) – Explicit gas object to use for payment, defaults to None. Will fail if provided object is marked as ‘in use’ in commands.
run_verification (Optional[bool], optional) – Will run validation on transaction using Sui ProtocolConfig constraints, defaults to False. Will fail if validation errors (SuiRpcResult.is_err()).
- Returns:
The bsae64 encoded transaction bytes that can be signed for execution
- Return type:
str
New in version 0.35.0: Added for offline signing support
- async inspect_all() TxInspectionResult | SuiRpcResult
inspect_all Returns results of sui_devInspectTransactionBlock on the current Transaction.
- Parameters:
for_sender (Union[str, SuiAddress], optional) – Used for inspection. If not supplied, uses current Transaction sender, defaults to None
- Returns:
The successful result or the SuiRpcResult if inspect transaction failed.
- Return type:
Union[TxInspectionResult, SuiRpcResult]
Changed in version 0.16.1: Added returning SuiRpcResult if inspect transaction failed.
- async make_move_vector(items: list[Any], item_type: str | None = None) Argument
Create a call to convert a list of objects to a Sui ‘vector’ of item_type.
Changed in version 0.40.0: Removed constraint of making vector from pure types
Changed in version 0.21.1: Added optional item_type argument
Changed in version 0.19.0: Check that only type Objects are passed
- async move_call(*, target: str | SuiString, arguments: list | SuiArray, type_arguments: list | SuiArray | None = None) Argument | list[Argument]
move_call Creates a command to invoke a move contract call. May or may not return results.
- Parameters:
target (Union[str, SuiString]) – String triple in form “package_object_id::module_name::function_name”
arguments (Union[list, SuiArray]) – Parameters that are passed to the move function
type_arguments (Optional[Union[list, SuiArray]], optional) – Optional list of type arguments for move function generics, defaults to None
- Returns:
The result which may or may not be used in subequent commands depending on the move method being called.
- Return type:
Union[bcs.Argument, list[bcs.Argument]]
Changed in version 0.20.2: Fixed #107
Changed in version 0.17.0: Target uses ‘package_id::module::function’ construct only
- async publish(*, project_path: str, args_list: list[str] | None = None) Argument
publish Creates a publish command.
- Parameters:
project_path (str) – path to project folder
args_list (Optional[list[str]], optional) – Additional sui move build arguments, defaults to None
- Returns:
A command result (UpgradeCap) that should used in a subsequent transfer commands
- Return type:
Changed in version 0.50.0: Removed with_unpublished_dependencies and skip_fetch_latest_git_deps replace with args list.
Changed in version 0.36.0: Drop legacy_digest. No longer supported by Sui.
Changed in version 0.20.0: Removed recipient. Transfer of UpgradeCap up to user as per Sui best practice.
- async publish_upgrade(*, project_path: str, package_id: str | ObjectID, upgrade_cap: str | ObjectID | ObjectRead, args_list: list[str] | None = None) Argument
publish_upgrade Authorize, publish and commit upgrade of package.
- Parameters:
project_path (str) – path to project folder
package_id (Union[str, ObjectID]) – The current package id that is being upgraded
upgrade_cap (Union[str, ObjectID, ObjectRead]) – The upgrade capability object
args_list (Optional[list[str]], optional) – Additional sui move build arguments, defaults to None
- Returns:
The Result Argument
- Return type:
Changed in version 0.50.0: Removed with_unpublished_dependencies and skip_fetch_latest_git_deps replace with args list.
Changed in version 0.36.0: Drop legacy_digest. No longer supported by Sui.
Changed in version 0.20.0: Added package compiled digest control as per Sui 1.0.0.
Changed in version 0.17.0: Dropped recipient as the resulting UpgradeCap goes to main signer.
- async custom_upgrade(*, project_path: str, package_id: str | ObjectID, upgrade_cap: str | ObjectID | ObjectRead, authorize_upgrade_fn: Callable[[SuiTransactionAsync, ObjectRead, Digest], Awaitable[Argument]], commit_upgrade_fn: Callable[[SuiTransactionAsync, ObjectRead, Argument], Awaitable[Argument]], args_list: list[str] | None = None) Argument
custom_upgrade Support for custom authorization and commitments.
- Parameters:
project_path (str) – path to project folder
package_id (Union[str, ObjectID]) – The current package id that is being upgraded
upgrade_cap (Union[str, ObjectID, ObjectRead]) – The upgrade capability object
authorize_upgrade_fn (Callable[["SuiTransaction", ObjectRead, bcs.Digest], bcs.Argument]) – Function to be called that generates custom authorization ‘move_call’
commit_upgrade_fn (Callable[["SuiTransaction", ObjectRead, bcs.Argument], bcs.Argument]) – Function to be called that generates custom commitment ‘move_call’
args_list (Optional[list[str]], optional) – Additional sui move build arguments, defaults to None
- Returns:
The Result Argument
- Return type:
Changed in version 0.50.0: Removed with_unpublished_dependencies and skip_fetch_latest_git_deps replace with args list.
New in version 0.20.0: Support Sui 1.0.0 custom upgrades
- async stake_coin(*, coins: list[ObjectID], validator_address: str | SuiAddress, amount: int | SuiInteger | None = None) Argument
stake_coin Stakes one or more coins to a specific validator.
- Parameters:
coins (list[ObjectID]) – One or more coins to stake.
validator_address (Union[str, SuiAddress]) – The validator to stake coins to
amount (Optional[Union[int, SuiInteger]], optional) – Amount from coins to stake. If not stated, all coin will be staked, defaults to None
- Returns:
The command result.
- Return type:
- async unstake_coin(*, staked_coin: str | ObjectID | StakedSui) Argument
unstake_coin Unstakes a Staked Sui Coin.
- async split_coin(*, coin: str | ObjectID | ObjectRead | SuiCoinObject | Argument, amounts: list[int | SuiInteger | Argument]) Argument | list[Argument]
split_coin Creates a new coin(s) with the defined amount(s), split from the provided coin.
Note: Returns the result that it can be used in subsequent commands. If only one amount is provided, a standard Result can be used as a singular argument to another command. But if more than 1 amount. For example you can index to get a singular value or use the whole list.
# Transfer all coins to one recipient txer = SuiTransaction(client) scres = txer.split_coin(coin=primary_coin, amounts=[1000000000, 1000000000]) txer.transfer_objects(transfers=scres, recipient=client.config.active_address) # OR only transfer less than all txer.transfer_objects(transfers=[scres[0]],recipient=client.config.active_address)
- Parameters:
coin (Union[str, ObjectID, ObjectRead,SuiCoinObject, bcs.Argument]) – The coin address (object id) to split from.
amounts (list[Union[int, SuiInteger, bcs.Argument]]) – The amount or list of amounts to split the coin out to
- Returns:
A result or list of results types to use in subsequent commands
- Return type:
Union[list[bcs.Argument],bcs.Argument]
Changed in version 0.33.0: Accept bcs.Argument (i.e. Result) in amounts
Changed in version 0.17.0: Made ‘amount’ ‘amounts’ with list argument.
- async split_coin_equal(*, coin: str | ObjectID | ObjectRead | SuiCoinObject | Argument, split_count: int | SuiInteger, coin_type: str | None = '0x2::sui::SUI') Argument
split_coin_equal Splits a Sui coin into equal parts and transfers to transaction signer.
- Parameters:
coin (Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]) – The coin to split
split_count (Union[int, SuiInteger]) – The number of parts to split coin into
coin_type (Optional[str], optional) – The coin type, defaults to a Sui coin type
- Returns:
The command result. Because all splits are automagically transferred to signer, the result is not usable as input to subseqent commands.
- Return type:
New in version 0.16.1: Expand Transaction builder ease of use capability.
- async split_coin_and_return(*, coin: str | ObjectID | ObjectRead | SuiCoinObject | Argument, split_count: int | SuiInteger, coin_type: str | None = '0x2::sui::SUI') Argument
split_coin_and_return Splits a Sui coin into equal parts and returns array of split_count-1 for user to transfer.
- Parameters:
coin (Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]) – The coin to split
split_count (Union[int, SuiInteger]) – The number of parts to split coin into
coin_type (Optional[str], optional) – The coin type, defaults to a Sui coin type
- Returns:
The command result which is a vector of coins split out and may be used in subsequent commands.
- Return type:
- async merge_coins(*, merge_to: str | ObjectID | ObjectRead | SuiCoinObject | Argument, merge_from: list[str | ObjectID | ObjectRead | SuiCoinObject | Argument] | SuiArray) Argument
merge_coins Merges one or more coins to a primary coin.
- Parameters:
merge_to (Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]) – The coin to merge other coins to
merge_from (Union[list[Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]], SuiArray]) – One or more coins to merge to primary ‘merge_to’ coin
- Returns:
The command result. Can not be used as input in subsequent commands.
- Return type:
- async public_transfer_object(*, object_to_send: str | ObjectID | ObjectRead | SuiCoinObject | Argument, recipient: SuiAddress, object_type: str) Argument
public_transfer_object Public transfer of any object.
- Parameters:
object_to_send (Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]) – Object being transferred
recipient (SuiAddress) – Address for recipient of object_to_send
object_type (str) – Type arguments
- Returns:
Result of command which is non-reusable
- Return type:
- async transfer_objects(*, transfers: list[str | ObjectID | ObjectRead | SuiCoinObject | Argument] | SuiArray, recipient: ObjectID | SuiAddress) Argument
transfer_objects Transfers one or more objects to a recipient.
- Parameters:
transfers (Union[list[Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]], SuiArray]) – A list or SuiArray of objects to transfer
recipient (Union[ObjectID, SuiAddress]) – The recipient address that will receive the objects being transfered
- Returns:
The command result. Can NOT be used as input in subsequent commands.
- Return type:
- async transfer_sui(*, recipient: ObjectID | SuiAddress, from_coin: str | ObjectID | ObjectRead | SuiCoinObject | Argument, amount: int | SuiInteger | None = None) Argument
transfer_sui Transfers a Sui coin object to a recipient.
- Parameters:
recipient (Union[ObjectID, SuiAddress]) – The recipient address that will receive the Sui coin being transfered
from_coin (Union[str, ObjectID, ObjectRead, SuiCoinObject]) – The Sui coin to transfer
amount (Optional[Union[int, SuiInteger]], optional) – Optional amount to transfer. Entire coin if not specified, defaults to None
- Raises:
ValueError – If unable to fetch the from_coin
ValueError – If from_coin is invalid
- Returns:
The command result. Can NOT be used as input in subsequent commands.
- Return type:
pysui.sui.sui_txn.signing_ms module
Transaction MultiSig Signing.
- class pysui.sui.sui_txn.signing_ms.SigningMultiSig(msig: BaseMultiSig, pub_keys: list[SuiPublicKey])
Bases:
object
Wraps the mutli-sig along with pubkeys to use in SuiTransaction.
Changed in version 0.35.0: Change msig to BaseMultiSig
New in version 0.21.1: Support subset pubkey address generation
New in version 0.17.0: Standardize on signing permutations
- __init__(msig: BaseMultiSig, pub_keys: list[SuiPublicKey])
.
- property signing_address: str
.
- class pysui.sui.sui_txn.signing_ms.SignerBlock(*, sender: SuiAddress | SigningMultiSig | None = None, sponsor: SuiAddress | SigningMultiSig | None = None)
Bases:
_SignerBlockBase
Manages the potential signers and resolving the gas object for paying.
Changed in version 0.26.0: Refactor to support Async.
Changed in version 0.18.0: Removed additional_signers as not supported by Sui at the moment.
New in version 0.17.0: Standardize on signing permutations
- __init__(*, sender: SuiAddress | SigningMultiSig | None = None, sponsor: SuiAddress | SigningMultiSig | None = None)
__init__ Create a signer block.
- Parameters:
sender (Optional[Union[SuiAddress, SigningMultiSig]], optional) – The primary sender/signer, defaults to None
sponsor (Optional[Union[SuiAddress, SigningMultiSig]], optional) – An optional sponsor for transaction, defaults to None
- property payer_address: str
Fetch payer address.
- get_gas_object(*, client: SuiClient, budget: int, objects_in_use: dict, merge_coin: bool, gas_price: int) GasData | ValueError
Produce a gas object from either the sponsor or the sender.
Changed in version 0.39.0: Change object_in_use type
Changed in version 0.30.0: Leverage multiple gas objects passed for paying in transaction.
Changed in version 0.28.0: Use _ConsolidateSui if coins needed for gas.
Changed in version 0.21.1: Corrected when using multisig senders.
- async get_gas_object_async(*, client: SuiClient, budget: int, objects_in_use: dict, merge_coin: bool, gas_price: int) GasData
Produce a gas object from either the sponsor or the sender.
Changed in version 0.39.0: Change object_in_use registry type.
Changed in version 0.30.0: Leverage multiple gas objects passed for paying in transaction.
Changed in version 0.28.0: Use _ConsolidateSui if coins needed for gas.
New in version 0.26.0: Added to support async operations
pysui.sui.sui_txn.sync_transaction module
Sui synchronous Transaction for building Programmable Transactions.
- class pysui.sui.sui_txn.sync_transaction.SuiTransaction(*args, **kwargs)
Bases:
_SuiTransactionBase
High level transaction builder.
Deprecated since version 0.54.0: Transitioning to sui_pgql
Changed in version 0.30.0: Separated sync and async SuiTransaction.
Changed in version 0.20.3: Explicit support of tx.gas.
- __init__(**kwargs) None
__init__ Initialize the synchronous SuiTransaction.
- Parameters:
client (SyncClient) – The synchronous SuiClient
initial_sender (Union[SuiAddress, SigningMultiSig], optional) – The address of the sender of the transaction, defaults to None
compress_inputs (bool,optional) – Reuse identical inputs, defaults to False
merge_gas_budget (bool, optional) – If True will take available gas not in use for paying for transaction, defaults to False
deserialize_from (Union[str, bytes], optional) – Will rehydrate SuiTransaction state from serialized base64 str or bytes, defaults to None
Changed in version 0.39.0: keyword arguments
Changed in version 0.39.0: Added compress_inputs option
Changed in version 0.33.0: Added deserialize_from optional argument
Changed in version 0.29.1: Eliminated redundant gas price RPC call
Changed in version 0.21.1: Takes a ‘initial_sender’ as option.
- inspect_all() TxInspectionResult | SuiRpcResult
inspect_all Returns results of sui_devInspectTransactionBlock on the current Transaction.
- Parameters:
for_sender (Union[str, SuiAddress], optional) – Used for inspection. If not supplied, uses current Transaction sender, defaults to None
- Returns:
The successful result or the SuiRpcResult if inspect transaction failed.
- Return type:
Union[TxInspectionResult, SuiRpcResult]
Changed in version 0.16.1: Added returning SuiRpcResult if inspect transaction failed.
- inspect_for_cost() tuple[int, int, str] | SuiRpcResult
inspect_for_cost Runs inspect transaction for cost summary.
- Parameters:
for_sender (Union[str, SuiAddress], optional) – Use for inspection. If not supplied, uses current Transaction sender, defaults to None
- Returns:
If inspect did not fail, a tuple of gas_max, gas_min, gas object_id otherwise None
- Return type:
Union[tuple[int, int, str], SuiRpcResult]
Changed in version 0.16.1: Added returning SuiRpcResult if inspect transaction failed.
- get_transaction_data(*, gas_budget: str | None = None) TransactionData
Returns the BCS TransactionKind.
Changed in version 0.35.1: gas_budget is optional.
New in version 0.17.0: Convenience for serializing and dry-running.
- execute(*, gas_budget: str | SuiString | None = '', options: dict | None = None, use_gas_object: str | ObjectID | None = None, run_verification: bool | None = False) SuiRpcResult | ValueError
execute Finalizes transaction and submits for execution on the chain.
- Parameters:
gas_budget (Optional[Union[str, SuiString]], optional) – The gas budget to use. If set, it will be used in transaction. Otherwise a dry-run is peformed to set budget, default to empty string (None)
options (Optional[dict], optional) – An options dictionary to pass to sui_executeTransactionBlock to control the information results, defaults to None
use_gas_object (Optional[Union[str, ObjectID]], optional) – Explicit gas object to use for payment, defaults to None. Will fail if provided object is marked as ‘in use’ in commands.
run_verification (Optional[bool], optional) – Will run validation on transaction using Sui ProtocolConfig constraints, defaults to False. Will fail if validation errors (SuiRpcResult.is_err()).
- Returns:
The result of running the transaction or a failing verification
- Return type:
Changed in version 0.32.0: Changed gas_budget to explicitly set budget, otherwise a dry-run estimates
Changed in version 0.31.0: Added optional ‘run_verification’ argument.
Changed in version 0.28.0: Added optional ‘use_gas_object’ argument.
- deferred_execution(*, gas_budget: str | SuiString | None = '', use_gas_object: str | ObjectID | None = None, run_verification: bool | None = False) str | ValueError
deferred_execution Finalizes transaction and returns base64 string for signing.
The result can then be signed (single, multisig) and then executed
- Parameters:
gas_budget (Optional[Union[str, SuiString]], optional) – The gas budget to use. If set, it will be used in transaction. Otherwise a dry-run is peformed to set budget, default to empty string (None)
use_gas_object (Optional[Union[str, ObjectID]], optional) – Explicit gas object to use for payment, defaults to None. Will fail if provided object is marked as ‘in use’ in commands.
run_verification (Optional[bool], optional) – Will run validation on transaction using Sui ProtocolConfig constraints, defaults to False. Will fail if validation errors (SuiRpcResult.is_err()).
- Returns:
The bsae64 encoded transaction bytes that can be signed for execution
- Return type:
str
New in version 0.35.0: Added for offline signing support
- make_move_vector(items: list[Any], item_type: str | None = None) Argument
Create a call to convert a list of objects to a Sui ‘vector’ of item_type.
Changed in version 0.40.0: Removed constraint of making vector from pure types
Changed in version 0.21.1: Added optional item_type argument
Changed in version 0.19.0: Check that only type Objects are passed
- move_call(*, target: str | SuiString, arguments: list | SuiArray, type_arguments: list | SuiArray | None = None) Argument | list[Argument]
move_call Creates a command to invoke a move contract call. May or may not return results.
- Parameters:
target (Union[str, SuiString]) – String triple in form “package_object_id::module_name::function_name”
arguments (Union[list, SuiArray]) – Parameters that are passed to the move function
type_arguments (Optional[Union[list, SuiArray]], optional) – Optional list of type arguments for move function generics, defaults to None
- Returns:
The result which may or may not be used in subequent commands depending on the move method being called.
- Return type:
Union[bcs.Argument, list[bcs.Argument]]
Changed in version 0.20.2: Fixed #107
Changed in version 0.17.0: Target uses ‘package_id::module::function’ construct only
- publish(*, project_path: str, args_list: list[str] | None = None) Argument
publish Creates a publish command.
- Parameters:
project_path (str) – path to project folder
args_list (Optional[list[str]], optional) – Additional sui move build arguments, defaults to None
- Returns:
A command result (UpgradeCap) that should used in a subsequent transfer commands
- Return type:
Changed in version 0.50.0: Removed with_unpublished_dependencies and skip_fetch_latest_git_deps replace with args list.
Changed in version 0.36.0: Removed legacy_digest. No longer supported in Sui.
Changed in version 0.20.0: Removed recipient. Transfer of UpgradeCap up to user as per Sui best practice.
- publish_upgrade(*, project_path: str, package_id: str | ObjectID, upgrade_cap: str | ObjectID | ObjectRead, args_list: list[str] | None) Argument
publish_upgrade Authorize, publish and commit upgrade of package.
- Parameters:
project_path (str) – path to project folder
package_id (Union[str, ObjectID]) – The current package id that is being upgraded
upgrade_cap (Union[str, ObjectID, ObjectRead]) – The upgrade capability object
args_list (Optional[list[str]], optional) – Additional sui move build arguments, defaults to None
- Returns:
The Result Argument
- Return type:
Changed in version 0.50.0: Removed with_unpublished_dependencies and skip_fetch_latest_git_deps replace with args list.
Changed in version 0.36.0: Dropped legacy_digest. No longer supported in Sui.
Changed in version 0.20.0: Added package compiled digest control as per Sui 1.0.0.
Changed in version 0.17.0: Dropped recipient as the resulting UpgradeCap goes to main signer.
- custom_upgrade(*, project_path: str, package_id: str | ObjectID, upgrade_cap: str | ObjectID | ObjectRead, authorize_upgrade_fn: Callable[[SuiTransaction, ObjectRead, Digest], Argument], commit_upgrade_fn: Callable[[SuiTransaction, ObjectRead, Argument], Argument], args_list: list[str] | None = None) Argument
custom_upgrade Support for custom authorization and commitments.
- Parameters:
project_path (str) – path to project folder
package_id (Union[str, ObjectID]) – The current package id that is being upgraded
upgrade_cap (Union[str, ObjectID, ObjectRead]) – The upgrade capability object
authorize_upgrade_fn (Callable[["SuiTransaction", ObjectRead, bcs.Digest], bcs.Argument]) – Function to be called that generates custom authorization ‘move_call’
commit_upgrade_fn (Callable[["SuiTransaction", ObjectRead, bcs.Argument], bcs.Argument]) – Function to be called that generates custom commitment ‘move_call’
args_list (Optional[list[str]], optional) – Additional sui move build arguments, defaults to None
- Returns:
The result argument
- Return type:
Changed in version 0.50.0: Removed with_unpublished_dependencies and skip_fetch_latest_git_deps replace with args list.
New in version 0.20.0: Support Sui 1.0.0 custom upgrades
- stake_coin(*, coins: list[ObjectID], validator_address: str | SuiAddress, amount: int | SuiInteger | None = None) Argument
stake_coin Stakes one or more coins to a specific validator.
- Parameters:
coins (list[ObjectID]) – One or more coins to stake.
validator_address (Union[str, SuiAddress]) – The validator to stake coins to
amount (Optional[Union[int, SuiInteger]], optional) – Amount from coins to stake. If not stated, all coin will be staked, defaults to None
- Returns:
The command result.
- Return type:
- unstake_coin(*, staked_coin: str | ObjectID | StakedSui) Argument
unstake_coin Unstakes a Staked Sui Coin.
- split_coin(*, coin: str | ObjectID | ObjectRead | SuiCoinObject | Argument, amounts: list[int | SuiInteger | Argument]) Argument | list[Argument]
split_coin Creates a new coin(s) with the defined amount(s), split from the provided coin.
Note: Returns the result that it can be used in subsequent commands. If only one amount is provided, a standard Result can be used as a singular argument to another command. But if more than 1 amount. For example you can index to get a singular value or use the whole list.
# Transfer all coins to one recipient txer = SuiTransaction(client) scres = txer.split_coin(coin=primary_coin, amounts=[1000000000, 1000000000]) txer.transfer_objects(transfers=scres, recipient=client.config.active_address) # OR only transfer less than all txer.transfer_objects(transfers=[scres[0]],recipient=client.config.active_address)
- Parameters:
coin (Union[str, ObjectID, ObjectRead,SuiCoinObject, bcs.Argument]) – The coin address (object id) to split from.
amounts (list[Union[int, SuiInteger,bcs.Argument]]) – The amount or list of amounts to split the coin out to
- Returns:
A result or list of results types to use in subsequent commands
- Return type:
Union[list[bcs.Argument],bcs.Argument]
Changed in version 0.33.0: Accept bcs.Argument (i.e. Result) in amounts
Changed in version 0.17.0: Made ‘amount’ ‘amounts’ with list argument.
- split_coin_equal(*, coin: str | ObjectID | ObjectRead | SuiCoinObject | Argument, split_count: int | SuiInteger, coin_type: str | None = '0x2::sui::SUI') Argument
split_coin_equal Splits a Sui coin into equal parts and transfers to transaction signer.
- Parameters:
coin (Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]) – The coin to split
split_count (Union[int, SuiInteger]) – The number of parts to split coin into
coin_type (Optional[str], optional) – The coin type, defaults to a Sui coin type
- Returns:
The command result. Because all splits are automagically transferred to signer, the result is not usable as input to subseqent commands.
- Return type:
New in version 0.16.1: Expand Transaction builder ease of use capability.
- split_coin_and_return(*, coin: str | ObjectID | ObjectRead | SuiCoinObject | Argument, split_count: int | SuiInteger, coin_type: str | None = '0x2::sui::SUI') Argument
split_coin_and_return Splits a Sui coin into equal parts and returns array of split_count-1 for user to transfer.
- Parameters:
coin (Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]) – The coin to split
split_count (Union[int, SuiInteger]) – The number of parts to split coin into
coin_type (Optional[str], optional) – The coin type, defaults to a Sui coin type
- Returns:
The command result which is a vector of coins split out and may be used in subsequent commands.
- Return type:
- merge_coins(*, merge_to: str | ObjectID | ObjectRead | SuiCoinObject | Argument, merge_from: list[str | ObjectID | ObjectRead | SuiCoinObject | Argument] | SuiArray) Argument
merge_coins Merges one or more coins to a primary coin.
- Parameters:
merge_to (Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]) – The coin to merge other coins to
merge_from (Union[list[Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]], SuiArray]) – One or more coins to merge to primary ‘merge_to’ coin
- Returns:
The command result. Can not be used as input in subsequent commands.
- Return type:
- public_transfer_object(*, object_to_send: str | ObjectID | ObjectRead | SuiCoinObject | Argument, recipient: SuiAddress, object_type: str) Argument
public_transfer_object Public transfer of any object.
- Parameters:
object_to_send (Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]) – Object being transferred
recipient (SuiAddress) – Address for recipient of object_to_send
object_type (str) – Type arguments
- Returns:
Result of command which is non-reusable
- Return type:
- transfer_objects(*, transfers: list[str | ObjectID | ObjectRead | SuiCoinObject | Argument] | SuiArray, recipient: ObjectID | SuiAddress) Argument
transfer_objects Transfers one or more objects to a recipient.
- Parameters:
transfers (Union[list[Union[str, ObjectID, ObjectRead, SuiCoinObject, bcs.Argument]], SuiArray]) – A list or SuiArray of objects to transfer
recipient (Union[ObjectID, SuiAddress]) – The recipient address that will receive the objects being transfered
- Returns:
The command result. Can NOT be used as input in subsequent commands.
- Return type:
- transfer_sui(*, recipient: ObjectID | SuiAddress, from_coin: str | ObjectID | ObjectRead | SuiCoinObject | Argument, amount: int | SuiInteger | None = None) Argument
transfer_sui Transfers a Sui coin object to a recipient.
- Parameters:
recipient (Union[ObjectID, SuiAddress]) – The recipient address that will receive the Sui coin being transfered
from_coin (Union[str, ObjectID, ObjectRead, SuiCoinObject]) – The Sui coin to transfer
amount (Optional[Union[int, SuiInteger]], optional) – Optional amount to transfer. Entire coin if not specified, defaults to None
- Raises:
ValueError – If unable to fetch the from_coin
ValueError – If from_coin is invalid
- Returns:
The command result. Can NOT be used as input in subsequent commands.
- Return type:
pysui.sui.sui_txn.transaction module
Sui high level Transaction Builder supports generation of TransactionKind and TransactionData.
pysui.sui.sui_txn.transaction_builder module
Sui low level Transaction Builder supports generation of TransactionKind.
- pysui.sui.sui_txn.transaction_builder.serialize_uint32_as_uleb128(cls, value: int) bytes
.
- class pysui.sui.sui_txn.transaction_builder.PureInput
Bases:
object
Pure inputs processing.
Changed in version 0.18.0: Support for lists and unsigned ints
Changed in version 0.17.0: Support bool arguments
- pure(arg)
Template dispatch method.
- classmethod as_input(args) BuilderArg
Convert scalars and ObjectIDs to a Pure BuilderArg.
- class pysui.sui.sui_txn.transaction_builder.ProgrammableTransactionBuilder(*, compress_inputs: bool = False)
Bases:
object
ProgrammableTransactionBuilder core transaction construction.
Changed in version 0.31.0: Added command type frequency
- __init__(*, compress_inputs: bool = False) None
Builder initializer.
- finish_for_inspect() TransactionKind
finish_for_inspect returns TransactionKind structure.
For inspection, serializing this return and converting to base64 is enough for sui_devInspectTransaction
- Returns:
The resulting TransactionKind structure
- Return type:
- input_pure(key: BuilderArg) Argument
input_pure registers a pure input argument in the inputs collection.
- Parameters:
key (bcs.BuilderArg) – Becomes the ‘key’ in the inputs dictionary cotaining the input index
- Raises:
ValueError – If the key arg BuilderArg is not “Pure” variant
- Returns:
The input Argument encapsulating it’s input index
- Return type:
Changed in version 0.30.2: Remove reuse of identical pure inputs
Changed in version 0.20.0: Check for duplication. See bug #99
- input_obj(key: BuilderArg, object_arg: ObjectArg) Argument
.
Changed in version 0.20.0: Check for duplication. See bug #99
- input_obj_from_objarg(object_arg: ObjectArg) Argument
.
New in version 0.54.0: Support stand-alone ObjectArg
- command(command_obj: Command, nresults: int = 1) Argument | list[Argument]
command adds a new command to the list of commands.
- Parameters:
command_obj (bcs.Command) – The Command type
- Returns:
A result argument to be potentially used in other commands
- Return type:
- make_move_vector(vtype: OptionalTypeTag, items: list[Argument | BuilderArg | ObjectArg | tuple[BuilderArg, ObjectArg]]) Argument
Create a call to convert a list of items to a Sui ‘vector’ type.
Changed in version 0.54.0: Accept bcs.ObjectArg(s) support GraphQL implementation.
- move_call(*, target: Address, arguments: list[Argument | ObjectArg | Optional | tuple[BuilderArg, ObjectArg]], type_arguments: list[TypeTag], module: str, function: str, res_count: int = 1) Argument | list[Argument]
Setup a MoveCall command and return it’s result Argument.
Changed in version 0.17.0: Add result count for correct arg return.
- split_coin(from_coin: Argument | ObjectArg | tuple[BuilderArg, ObjectArg], amounts: list[BuilderArg]) Argument
Setup a SplitCoin command and return it’s result Argument.
Changed in version 0.54.0: Accept bcs.ObjectArg support GraphQL implementation.
Changed in version 0.33.0: Accept bcs.Argument (i.e. Result) as amount
Changed in version 0.17.0: Extend to take list of amounts
- merge_coins(to_coin: Argument | ObjectArg | tuple[BuilderArg, ObjectArg], from_coins: list[Argument | ObjectArg | tuple[BuilderArg, ObjectArg]]) Argument
Setup a MergeCoins command and return it’s result Argument.
Changed in version 0.54.0: Accept bcs.ObjectArg(s) support GraphQL implementation.
- transfer_objects(recipient: BuilderArg, object_ref: Argument | list[Argument | ObjectArg | tuple[BuilderArg, ObjectArg]]) Argument
Setup a TransferObjects command and return it’s result Argument.
- transfer_sui(recipient: BuilderArg, from_coin: Argument | tuple[BuilderArg, ObjectArg], amount: BuilderArg | Optional | None = None) Argument
Setup a TransferObjects for Sui Coins.
First uses the SplitCoins result, then returns the TransferObjects result Argument.
- publish(modules: list[list[Uint8]], dep_ids: list[Address]) Argument
Setup a Publish command and return it’s result Argument.
Changed in version 0.20.0: Removed UpgradeCap auto transfer as per Sui best practices.
- authorize_upgrade(upgrade_cap: ObjectArg | tuple[BuilderArg, ObjectArg], policy: BuilderArg, digest: BuilderArg) Argument
Setup a Authorize Upgrade MoveCall and return it’s result Argument.
pysui.sui.sui_txn.txn_deser module
SuiTransaction Serialize/Deserialize model.
- pysui.sui.sui_txn.txn_deser.ser_sender_and_sponsor(signer_block: SignerBlock, config: SuiConfig) tuple[TxSender, TxSender]
Serialize sender and/or sponsor.
- pysui.sui.sui_txn.txn_deser.ser_transaction_builder(builder: ProgrammableTransactionBuilder) TxTransaction
Serialize the transaction builder data.
- pysui.sui.sui_txn.txn_deser.deser_sender_and_sponsor(sender: TxSender, sponsor: TxSender, config: SuiConfig) SignerBlock
.
- pysui.sui.sui_txn.txn_deser.deser_transaction_builder(tx_builder: TxTransaction, builder: ProgrammableTransactionBuilder, config: SuiConfig)
.
Module contents
Sui Transactions (sync, async) package.