Why Batch Operations?
When setting up a Swig with multiple authorities, you have two options:- Add authorities one at a time - Simple but requires multiple transactions
- Batch add authorities - More efficient, atomic, and cost-effective
Two Approaches to Batch Adding
Swig provides two methods for batch adding authorities:- During Creation: Add multiple authorities when creating the Swig using
getCreateSwigInstructionBuilder - After Creation: Add multiple authorities to an existing Swig using
getAddMultipleAuthoritiesInstructionBuilder
Approach 1: Adding Authorities During Swig Creation
When creating a Swig, you can chain.addAuthority() calls to add multiple authorities in the creation transaction. This is ideal for initial setup.
Key Differences from Basic Creation
Instead ofgetCreateSwigInstruction, use getCreateSwigInstructionBuilder which returns a builder that allows chaining.
Key Points
- Use
getCreateSwigInstructionBuilderinstead ofgetCreateSwigInstruction - Chain
.addAuthority()calls for each additional authority - Call
.getInstructions()at the end to get all instructions - All authorities are added in a single atomic transaction
Approach 2: Adding Multiple Authorities to Existing Swig
Sometimes you need to add multiple authorities to an existing Swig. For this, usegetAddMultipleAuthoritiesInstructionBuilder.
This is particularly useful for:
- Team onboarding - Adding multiple team members at once
- Permission upgrades - Granting multiple new authorities simultaneously
- Dynamic authority management - Responding to application events
Key Points for getAddMultipleAuthoritiesInstructionBuilder
- Fetch fresh Swig data - Always fetch the latest Swig state before adding authorities
- Need proper permissions - The signing role must have
allormanageAuthoritypermission - Chain additions - Call
.addAuthority()for each authority you want to add - All or nothing - The operation is atomic - all authorities are added or none
Advanced: Multi-Curve Authorities
Swig supports multiple cryptographic curves. You can mix Ed25519, Secp256k1 (Ethereum), and Secp256r1 (Passkeys/WebAuthn) authorities in a single Swig!When to Use Each Approach
Summary
- Two batching methods - Use builders for creation-time or post-creation batching
- Atomic operations - All authorities are added together or none at all
- Multi-curve support - Mix Ed25519, Secp256k1, and Secp256r1 authorities
Related Examples
- Transfer Example - Basic Swig usage with single authorities
- Sessions Example - Temporary authorities with time limits
- Sub Accounts Example - Delegated account management

