API Reference
Plugin (Base Class)
Section titled “Plugin (Base Class)”import { Plugin } from '@akta/plugin'Base contract class for ARC-58 plugins. Extends Contract from @algorandfoundation/algorand-typescript/arc4.
All plugin contracts should extend this class. It serves as a marker and provides the correct base for ARC-4 ABI compatibility.
export class MyPlugin extends Plugin { myMethod(wallet: Application, rekeyBack: boolean, ...args): void { // Plugin logic }}Utility Functions
Section titled “Utility Functions”getSpendingAccount
Section titled “getSpendingAccount”function getSpendingAccount(wallet: Application): AccountReturns the spending account (the rekeyed address) from the ARC-58 wallet. Use this as the sender for all inner transactions your plugin submits.
getOriginAccount
Section titled “getOriginAccount”function getOriginAccount(wallet: Application): AccountReturns the origin account — the real user who owns the ARC-58 wallet. Useful for gated operations that need to verify the wallet owner’s identity or holdings.
getReferrerAccount
Section titled “getReferrerAccount”function getReferrerAccount(wallet: Application): AccountReturns the referrer account associated with the wallet, or the zero address if no referrer is set.
getAccounts
Section titled “getAccounts”function getAccounts(wallet: Application): Arc58AccountsReturns all relevant accounts from the wallet in a single call. Use this when your plugin needs multiple account references.
Returns:
| Field | Type | Description |
|---|---|---|
walletAddress | Account | The wallet’s application address |
origin | Account | The real user who owns the wallet |
sender | Account | The spending account (rekeyed to plugin) |
referrer | Account | The referrer account |
rekeyAddress
Section titled “rekeyAddress”function rekeyAddress(rekeyBack: boolean, wallet: Application): AccountReturns the address to use in the rekeyTo field of your last inner transaction.
rekeyBack: true— returns the wallet address (rekeys control back)rekeyBack: false— returns the zero address (allows plugin chaining)
rekeyBackIfNecessary
Section titled “rekeyBackIfNecessary”function rekeyBackIfNecessary(rekeyBack: boolean, wallet: Application): voidReturns control of the spending account to the wallet when rekeyBack is true by submitting a minimal payment with the rekey. Use this when your plugin’s operation doesn’t naturally include an inner transaction to attach the rekey to (e.g., box writes or state updates only). If your plugin already submits inner transactions, attach the rekey to the last one via rekeyAddress() instead.
Only submits the transaction when rekeyBack is true. Does nothing when false.
controls
Section titled “controls”function controls(sender: Account): booleanAuthorization check that verifies the given account’s auth address matches the current application (your plugin). Plugins that submit inner transactions are naturally authorized — the transaction will fail if the plugin doesn’t control the account. But for operations without inner transactions, getSpendingAccount(wallet) alone isn’t trustworthy since wallet is just an argument. Use controls() to confirm the spending account was genuinely delegated to your plugin.
Arc58Accounts
Section titled “Arc58Accounts”type Arc58Accounts = { walletAddress: Account origin: Account sender: Account referrer: Account}Returned by getAccounts(). Contains all account references from an ARC-58 wallet.
Arc58PluginCallContext
Section titled “Arc58PluginCallContext”type Arc58PluginCallContext = { wallet: Application rekeyBack: boolean}Convenience type representing the two required parameters every plugin method must accept.
Constants
Section titled “Constants”ARC-58 global state keys used to read wallet state. These match the keys defined in the AbstractedAccount contract.
| Constant | Value | Description |
|---|---|---|
ARC58_CONTROLLED_ADDRESS_KEY | 'controlled_address' | The address controlled by the wallet |
ARC58_SPENDING_ADDRESS_KEY | 'spending_address' | The current spending address |
ARC58_REFERRER_KEY | 'referrer' | The referrer address |
ARC58_CURRENT_PLUGIN_KEY | 'current_plugin' | The currently active plugin |
ARC58_REKEY_INDEX_KEY | 'rekey_index' | Rekey nonce for replay protection |
import { ARC58_CONTROLLED_ADDRESS_KEY, ARC58_SPENDING_ADDRESS_KEY, ARC58_REFERRER_KEY, ARC58_CURRENT_PLUGIN_KEY, ARC58_REKEY_INDEX_KEY,} from '@akta/plugin'