transaction

class Transaction(sender, fee, first, last, note, gen, gh, lease, txn_type, rekey_to)

Bases: object

Superclass for various transaction types.

get_txid()

Get the transaction’s ID.

Returns:transaction ID
Return type:str
sign(private_key)

Sign the transaction with a private key.

Parameters:private_key (str) – the private key of the signing account
Returns:signed transaction with the signature
Return type:SignedTransaction
raw_sign(private_key)

Sign the transaction.

Parameters:private_key (str) – the private key of the signing account
Returns:signature
Return type:bytes
estimate_size()
dictify()
static undictify(d)
class PaymentTxn(sender, fee, first, last, gh, receiver, amt, close_remainder_to=None, note=None, gen=None, flat_fee=False, lease=None, rekey_to=None)

Bases: algosdk.transaction.Transaction

Represents a payment transaction.

Parameters:
  • sender (str) – address of the sender
  • fee (int) – transaction fee (per byte if flat_fee is false)
  • first (int) – first round for which the transaction is valid
  • last (int) – last round for which the transaction is valid
  • gh (str) – genesis_hash
  • receiver (str) – address of the receiver
  • amt (int) – amount in microAlgos to be sent
  • close_remainder_to (str, optional) – if nonempty, account will be closed and remaining algos will be sent to this address
  • note (bytes, optional) – arbitrary optional bytes
  • gen (str, optional) – genesis_id
  • flat_fee (bool, optional) – whether the specified fee is a flat fee
  • 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
sender
Type:str
fee
Type:int
first_valid_round
Type:int
last_valid_round
Type:int
note
Type:bytes
genesis_id
Type:str
genesis_hash
Type:str
group
Type:bytes
receiver
Type:str
amt
Type:int
close_remainder_to
Type:str
type
Type:str
lease
Type:byte[32]
rekey_to
Type:str
dictify()
class KeyregTxn(sender, fee, first, last, gh, votekey, selkey, votefst, votelst, votekd, note=None, gen=None, flat_fee=False, lease=None, rekey_to=None)

Bases: algosdk.transaction.Transaction

Represents a key registration transaction.

Parameters:
  • sender (str) – address of sender
  • fee (int) – transaction fee (per byte if flat_fee is false)
  • first (int) – first round for which the transaction is valid
  • last (int) – last round for which the transaction is valid
  • gh (str) – genesis_hash
  • votekey (str) – participation public key
  • selkey (str) – VRF public key
  • votefst (int) – first round to vote
  • votelst (int) – last round to vote
  • votekd (int) – vote key dilution
  • note (bytes, optional) – arbitrary optional bytes
  • gen (str, optional) – genesis_id
  • flat_fee (bool, optional) – whether the specified fee is a flat fee
  • 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
sender
Type:str
fee
Type:int
first_valid_round
Type:int
last_valid_round
Type:int
note
Type:bytes
genesis_id
Type:str
genesis_hash
Type:str
group
Type:bytes
votepk
Type:str
selkey
Type:str
votefst
Type:int
votelst
Type:int
votekd
Type:int
type
Type:str
lease
Type:byte[32]
rekey_to
Type:str
dictify()
class AssetConfigTxn(sender, fee, first, last, gh, index=None, total=None, default_frozen=None, unit_name=None, asset_name=None, manager=None, reserve=None, freeze=None, clawback=None, url=None, metadata_hash=None, note=None, gen=None, flat_fee=False, lease=None, strict_empty_address_check=True, decimals=0, rekey_to=None)

Bases: algosdk.transaction.Transaction

Represents a transaction for asset creation, reconfiguration, or destruction.

To create an asset, include the following:
total, default_frozen, unit_name, asset_name, manager, reserve, freeze, clawback, url, metadata, decimals
To destroy an asset, include the following:
index, strict_empty_address_check (set to False)
To update asset configuration, include the following:
index, manager, reserve, freeze, clawback, strict_empty_address_check (optional)
Parameters:
  • sender (str) – address of the sender
  • fee (int) – transaction fee (per byte if flat_fee is false)
  • first (int) – first round for which the transaction is valid
  • last (int) – last round for which the transaction is valid
  • gh (str) – genesis_hash
  • index (int, optional) – index of the asset
  • total (int, optional) – total number of base units of this asset created
  • default_frozen (bool, optional) – whether slots for this asset in user accounts are frozen by default
  • unit_name (str, optional) – hint for the name of a unit of this asset
  • asset_name (str, optional) – hint for the name of the asset
  • manager (str, optional) – address allowed to change nonzero addresses for this asset
  • reserve (str, optional) – account whose holdings of this asset should be reported as “not minted”
  • freeze (str, optional) – account allowed to change frozen state of holdings of this asset
  • clawback (str, optional) – account allowed take units of this asset from any account
  • url (str, optional) – a URL where more information about the asset can be retrieved
  • metadata_hash (byte[32], optional) – a commitment to some unspecified asset metadata (32 byte hash)
  • note (bytes, optional) – arbitrary optional bytes
  • gen (str, optional) – genesis_id
  • flat_fee (bool, optional) – whether the specified fee is a flat fee
  • 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
  • strict_empty_address_check (bool, optional) – set this to False if you want to specify empty addresses. Otherwise, if this is left as True (the default), having empty addresses will raise an error, which will prevent accidentally removing admin access to assets or deleting the asset.
  • decimals (int, optional) – number of digits to use for display after decimal. If set to 0, the asset is not divisible. If set to 1, the base unit of the asset is in tenths. Must be between 0 and 19, inclusive. Defaults to 0.
  • rekey_to (str, optional) – additionally rekey the sender to this address
