Skip to content

fix: update group txn example to exclude setup code #47

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Mar 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@


def atomic_transaction_groups() -> None:
# example: ATOMIC_TRANSACTION_GROUP

algorand_client, dispenser, account_a, account_b, account_c = (
setup_localnet_environment()
)

# example: ATOMIC_TRANSACTION_GROUP
"""
Create a transaction group that will execute atomically
Either all transactions succeed, or they all fail
Expand All @@ -31,7 +30,6 @@ def atomic_transaction_groups() -> None:
note=b"Second payment in atomic group",
)
).send() # Send the atomic group of transactions

# example: ATOMIC_TRANSACTION_GROUP

# example: ATOMIC_GROUP_SIMULATE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ async function AccountReferenceExampleMethod3() {
const { referenceAccountAppClient, referenceAccount } = await setupLocalnetEnvironment()

// example: ACCOUNT_REFERENCE_EXAMPLE_METHOD_3
// Include the account reference in the accountReferences array to be populated
// Include the account reference in the accountReferences array to be populated manually
const result = await referenceAccountAppClient.send.getAccountBalance({
args: {},
accountReferences: [referenceAccount],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,11 @@ import type { uint64 } from '@algorandfoundation/algorand-typescript'
export default class InnerTransactions extends Contract {
// example: PAYMENT
/**
* Demonstrates a simple payment inner transaction
* Demonstrates a simple payment inner transaction.
* The fee is set to 0 by default. Manually set here for demonstration purposes.
* The `Sender` for the payment is implied to be Global.currentApplicationAddress.
* If a different sender is needed, it'd have to be an account that has been
* rekeyed to the application address.
* @returns The amount of the payment
*/
@abimethod()
Expand All @@ -34,14 +38,6 @@ export default class InnerTransactions extends Contract {

return result.amount
}

/**
* fee is set to 0 by default. Manually set here for demonstration purposes.
* The `Sender` for the above is implied to be Global.currentApplicationAddress.
*
* If a different sender is needed, it'd have to be an account that has been
* rekeyed to the application address.
*/
// example: PAYMENT

// example: ASSET_CREATE
Expand All @@ -64,10 +60,12 @@ export default class InnerTransactions extends Contract {
}

/**
* Creates a non-fungible asset (NFT)
* Creates a non-fungible asset (NFT).
* Following the ARC3 standard, the total supply must be 1 for a non-fungible asset.
* If you want to create fractional NFTs, `total` * `decimals` point must be 1.
* ex) total=100, decimals=2, 100 * 0.01 = 1
* The fee is set to 0 by default for inner transactions.
* The Sender is implied to be Global.currentApplicationAddress.
* @returns The ID of the created asset
*/
@abimethod()
Expand All @@ -93,7 +91,10 @@ export default class InnerTransactions extends Contract {

// example: ASSET_OPT_IN
/**
* Opts the application into an asset
* Opts the application into an asset.
* A zero amount asset transfer to one's self is a special type of asset transfer
* that is used to opt-in to an asset.
* To send an asset transfer, the asset must be an available resource.
* @param asset The asset to opt into
*/
@abimethod()
Expand All @@ -107,19 +108,14 @@ export default class InnerTransactions extends Contract {
})
.submit()
}

/**
* A zero amount asset transfer to one's self is a special type of asset transfer
* that is used to opt-in to an asset.
*
* To send an asset transfer, the asset must be an available resource.
* Refer the Resource Availability section for more information.
*/
// example: ASSET_OPT_IN

// example: ASSET_TRANSFER
/**
* Transfers an asset from the application to another account
* Transfers an asset from the application to another account.
* For a smart contract to transfer an asset, the app account must be opted into the asset
* and be holding non zero amount of assets.
* To send an asset transfer, the asset must be an available resource.
* @param asset The asset to transfer
* @param receiver The account to receive the asset
* @param amount The amount to transfer
Expand All @@ -136,18 +132,13 @@ export default class InnerTransactions extends Contract {
.submit()
}

/**
* For a smart contract to transfer an asset, the app account must be opted into the asset
* and be holding non zero amount of assets.
*
* To send an asset transfer, the asset must be an available resource.
* Refer the Resource Availability section for more information.
*/
// example: ASSET_TRANSFER

// example: ASSET_FREEZE
/**
* Freezes an asset for a specific account
* Freezes an asset for a specific account.
* To freeze an asset, the asset must be a freezable asset
* by having an account with freeze authority.
* @param acctToBeFrozen The account to freeze the asset for
* @param asset The asset to freeze
*/
Expand All @@ -162,16 +153,14 @@ export default class InnerTransactions extends Contract {
})
.submit()
}

/**
* To freeze an asset, the asset must be a freezable asset
* by having an account with freeze authority.
*/
// example: ASSET_FREEZE

// example: ASSET_REVOKE
/**
* Revokes (clawbacks) an asset from an account
* Revokes (clawbacks) an asset from an account.
* To revoke an asset, the asset must be a revocable asset
* by having an account with clawback authority.
* The Sender is implied to be current_application_address.
* @param asset The asset to revoke
* @param accountToBeRevoked The account to revoke the asset from
* @param amount The amount to revoke
Expand All @@ -188,18 +177,15 @@ export default class InnerTransactions extends Contract {
})
.submit()
}

/**
* To revoke an asset, the asset must be a revocable asset
* by having an account with clawback authority.
*
* Sender is implied to be current_application_address
*/
// example: ASSET_REVOKE

// example: ASSET_CONFIG
/**
* Reconfigures an existing asset
* Reconfigures an existing asset.
* For a smart contract to transfer an asset, the app account must be opted into the asset
* and be holding non zero amount of assets.
* To send an asset transfer, the asset must be an available resource.
* Refer the Resource Availability section for more information.
* @param asset The asset to reconfigure
*/
@abimethod()
Expand All @@ -215,19 +201,14 @@ export default class InnerTransactions extends Contract {
})
.submit()
}

/**
* For a smart contract to transfer an asset, the app account must be opted into the asset
* and be holding non zero amount of assets.
*
* To send an asset transfer, the asset must be an available resource.
* Refer the Resource Availability section for more information.
*/
// example: ASSET_CONFIG

// example: ASSET_DELETE
/**
* Deletes an asset
* Deletes an asset.
* To delete an asset, the asset must be a deleteable asset
* by having an account with delete authority.
* The Sender is implied to be current_application_address.
* @param asset The asset to delete
*/
@abimethod()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
import type { uint64 } from '@algorandfoundation/algorand-typescript'
import { Address } from '@algorandfoundation/algorand-typescript/arc4'

// example: REFERENCE_ACCOUNT_APP_EXAMPLE
/**
* A contract that maintains a per-account counter in local state
* Accounts must opt in to use the counter
Expand Down Expand Up @@ -87,3 +88,4 @@ export default class ReferenceAccountApp extends Contract {
return value
}
}
// example: REFERENCE_ACCOUNT_APP_EXAMPLE
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { Contract, abimethod, Account, Asset, assert } from '@algorandfoundation/algorand-typescript'
import { Address } from '@algorandfoundation/algorand-typescript/arc4'

// example: REFERENCE_ACCOUNT_ASSET_EXAMPLE
/**
* A contract that demonstrates how to reference both accounts and assets in a smart contract
*/
Expand Down Expand Up @@ -34,3 +35,4 @@ export default class ReferenceAccountAsset extends Contract {
return asset.balance(account)
}
}
// example: REFERENCE_ACCOUNT_ASSET_EXAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
} from '@algorandfoundation/algorand-typescript'
import type { uint64 } from '@algorandfoundation/algorand-typescript'

// example: APP_REFERENCE_EXAMPLE
/**
* A contract that increments a counter
*/
Expand Down Expand Up @@ -75,3 +76,4 @@ export default class ReferenceApp extends Contract {
return arc4.decodeArc4<uint64>(appCallTxn.lastLog, 'log')
}
}
// example: APP_REFERENCE_EXAMPLE
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
} from '@algorandfoundation/algorand-typescript'
import type { uint64 } from '@algorandfoundation/algorand-typescript'

// example: REFERENCE_APP_BOX_EXAMPLE
/**
* A contract that uses box storage to maintain a counter for each account
* Each account needs to pay for the Minimum Balance Requirement (MBR) for their box
Expand Down Expand Up @@ -128,3 +129,4 @@ export default class ReferenceAppBox extends Contract {
this.boxMbr.value = Uint64(2500) + this.boxSize.value * Uint64(400)
}
}
// example: REFERENCE_APP_BOX_EXAMPLE