AlgoKit Task Sign
The AlgoKit Sign feature allows you to sign Algorand transaction(s) using the AlgoKit CLI. This feature supports signing single or multiple transactions, either provided directly as a base64 encoded string or from a binary file.
Usage
Available commands and possible usage as follows:
1$ ~ algokit task sign2Usage: algokit task sign [OPTIONS]3
4Sign goal clerk compatible Algorand transaction(s).5
6Options:7-a, --account TEXT Address or alias of the signer account. [required]8-f, --file PATH Single or multiple message pack encoded transactions from binary file to sign.9-t, --transaction TEXT Single base64 encoded transaction object to sign.10-o, --output PATH The output file path to store signed transaction(s).11--force Force signing without confirmation.12-h, --help Show this message and exit.Options
- --account, -a TEXT: Specifies the address or alias of the signer account. This option is required.
- --file, -f PATH: Specifies the path to a binary file containing single or multiple message pack encoded transactions to sign. Mutually exclusive with- --transactionoption.
- --transaction, -t TEXT: Specifies a single base64 encoded transaction object to sign. Mutually exclusive with- --fileoption.
- --output, -o PATH: Specifies the output file path to store signed transaction(s).
- --force: If specified, it allows signing without interactive confirmation prompt.
Please note,
--transactionflag only supports signing a single transaction. If you want to sign multiple transactions, you can use the--fileflag to specify a binary file containing multiple transactions.
Example
To sign a transaction, you can use the sign command as follows:
1$ algokit task sign --account {YOUR_ACCOUNT_ALIAS OR YOUR_ADDRESS} --file {PATH_TO_BINARY_FILE_CONTAINING_TRANSACTIONS}This will prompt you to confirm the transaction details before signing. If you want to bypass the confirmation, you can use the --force flag:
1$ algokit task sign --account {YOUR_ACCOUNT_ALIAS OR YOUR_ADDRESS} --transaction {YOUR_BASE64_ENCODED_TRANSACTION} --forceIf the transaction is successfully signed, the signed transaction will be output to the console in a JSON format. If you want to write the signed transaction to a file, you can use the --output option:
1$ algokit task sign --account {YOUR_ACCOUNT_ALIAS OR YOUR_ADDRESS} --transaction {YOUR_BASE64_ENCODED_TRANSACTION} --output /path/to/output/fileThis will write the signed transaction to the specified file.
Goal Compatibility
Please note, at the moment this feature only supports goal clerk compatible transaction objects.
When --output option is not specified, the signed transaction(s) will be output to the console in a following JSON format:
1[2  {transaction_id: "TRANSACTION_ID", content: "BASE64_ENCODED_SIGNED_TRANSACTION"},3]On the other hand, when --output option is specified, the signed transaction(s) will be stored to a file as a message pack encoded binary file.
Encoding transactins for signing
Algorand provides a set of options in py-algorand-sdk and js-algorand-sdk to encode transactions for signing.
Encoding simple txn object in python:
1# Encoding single transaction as a base64 encoded string2algosdk.encoding.msgpack_encode({"txn": {YOUR_TXN_OBJECT}.dictify()}) # Resulting string can be passed directly to algokit task sign with --transaction flag3
4# Encoding multiple transactions as a message pack encoded binary file5algosdk.transaction.write_to_file([{YOUR_TXN_OBJECT}], "some_file.txn") # Resulting file path can be passed directly to algokit sign with --file flagEncoding simple txn object in javascript:
1Buffer.from(algosdk.encodeObj({ txn: txn.get_obj_for_encoding() })).toString(2  "base64"3); // Resulting string can be passed directly to algokit task sign with --transaction flagFurther Reading
For in-depth details, visit the sign section in the AlgoKit CLI reference documentation.