Skip to main content

Swig Actions Documentation

This document provides comprehensive documentation for all available Swig Actions, including their inputs, outputs, and usage examples.

Overview

Swig Actions define permissions and spending limits for authorities in the Swig wallet system. Actions are composed using a builder pattern starting with Actions.set() and ending with .get().

Action Categories

1. Root/Management Actions

all()

Grants unlimited permissions for all operations. Inputs: None
Output: Actions instance
Usage:
Permissions Granted:
  • Unlimited SOL and token spending
  • Access to all programs
  • Authority management
  • All other operations

manageAuthority()

Grants permission to manage authorities (add/remove authorities). Inputs: None
Output: Actions instance
Usage:
Permissions Granted:
  • Add new authorities
  • Remove existing authorities

allButManageAuthority()

Grants all permissions except authority management. Inputs: None
Output: Actions instance
Usage:
Permissions Granted:
  • Unlimited SOL and token spending
  • Access to all programs
  • All operations except authority management

2. Program Actions

programLimit(payload)

Grants permission to interact with a specific program. Inputs:
  • payload.programId: SolPublicKeyData - The program ID to allow access to
Output: Actions instance Usage:
Permissions Granted:
  • Execute transactions with the specified program

programAll()

Grants permission to interact with all programs. Inputs: None
Output: Actions instance
Usage:
Permissions Granted:
  • Execute transactions with any program

programCurated()

Grants permission to interact with curated/whitelisted programs. Inputs: None
Output: Actions instance
Usage:
Permissions Granted:
  • Execute transactions with approved/curated programs

programScopeBasic(payload)

Basic program scope with specific target account. Inputs:
  • payload.programId: SolPublicKeyData - Program ID
  • payload.targetAccount: SolPublicKeyData - Target account within the program
Output: Actions instance Usage:
Permissions Granted:
  • Access to specific program with targeted account interactions

programScopeLimit(payload)

Program scope with spending limits. Inputs:
  • payload.programId: SolPublicKeyData - Program ID
  • payload.targetAccount: SolPublicKeyData - Target account
  • payload.amount: bigint - Maximum spendable amount
  • payload.numericType: NumericType - Numeric type (U8, U32, U64, U128)
Output: Actions instance Usage:
Permissions Granted:
  • Limited access to specific program with amount restrictions

programScopeRecurringLimit(payload)

Program scope with recurring spending limits. Inputs:
  • payload.programId: SolPublicKeyData - Program ID
  • payload.targetAccount: SolPublicKeyData - Target account
  • payload.amount: bigint - Recurring amount limit
  • payload.window: bigint - Time window in slots for limit reset
  • payload.numericType: NumericType - Numeric type (U8, U32, U64, U128)
Output: Actions instance Usage:
Permissions Granted:
  • Recurring limited access to specific program

3. SOL Spending Actions

solLimit(payload)

One-time SOL spending limit. Inputs:
  • payload.amount: bigint - Maximum SOL amount to spend (in lamports)
Output: Actions instance Usage:
Permissions Granted:
  • Spend up to the specified amount of SOL once

solRecurringLimit(payload)

Recurring SOL spending limit. Inputs:
  • payload.recurringAmount: bigint - SOL amount per window (in lamports)
  • payload.window: bigint - Time window in slots until reset
Output: Actions instance Usage:
Permissions Granted:
  • Spend up to the specified amount of SOL per time window

solDestinationLimit(payload)

One-time SOL spending to a specific destination. Inputs:
  • payload.amount: bigint - SOL amount (in lamports)
  • payload.destination: SolPublicKeyData - Destination public key
Output: Actions instance Usage:
Permissions Granted:
  • Send up to the specified SOL amount to the specified destination once

solRecurringDestinationLimit(payload)

Recurring SOL spending to a specific destination. Inputs:
  • payload.recurringAmount: bigint - SOL amount per window (in lamports)
  • payload.window: bigint - Time window in slots until reset
  • payload.destination: SolPublicKeyData - Destination public key
