Skip to main content
SWIG provides account abstraction on Solana, enabling seamless embedded wallet experiences. This guide walks you through integrating SWIG with Para for embedded wallet creation.

Prerequisites

Before starting this integration:
  • Set up a Para account on their developer portal
  • Generate an API Key
  • Enable Solana as a supported network
  • Basic understanding of React, TypeScript, and Solana

Installation

Install the required dependencies for SWIG integration:
Install Vite polyfills for development:

Setup

Vite Configuration

Update your vite.config.ts for Solana compatibility:

Environment Variables

Create a .env.local file in your project root:

Para Provider Setup

Create providers.tsx in your src directory:

Authentication

Create a login button component with Para modal integration:

SWIG Account Creation

Create a SWIG account using Para’s Solana Web3.js integration:

Complete Application

Here’s the complete App component that brings everything together:

Key Implementation Details

SWIG Account Creation Process

The createSwigAccount function performs these critical steps:
  1. Generate Random ID: Creates a unique 32-byte identifier for the SWIG account
  2. Create Para Signer: Initializes ParaSolanaWeb3Signer with Para client and wallet
  3. Set Authority: Establishes the Para-generated wallet as root authority
  4. Configure Actions: Grants full permissions using Actions.set().all().get()
  5. Build Transaction: Creates and configures the Solana transaction
  6. Sign & Send: Uses Para’s signer to sign and broadcast the transaction

Important Notes

  • Devnet SOL Required: You need devnet SOL in your Para-generated wallet before creating a SWIG account
  • Root Authority: The Para-generated wallet becomes the root authority for the SWIG account
  • Error Handling: The implementation includes proper error handling and loading states
  • Balance Display: Shows wallet SOL balance and SWIG address after creation

Testing Your Integration

  1. Start your development server:
  1. Open your browser to the displayed URL
  2. Click “Sign in with Para” to authenticate
  3. Send devnet SOL to your wallet address
  4. Click “Create Swig Account” to create your SWIG account

Best Practices

  • Never commit API keys to version control
  • Use environment variables for sensitive configuration
  • Test thoroughly on Solana devnet before mainnet
  • Implement proper error handling throughout the flow
  • Store SWIG account information securely

Resources

Next Steps

Now that you have SWIG working with Para, you can:
  • Implement additional SWIG functionality (transfers, token management)
  • Customize the Para modal appearance and OAuth providers
  • Add more complex transaction flows
  • Implement additional security features like multi-signature support
  • Integrate with other Solana protocols and applications