Skip to main content
In this tutorial, we’ll learn how to add multiple authorities to a Swig account with different permission sets. We’ll create a root authority that can manage other authorities, then add two specialized authorities: one for SOL spending and another for token management.

Prerequisites

Before starting this tutorial:
  1. Make sure you’re in the examples/classic/transfer/tutorial directory for the classic version and examples/kit/transfer/tutorial for kit
  2. Ensure your local validator is running with:

Quick Review

In Tutorial 1, we learned how to create a basic Swig account. Now we’ll expand on that by managing multiple authorities with different permissions.
Open that file up in your favorite editor, or AI overlord super virtual reality goggles. Lets make a function called addNewAuthority

Example

Code Breakdown

Let’s examine the key parts of tutorial-2.ts:

1. Creating a Root Authority

This creates a Swig account where the root authority has permission to manage other authorities. We specifically use .manageAuthority() to limit this authority to only managing other authorities.

2. Adding a SOL Spending Authority

Don’t forget that the full list of actions an authority can have is here.
This creates an authority that:
  • Can only spend SOL (no token permissions)
  • Has a spending limit of 0.1 SOL
  • Cannot manage other authorities

3. Adding a Token Authority

This creates an authority that:
  • Can only manage tokens for a specific mint
  • Has a token spending limit of 1,000,000 units
  • Cannot spend SOL or manage other authorities

Understanding the Output

When you run the tutorial, you’ll see:
  1. The root user’s public key
  2. The Swig account address
  3. Two new authority public keys
  4. A permission summary showing what each authority can and cannot do
The tutorial provides links to view your transactions on Solana Explorer (using your local validator).

Key Concepts

  • Root Authority: An authority with management permissions that can add or remove other authorities
  • Specialized Authorities: Authorities with specific, limited permissions (e.g., SOL spending or token management)
  • Permission Limits:
    • SOL limits are set in lamports (1 SOL = 1,000,000,000 lamports)
    • Token limits are set based on the token’s decimals
  • Action Sets: Define what an authority can do using methods like:
    • .manageAuthority()
    • .solLimit()
    • .tokenLimit()

Running the Tutorial

Execute the tutorial with:
You nailed it , first try!! You now have a multi authority Swig, free energy and perpetual motion next.