Transactions
Low-level transaction construction and signing.
Examples (14)
Section titled “Examples (14)”| Example | Description |
|---|---|
| Payment Transaction | This example demonstrates how to send ALGO between accounts using the transact package. It shows the low-level transaction construction pattern with:
|
| Payment with Close | This example demonstrates how to close an account by transferring all remaining ALGO to another account using the closeRemainderTo field in PaymentTransactionFields. Key concepts:
|
| Asset Create | This example demonstrates how to create a new Algorand Standard Asset (ASA) using the transact package. It shows the low-level transaction construction pattern with:
|
| Asset Transfer | This example demonstrates the full asset transfer flow using the transact package: 1. Create a new Algorand Standard Asset (ASA) 2. Opt-in: receiver sends 0 amount of the asset to themselves 3. Transfer assets from creator to the opted-in receiver 4. Verify receiver’s asset balance after transfer Uses Transaction class with TransactionType.AssetTransfer and AssetTransferTransactionFields. |
| Asset Freeze | This example demonstrates how to freeze and unfreeze asset holdings using the transact package: 1. Create an asset with freeze address set 2. Transfer assets to another account 3. Freeze the account’s asset holdings (prevent transfers) 4. Verify frozen account cannot transfer 5. Unfreeze the account’s asset holdings 6. Verify account can transfer after unfreeze Uses Transaction class with TransactionType.AssetFreeze and AssetFreezeTransactionFields. |
| Asset Clawback | This example demonstrates how to clawback assets from an account using the clawback address and the transact package: 1. Create an asset with clawback address set 2. Transfer assets to a target account 3. Clawback assets from target account using assetSender field 4. Verify target account balance decreased 5. Verify clawback receiver received the assets Uses Transaction class with TransactionType.AssetTransfer and the assetSender field in AssetTransferTransactionFields for clawback operations. |
| Atomic Transaction Group | This example demonstrates how to group multiple transactions atomically. All transactions in a group either succeed together or fail together. It shows:
|
| Atomic Swap | This example demonstrates how to perform an atomic swap of ALGO for ASA between two parties. In an atomic swap:
Key difference from regular atomic groups: different parties sign different transactions. |
| Single Signature | This example demonstrates how to create an ed25519 keypair and sign transactions using the low-level transact package APIs. Key concepts:
|
| Multisig | This example demonstrates how to create and use a 2-of-3 multisig account. Key concepts:
|
| Logic Signature | This example demonstrates how to use a logic signature (lsig) to authorize transactions. Key concepts:
Logic signatures allow transactions to be authorized by a program instead of (or in addition to) a cryptographic signature. This enables smart contracts that can hold and send funds based purely on program logic. |
| Fee Calculation | This example demonstrates how to estimate transaction size and calculate fees using the transact package:
|
| Encoding/Decoding | This example demonstrates how to serialize and deserialize transactions using the transact package:
|
| Application Call | This example demonstrates how to deploy and interact with a smart contract on Algorand using the transact package:
globalStateSchema, and localStateSchema
|
Quick Start
Section titled “Quick Start”Run any example from the repository’s examples directory:
cd examplesnpm run example transact/01-*.ts