sender
Type:str
fee
Type:int
first_valid_round
Type:int
last_valid_round
Type:int
genesis_hash
Type:str
index
Type:int
total
Type:int
default_frozen
Type:bool
unit_name
Type:str
asset_name
Type:str
manager
Type:str
reserve
Type:str
freeze
Type:str
clawback
Type:str
url
Type:str
metadata_hash
Type:byte[32]
note
Type:bytes
genesis_id
Type:str
type
Type:str
lease
Type:byte[32]
decimals
Type:int
rekey_to
Type:str
dictify()
class AssetFreezeTxn(sender, fee, first, last, gh, index, target, new_freeze_state, note=None, gen=None, flat_fee=False, lease=None, rekey_to=None)

Bases: algosdk.transaction.Transaction

Represents a transaction for freezing or unfreezing an account’s asset holdings. Must be issued by the asset’s freeze manager.

Parameters:
  • sender (str) – address of the sender, who must be the asset’s freeze manager
  • fee (int) – transaction fee (per byte if flat_fee is false)
  • first (int) – first round for which the transaction is valid
  • last (int) – last round for which the transaction is valid
  • gh (str) – genesis_hash
  • index (int) – index of the asset
  • target (str) – address having its assets frozen or unfrozen
  • new_freeze_state (bool) – true if the assets should be frozen, false if they should be transferrable
  • note (bytes, optional) – arbitrary optional bytes
  • gen (str, optional) – genesis_id
  • flat_fee (bool, optional) – whether the specified fee is a flat fee
  • 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
sender
Type:str
fee
Type:int
first_valid_round
Type:int
last_valid_round
Type:int
genesis_hash
Type:str
index
Type:int
target
Type:str
new_freeze_state
Type:bool
note
Type:bytes
genesis_id
Type:str
type
Type:str
lease
Type:byte[32]
rekey_to
Type:str
dictify()
class AssetTransferTxn(sender, fee, first, last, gh, receiver, amt, index, close_assets_to=None, revocation_target=None, note=None, gen=None, flat_fee=False, lease=None, rekey_to=None)

Bases: algosdk.transaction.Transaction

Represents a transaction for asset transfer. To begin accepting an asset, supply the same address as both sender and receiver, and set amount to 0. To revoke an asset, set revocation_target, and issue the transaction from the asset’s revocation manager account.

Parameters:
  • sender (str) – address of the sender
  • fee (int) – transaction fee (per byte if flat_fee is false)
  • first (int) – first round for which the transaction is valid
  • last (int) – last round for which the transaction is valid
  • gh (str) – genesis_hash
  • receiver (str) – address of the receiver
  • amt (int) – amount of asset base units to send
  • index (int) – index of the asset
  • close_assets_to (string, optional) – send all of sender’s remaining assets, after paying amt to receiver, to this address
  • revocation_target (string, optional) – send assets from this address, rather than the sender’s address (can only be used by an asset’s revocation manager, also known as clawback)
  • note (bytes, optional) – arbitrary optional bytes
  • gen (str, optional) – genesis_id
  • flat_fee (bool, optional) – whether the specified fee is a flat fee
  • 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
sender
Type:str
fee
Type:int
first_valid_round
Type:int
last_valid_round
Type:int
genesis_hash
Type:str
index
Type:int
amount
Type:int
receiver
Type:string
close_assets_to
Type:string
revocation_target
Type:string
note
Type:bytes
genesis_id
Type:str
type
Type:str
lease
Type:byte[32]
rekey_to
Type:str
dictify()
class SignedTransaction(transaction, signature, authorizing_address=None)

Bases: object

Represents a signed transaction.

Parameters:
  • transaction (Transaction) – transaction that was signed
  • signature (str) – signature of a single address
  • authorizing_address (str, optional) – the address authorizing the signed transaction, if different from sender
