Skip to content

API Reference

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
}
}

function getSpendingAccount(wallet: Application): Account

Returns the spending account (the rekeyed address) from the ARC-58 wallet. Use this as the sender for all inner transactions your plugin submits.

function getOriginAccount(wallet: Application): Account

Returns 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.

function getReferrerAccount(wallet: Application): Account

Returns the referrer account associated with the wallet, or the zero address if no referrer is set.

function getAccounts(wallet: Application): Arc58Accounts

Returns all relevant accounts from the wallet in a single call. Use this when your plugin needs multiple account references.

Returns:

FieldTypeDescription
walletAddressAccountThe wallet’s application address
originAccountThe real user who owns the wallet
senderAccountThe spending account (rekeyed to plugin)
referrerAccountThe referrer account
function rekeyAddress(rekeyBack: boolean, wallet: Application): Account

Returns 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)
function rekeyBackIfNecessary(rekeyBack: boolean, wallet: Application): void

Returns 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.

function controls(sender: Account): boolean

Authorization 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.


type Arc58Accounts = {
walletAddress: Account
origin: Account
sender: Account
referrer: Account
}

Returned by getAccounts(). Contains all account references from an ARC-58 wallet.

type Arc58PluginCallContext = {
wallet: Application
rekeyBack: boolean
}

Convenience type representing the two required parameters every plugin method must accept.


ARC-58 global state keys used to read wallet state. These match the keys defined in the AbstractedAccount contract.

ConstantValueDescription
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'