Skip to main content
This tutorial covers transaction signing after your wallet and authorities are already in place. Finish the earlier quickstart pages first, then create the next tutorial file: Create tutorial-3.ts in examples/tutorial/classic for the classic version or in examples/tutorial/kit for kit:

Example

Let’s break down how signing works with Swig.

1. Fetch the Swig Account

First, we need to fetch the current state of our Swig account. This contains all the roles and their permissions that we set up in the previous tutorials.

2. Find the Appropriate Role

We locate the role associated with our token authority. Remember from the previous tutorial that this role was created with specific token transfer limits.
💡 A single authority can have multiple roles. Always make sure you’re using the correct role for your intended action.

3. Create the Instruction

Create the instruction that needs to be signed. In this case, it’s a token transfer instruction, but Swig can sign any type of instruction as long as the role has the appropriate permissions.

4. Sign the Instruction

This is where the magic happens. The getSignInstructions function:
  1. Verifies that the role has permission to sign this type of instruction
  2. Creates the necessary signing instructions
  3. Wraps the original instruction with Swig’s signing logic
🔒 Swig validates both the authority type and action permissions at this stage

5. Build and Send the Transaction

Finally, we build the transaction with our signed instructions and send it to the network. Note that the transaction still needs to be signed by the authority’s keypair because they’re the one paying for the transaction fees.

Understanding Signature Verification

When the transaction reaches the Solana network, the Swig program will:
  1. Extract the original instruction
  2. Verify the authority’s signature
  3. Check that the role’s permissions allow this action
  4. Execute the instruction if all checks pass
🧠 This multi-step verification ensures that only authorized actions are performed

Ready to try it?

Make sure you have:
  1. Completed the previous tutorials
  2. Have a running validator (bun start-validator)
  3. Created a Swig account with appropriate authorities
Then run:
The link at the end of the tutorial will take you to the swig on the Solana Explorer. You will see multiple transactions and there should be one failed which shows the negative case.