transaction
Type:Transaction
signature
Type:str
authorizing_address
Type:str
dictify()
static undictify(d)
class MultisigTransaction(transaction, multisig)

Bases: object

Represents a signed transaction.

Parameters:
  • transaction (Transaction) – transaction that was signed
  • multisig (Multisig) – multisig account and signatures
transaction
Type:Transaction
multisig
Type:Multisig
sign(private_key)

Sign the multisig transaction.

Parameters:private_key (str) – private key of signing account

Note

A new signature will replace the old if there is already a signature for the address. To sign another transaction, you can either overwrite the signatures in the current Multisig, or you can use Multisig.get_multisig_account() to get a new multisig object with the same addresses.

dictify()
static undictify(d)
static merge(part_stxs)

Merge partially signed multisig transactions.

Parameters:part_stxs (MultisigTransaction[]) – list of partially signed multisig transactions
Returns:multisig transaction containing signatures
Return type:MultisigTransaction

Note

Only use this if you are given two partially signed multisig transactions. To append a signature to a multisig transaction, just use MultisigTransaction.sign()

class Multisig(version, threshold, addresses)

Bases: object

Represents a multisig account and signatures.

Parameters:
  • version (int) – currently, the version is 1
  • threshold (int) – how many signatures are necessary
  • addresses (str[]) – addresses in the multisig account
version
Type:int
threshold
Type:int
subsigs
Type:MultisigSubsig[]
validate()

Check if the multisig account is valid.

address()

Return the multisig account address.

verify(message)

Verify that the multisig is valid for the message.

dictify()
json_dictify()
static undictify(d)
get_multisig_account()

Return a Multisig object without signatures.

get_public_keys()

Return the base32 encoded addresses for the multisig account.

class MultisigSubsig(public_key, signature=None)

Bases: object

public_key
Type:bytes
signature
Type:bytes
dictify()
json_dictify()
static undictify(d)
class LogicSig(program, args=None)

Bases: object

Represents a logic signature.

Parameters:
  • logic (bytes) – compiled program
  • args (list[bytes]) – args are not signed, but are checked by logic
logic
Type:bytes
sig
Type:bytes
msig
Type:Multisig
args
Type:list[bytes]
dictify()
static undictify(d)
verify(public_key)

Verifies LogicSig against the transaction’s sender address

Parameters:public_key (bytes) – sender address
Returns:true if the signature is valid (the sender address matches the logic hash or the signature is valid against the sender address), false otherwise
Return type:bool
address()

Compute hash of the logic sig program (that is the same as escrow account address) as string address

Returns:program address
Return type:str
static sign_program(program, private_key)
static single_sig_multisig(program, private_key, multisig)
sign(private_key, multisig=None)

Creates signature (if no pk provided) or multi signature

Parameters:
  • private_key (str) – private key of signing account
  • multisig (Multisig) – optional multisig account without signatures to sign with
Raises:

InvalidSecretKeyError – if no matching private key in multisig object

append_to_multisig(private_key)

Appends a signature to multi signature

Parameters:private_key (str) – private key of signing account
Raises:InvalidSecretKeyError – if no matching private key in multisig object
class LogicSigTransaction(transaction, lsig)

Bases: object

Represents a logic signed transaction.

Parameters:
transaction
Type:Transaction
lsig
Type:LogicSig
verify()

Verify LogicSig against the transaction

Returns:true if the signature is valid (the sender address matches the logic hash or the signature is valid against the sender address), false otherwise
Return type:bool
dictify()
static undictify(d)
write_to_file(objs, path, overwrite=True)

Write signed or unsigned transactions to a file.

Parameters:
  • txns (Transaction[], SignedTransaction[], or MultisigTransaction[]) – can be a mix of the three
  • path (str) – file to write to
  • overwrite (bool) – whether or not to overwrite what’s already in the file; if False, transactions will be appended to the file
Returns:

true if the transactions have been written to the file

Return type:

bool

retrieve_from_file(path)

Retrieve encoded objects from a file.

Parameters:path (str) – file to read from
Returns:list of objects
Return type:Object[]
class TxGroup(txns)

Bases: object

dictify()
static undictify(d)
calculate_group_id(txns)

Calculate group id for a given list of unsigned transactions

Parameters:txns (list) – list of unsigned transactions
Returns:checksum value representing the group id
Return type:bytes
assign_group_id(txns, address=None)

Assign group id to a given list of unsigned transactions.

Parameters:
  • txns (list) – list of unsigned transactions
  • address (str) – optional sender address specifying which transaction to return
Returns:

list of unsigned transactions with group property set

Return type:

txns (list)