Skip to main content
This tutorial adds multiple authorities to a Swig wallet and assigns each one a different permission set.

Prerequisites

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

Quick Review

In Create a Wallet, you created a basic Swig wallet. This page builds on that by adding multiple authorities with different permissions.
Create the file and implement an addNewAuthority helper.

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

See the full list of actions an authority can have.
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.