algosdk.atomic_transaction_composer
Classes
AccountTransactionSigner | Represents a Transaction Signer for an account that can sign transactions from an atomic transaction group. |
---|---|
AtomicTransactionComposer | Constructs an atomic transaction group which may contain a combination of Transactions and ABI Method calls. |
AtomicTransactionComposerStatus | Enum where members are also (and must be) ints |
EmptySigner | Represents an object which can sign transactions from an atomic transaction group. |
LogicSigTransactionSigner | Represents a Transaction Signer for a LogicSig that can sign transactions from an atomic transaction group. |
MultisigTransactionSigner | Represents a Transaction Signer for a Multisig that can sign transactions from an atomic transaction group. |
TransactionSigner | Represents an object which can sign transactions from an atomic transaction group. |
Functions
populate_foreign_array | Add a value to an application call’s foreign array. The addition will be as compact as possible, and this function will return an index used to reference value_to_add in the foreign_array . |
---|
API
class algosdk.atomic_transaction_composer.AccountTransactionSigner
AccountTransactionSigner(private_key: str)
Represents a Transaction Signer for an account that can sign transactions from an atomic transaction group.
Args: private_key (str): private key of signing account
Initialization
sign_transactions
sign_transactions(txn_group: List[algosdk.transaction.Transaction], indexes: List[int]) → List[algosdk.transaction.GenericSignedTransaction]
Sign transactions in a transaction group given the indexes.
Returns an array of encoded signed transactions. The length of the array will be the same as the length of indexesToSign, and each index i in the array corresponds to the signed transaction from txnGroup[indexesToSign[i]].
Args: txn_group (list[Transaction]): atomic group of transactions indexes (list[int]): array of indexes in the atomic transaction group that should be signed
class algosdk.atomic_transaction_composer.AtomicTransactionComposer
AtomicTransactionComposer
Constructs an atomic transaction group which may contain a combination of Transactions and ABI Method calls.
Args: status (AtomicTransactionComposerStatus): IntEnum representing the current state of the composer method_dict (dict): dictionary of an index in the transaction list to a Method object txn_list (list[TransactionWithSigner]): list of transactions with signers signed_txns (list[GenericSignedTransaction]): list of signed transactions tx_ids (list[str]): list of individual transaction IDs in this atomic group
Initialization
add_method_call
add_method_call(app_id: int, method: algosdk.abi.Method, sender: str, sp: algosdk.transaction.SuggestedParams, signer: algosdk.atomic_transaction_composer.TransactionSigner, method_args: Optional[List[Union[Any, algosdk.atomic_transaction_composer.TransactionWithSigner]]] = None, on_complete: algosdk.transaction.OnComplete = transaction.OnComplete.NoOpOC, local_schema: Optional[algosdk.transaction.StateSchema] = None, global_schema: Optional[algosdk.transaction.StateSchema] = None, approval_program: Optional[bytes] = None, clear_program: Optional[bytes] = None, extra_pages: int = 0, accounts: Optional[List[str]] = None, foreign_apps: Optional[List[int]] = None, foreign_assets: Optional[List[int]] = None, note: Optional[bytes] = None, lease: Optional[bytes] = None, rekey_to: Optional[str] = None, boxes: Optional[List[Tuple[int, bytes]]] = None) → algosdk.atomic_transaction_composer.AtomicTransactionComposer
Add a smart contract method call to this atomic group.
An error will be thrown if the composer’s status is not BUILDING, if adding this transaction causes the current group to exceed MAX_GROUP_SIZE, or if the provided arguments are invalid for the given method.
Args: app_id (int): application id of app that the method is being invoked on method (Method): ABI method object with initialized arguments and return types sender (str): address of the sender sp (SuggestedParams): suggested params from algod signer (TransactionSigner): signer that will sign the transactions method_args (list[ABIValue | TransactionWithSigner], optional): list of arguments to be encoded or transactions that immediate precede this method call on_complete (OnComplete, optional): intEnum representing what app should do on completion and if blank, it will default to a NoOp call local_schema (StateSchema, optional): restricts what can be stored by created application; must be omitted if not creating an application global_schema (StateSchema, optional): restricts what can be stored by created application; must be omitted if not creating an application approval_program (bytes, optional): the program to run on transaction approval; must be omitted if not creating or updating an application clear_program (bytes, optional): the program to run when state is being cleared; must be omitted if not creating or updating an application extra_pages (int, optional): additional program space for supporting larger programs. A page is 1024 bytes. accounts (list[string], optional): list of additional accounts involved in call foreign_apps (list[int], optional): list of other applications (identified by index) involved in call foreign_assets (list[int], optional): list of assets involved in call note (bytes, optional): arbitrary optional bytes lease (byte[32], optional): specifies a lease, and no other transaction with the same sender and lease can be confirmed in this transaction’s valid rounds rekey_to (str, optional): additionally rekey the sender to this address boxes (list[(int, bytes)], optional): list of tuples specifying app id and key for boxes the app may access
add_transaction
add_transaction(txn_and_signer: algosdk.atomic_transaction_composer.TransactionWithSigner) → algosdk.atomic_transaction_composer.AtomicTransactionComposer
Adds a transaction to this atomic group.
An error will be thrown if the composer’s status is not BUILDING, or if adding this transaction causes the current group to exceed MAX_GROUP_SIZE.
Args: txn_and_signer (TransactionWithSigner)
build_group
build_group() → List[algosdk.atomic_transaction_composer.TransactionWithSigner]
Finalize the transaction group and returns the finalized transactions with signers. The composer’s status will be at least BUILT after executing this method.
Returns: list[TransactionWithSigner]: list of transactions with signers
clone
clone() → algosdk.atomic_transaction_composer.AtomicTransactionComposer
Creates a new composer with the same underlying transactions. The new composer’s status will be BUILDING, so additional transactions may be added to it.
execute
execute(client: algosdk.v2client.algod.AlgodClient, wait_rounds: int) → algosdk.atomic_transaction_composer.AtomicTransactionResponse
Send the transaction group to the network and wait until it’s committed to a block. An error will be thrown if submission or execution fails. The composer’s status must be SUBMITTED or lower before calling this method, since execution is only allowed once. If submission is successful, this composer’s status will update to SUBMITTED. If the execution is also successful, this composer’s status will update to COMMITTED.
Note: a group can only be submitted again if it fails.
Args: client (AlgodClient): Algod V2 client wait_rounds (int): maximum number of rounds to wait for transaction confirmation
Returns: AtomicTransactionResponse: Object with confirmed round for this transaction, a list of txIDs of the submitted transactions, and an array of results for each method call transaction in this group. If a method has no return value (void), then the method results array will contain None for that method’s return value.
gather_signatures
gather_signatures() → List[algosdk.transaction.GenericSignedTransaction]
Obtain signatures for each transaction in this group. If signatures have already been obtained, this method will return cached versions of the signatures. The composer’s status will be at least SIGNED after executing this method. An error will be thrown if signing any of the transactions fails.
Returns: List[GenericSignedTransaction]: list of signed transactions
get_status
get_status() → algosdk.atomic_transaction_composer.AtomicTransactionComposerStatus
Returns the status of this composer’s transaction group.
get_tx_count
get_tx_count() → int
Returns the number of transactions currently in this atomic group.
simulate
simulate(client: algosdk.v2client.algod.AlgodClient, request: Optional[algosdk.v2client.models.SimulateRequest] = None) → algosdk.atomic_transaction_composer.SimulateAtomicTransactionResponse
Send the transaction group to the simulate
endpoint and wait for results.
An error will be thrown if submission or execution fails.
The composer’s status must be SUBMITTED or lower before calling this method,
since execution is only allowed once.
Args: client (AlgodClient): Algod V2 client request (models.SimulateRequest): SimulateRequest with options in simulation. The request’s transaction group will be overrwritten by the composer’s group, only simulation related options will be used.
Returns: SimulateAtomicTransactionResponse: Object with simulation results for this transaction group, a list of txIDs of the simulated transactions, an array of results for each method call transaction in this group. If a method has no return value (void), then the method results array will contain None for that method’s return value.
submit
submit(client: algosdk.v2client.algod.AlgodClient) → List[str]
Send the transaction group to the network, but don’t wait for it to be committed to a block. An error will be thrown if submission fails. The composer’s status must be SUBMITTED or lower before calling this method. If submission is successful, this composer’s status will update to SUBMITTED.
Note: a group can only be submitted again if it fails.
Args: client (AlgodClient): Algod V2 client
Returns: List[str]: list of submitted transaction IDs
class algosdk.atomic_transaction_composer.AtomicTransactionComposerStatus
AtomicTransactionComposerStatus
Enum where members are also (and must be) ints
Initialization
Initialize self. See help(type(self)) for accurate signature.
__abs__
abs()
abs(self)
__add__
add()
Return self+value.
__and__
and()
Return self&value.
__bool__
bool()
True if self else False
__ceil__
ceil()
Ceiling of an Integral returns itself.
__delattr__
delattr()
Implement delattr(self, name).
__dir__
dir()
Default dir() implementation.
__divmod__
divmod()
Return divmod(self, value).
__eq__
eq()
Return self==value.
__float__
float()
float(self)
__floor__
floor()
Flooring an Integral returns itself.
__floordiv__
floordiv()
Return self//value.
__format__
format()
Convert to a string according to format_spec.
__ge__
ge()
Return self>=value.
__getattribute__
getattribute()
Return getattr(self, name).
__getstate__
getstate()
Helper for pickle.
__gt__
gt()
Return self>value.
__hash__
hash()
Return hash(self).
__index__
index()
Return self converted to an integer, if self is suitable for use as an index into a list.
__int__
int()
int(self)
__invert__
invert()
~self
__le__
le()
Return self<=value.
__lshift__
lshift()
Return self<<value.
__lt__
lt()
Return self<value.
__mod__
mod()
Return self%value.
__mul__
mul()
Return self*value.
__ne__
ne()
Return self!=value.
__neg__
neg()
-self
__new__
new()
Create and return a new object. See help(type) for accurate signature.
__or__
or()
Return self|value.
__pos__
pos()
+self
__pow__
pow()
Return pow(self, value, mod).
__radd__
radd()
Return value+self.
__rand__
rand()
Return value&self.
__rdivmod__
rdivmod()
Return divmod(value, self).
__reduce__
reduce()
Helper for pickle.
__reduce_ex__
reduce_ex()
Helper for pickle.
__repr__
repr()
Return repr(self).
__rfloordiv__
rfloordiv()
Return value//self.
__rlshift__
rlshift()
Return value<<self.
__rmod__
rmod()
Return value%self.
__rmul__
rmul()
Return value*self.
__ror__
ror()
Return value|self.
__round__
round()
Rounding an Integral returns itself.
Rounding with an ndigits argument also returns an integer.
__rpow__
rpow()
Return pow(value, self, mod).
__rrshift__
rrshift()
Return value>>self.
__rshift__
rshift()
Return self>>value.
__rsub__
rsub()
Return value-self.
__rtruediv__
rtruediv()
Return value/self.
__rxor__
rxor()
Return value^self.
__setattr__
setattr()
Implement setattr(self, name, value).
__sizeof__
sizeof()
Returns size in memory, in bytes.
__str__
str()
Return str(self).
__sub__
sub()
Return self-value.
__truediv__
truediv()
Return self/value.
__trunc__
trunc()
Truncating an Integral returns itself.
__xor__
xor()
Return self^value.
as_integer_ratio
as_integer_ratio()
Return a pair of integers, whose ratio is equal to the original int.
The ratio is in lowest terms and has a positive denominator.
(10).as_integer_ratio() (10, 1) (-10).as_integer_ratio() (-10, 1) (0).as_integer_ratio() (0, 1)
bit_count
bit_count()
Number of ones in the binary representation of the absolute value of self.
Also known as the population count.
bin(13) ‘0b1101’ (13).bit_count() 3
bit_length
bit_length()
Number of bits necessary to represent self in binary.
bin(37) ‘0b100101’ (37).bit_length() 6
conjugate
conjugate()
Returns self, the complex conjugate of any int.
class denominator
denominator
the denominator of a rational number in lowest terms
class imag
imag
the imaginary part of a complex number
is_integer
is_integer()
Returns True. Exists for duck type compatibility with float.is_integer.
name
name()
The name of the Enum member.
class numerator
numerator
the numerator of a rational number in lowest terms
class real
real
the real part of a complex number
to_bytes
to_bytes()
Return an array of bytes representing an integer.
length Length of bytes object to use. An OverflowError is raised if the integer is not representable with the given number of bytes. Default is length 1. byteorder The byte order used to represent the integer. If byteorder is ‘big’, the most significant byte is at the beginning of the byte array. If byteorder is ‘little’, the most significant byte is at the end of the byte array. To request the native byte order of the host system, use `sys.byteorder’ as the byte order value. Default is to use ‘big’. signed Determines whether two’s complement is used to represent the integer. If signed is False and a negative integer is given, an OverflowError is raised.
value
value()
The value of the Enum member.
class algosdk.atomic_transaction_composer.EmptySigner
EmptySigner
Represents an object which can sign transactions from an atomic transaction group.
Initialization
class algosdk.atomic_transaction_composer.LogicSigTransactionSigner
LogicSigTransactionSigner(lsig: algosdk.transaction.LogicSigAccount)
Represents a Transaction Signer for a LogicSig that can sign transactions from an atomic transaction group.
Args: lsig (LogicSigAccount): LogicSig account
Initialization
sign_transactions
sign_transactions(txn_group: List[algosdk.transaction.Transaction], indexes: List[int]) → List[algosdk.transaction.GenericSignedTransaction]
Sign transactions in a transaction group given the indexes.
Returns an array of encoded signed transactions. The length of the array will be the same as the length of indexesToSign, and each index i in the array corresponds to the signed transaction from txnGroup[indexesToSign[i]].
Args: txn_group (list[Transaction]): atomic group of transactions indexes (list[int]): array of indexes in the atomic transaction group that should be signed
class algosdk.atomic_transaction_composer.MultisigTransactionSigner
MultisigTransactionSigner(msig: algosdk.transaction.Multisig, sks: List[str])
Represents a Transaction Signer for a Multisig that can sign transactions from an atomic transaction group.
Args: msig (Multisig): Multisig account sks (str): private keys of multisig
Initialization
sign_transactions
sign_transactions(txn_group: List[algosdk.transaction.Transaction], indexes: List[int]) → List[algosdk.transaction.GenericSignedTransaction]
Sign transactions in a transaction group given the indexes.
Returns an array of encoded signed transactions. The length of the array will be the same as the length of indexesToSign, and each index i in the array corresponds to the signed transaction from txnGroup[indexesToSign[i]].
Args: txn_group (list[Transaction]): atomic group of transactions indexes (list[int]): array of indexes in the atomic transaction group that should be signed
class algosdk.atomic_transaction_composer.TransactionSigner
TransactionSigner
Represents an object which can sign transactions from an atomic transaction group.
Initialization
algosdk.atomic_transaction_composer.populate_foreign_array
populate_foreign_array(value_to_add: algosdk.atomic_transaction_composer.T, foreign_array: List[algosdk.atomic_transaction_composer.T], zero_value: Optional[algosdk.atomic_transaction_composer.T] = None) → int
Add a value to an application call’s foreign array. The addition will be as
compact as possible, and this function will return an index used to
reference value_to_add
in the foreign_array
.
Args:
value_to_add: value to add to the array. If the value is already
present, it will not be added again. Instead, the existing index
will be returned.
foreign_array: the existing foreign array. This input may be modified
to append value_to_add
.
zero_value: If provided, this value indicates two things: the 0 value is
reserved for this array so foreign_array
must start at index 1;
additionally, if value_to_add
equals zero_value
, then
value_to_add
will not be added to the array and the 0 index will
be returned.