Prerequisites
Before starting this tutorial:- Make sure you’re in the
examples/classic/transfer/tutorialdirectory for theclassicversion andexamples/kit/transfer/tutorialforkit - 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.addNewAuthority
Example
- Classic
- Kit
Code Breakdown
Let’s examine the key parts oftutorial-2.ts:
1. Creating a Root Authority
- Classic
- Kit
.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.- Classic
- Kit
- Can only spend SOL (no token permissions)
- Has a spending limit of 0.1 SOL
- Cannot manage other authorities
3. Adding a Token Authority
- Classic
- Kit
- 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:- The root user’s public key
- The Swig account address
- Two new authority public keys
- A permission summary showing what each authority can and cannot do
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()