Output: Actions instance Usage:
Permissions Granted:
  • Send up to the specified SOL amount to the destination per time window

4. Token Spending Actions

tokenLimit(payload)

One-time token spending limit. Inputs:
  • payload.mint: SolPublicKeyData - Token mint public key
  • payload.amount: bigint - Maximum token amount to spend
Output: Actions instance Usage:
Permissions Granted:
  • Spend up to the specified amount of the token once

tokenRecurringLimit(payload)

Recurring token spending limit. Inputs:
  • payload.mint: SolPublicKeyData - Token mint public key
  • payload.recurringAmount: bigint - Token amount per window
  • payload.window: bigint - Time window in slots until reset
Output: Actions instance Usage:
Permissions Granted:
  • Spend up to the specified token amount per time window

tokenDestinationLimit(payload)

One-time token spending to a specific destination. Inputs:
  • payload.mint: SolPublicKeyData - Token mint public key
  • payload.amount: bigint - Token amount
  • payload.destination: SolPublicKeyData - Destination public key
Output: Actions instance Usage:
Permissions Granted:
  • Send up to the specified token amount to the destination once

tokenRecurringDestinationLimit(payload)

Recurring token spending to a specific destination. Inputs:
  • payload.mint: SolPublicKeyData - Token mint public key
  • payload.recurringAmount: bigint - Token amount per window
  • payload.window: bigint - Time window in slots until reset
  • payload.destination: SolPublicKeyData - Destination public key
Output: Actions instance Usage:
Permissions Granted:
  • Send up to the specified token amount to the destination per time window

5. Staking Actions

stakeAll()

Unlimited staking permissions. Inputs: None
Output: Actions instance
Usage:
Permissions Granted:
  • Unlimited staking operations

stakeLimit(payload)

One-time staking limit. Inputs:
  • payload.amount: bigint - Maximum stake amount
Output: Actions instance Usage:
Permissions Granted:
  • Stake up to the specified amount once

stakeRecurringLimit(payload)

Recurring staking limit. Inputs:
  • payload.recurringAmount: bigint - Stake amount per window
  • payload.window: bigint - Time window in slots until reset
Output: Actions instance Usage:
Permissions Granted:
  • Stake up to the specified amount per time window

6. Account Management Actions

subAccount()

Grants permission to control a subaccount. Inputs: None
Output: Actions instance
Usage:
Permissions Granted:
  • Control and manage subaccount operations

Action Types Reference

SolPublicKeyData

A Solana public key in various formats:
  • String (base58)
  • Uint8Array (32 bytes)
  • PublicKey object

NumericType

Enum defining numeric types:

Combining Actions

Actions can be chained together to create complex permission sets:

Return Value: Actions Object

The .get() method returns an Actions object with the following methods:

Query Methods

  • count: number - Number of actions
  • bytes(): Uint8Array - Serialized action bytes
  • isRoot(): boolean - Check if root action present
  • canManageAuthority(): boolean - Check authority management permission
  • canUseProgram(programId): boolean - Check program access permission
  • hasProgramAction(): boolean - Check if any program action exists

SOL Spending Methods

  • canSpendSol(amount?): boolean - Check SOL spending permission
  • canSpendSolMax(): boolean - Check unlimited SOL spending
  • solSpendLimit(): bigint | null - Get SOL spending limit (null = unlimited)
  • solSpend(): SpendController - Get SOL spend controller

Token Spending Methods

  • canSpendToken(mint, amount?): boolean - Check token spending permission
  • canSpendTokenMax(mint): boolean - Check unlimited token spending
  • tokenSpendLimit(mint): bigint | null - Get token spending limit
  • tokenSpend(mint): SpendController - Get token spend controller

Usage Examples

Simple Token Limit

Program + Destination Limits

Recurring Subscription Pattern

This comprehensive documentation covers all available Swig Actions with their inputs, outputs, and practical usage examples.