Skip to content

Solana Integration

Overview

This sample demonstrates how to integrate Openfort's embedded wallet infrastructure with the Solana blockchain. It showcases user creation, transaction execution on Solana, and cross-chain capabilities with EVM networks.

Project Structure

solana-sample/
├── src/
│   ├── App.tsx              # Main application component
│   ├── main.tsx             # React entry point
│   ├── Login.tsx            # Authentication flow
│   ├── content.tsx          # UI content and components
│   ├── solana.tsx           # Solana blockchain interactions
│   ├── openfort.ts          # Openfort SDK configuration
│   ├── index.css            # Global styles
│   ├── vite-env.d.ts        # Vite type definitions
│   └── assets/              # Static assets (logos, icons)
│       ├── openfort.svg
│       └── solanaLogo.svg
├── public/
│   └── favicon.ico          # Favicon
├── .env.local.example       # Environment template
├── package.json             # Dependencies and scripts
├── vite.config.ts           # Vite configuration
├── tsconfig.json            # TypeScript configuration
└── README.md                # Project documentation

Key Features

  • Openfort embedded wallet creation
  • Solana transaction execution
  • Cross-chain support (Solana ↔ EVM chains)
  • Simple authentication flow
  • Chain switching capabilities
ComponentTechnology
FrontendReact + Vite + TypeScript
BlockchainSolana (+ Polygon Amoy for chain switching)
Key Libraries@openfort/openfort-js, @solana/web3.js
StylingCSS

Quick Start

Clone the repository and navigate to the solana sample:

git clone https://github.com/openfort-xyz/openfort-js.git
cd openfort-js
yarn install
yarn build
cd examples/apps/solana-sample

Prerequisites

  • Node.js 16+
  • Yarn or npm
  • Openfort account with configured API keys
  • Modern web browser

Configuration

  1. Copy the environment template:

    cp .env.local.example .env.local
  2. Add your Openfort credentials to .env.local:

    VITE_PROJECT_PUBLISHABLE_KEY=your_publishable_key
    VITE_SHIELD_PUBLISHABLE_KEY=your_shield_key
    VITE_SOLANA_TEST_RECEIVE_ADDRESS=your_solana_receive_address
    

Install & Run

From the openfort-js project root:

yarn dev:solana

Or from the solana-sample directory:

yarn install
yarn dev

How It Works

The application demonstrates three core functionalities:

  1. User Creation: Creates a new Openfort user with embedded wallet support
  2. Solana Transactions: Executes transactions on the Solana blockchain using Openfort's signer
  3. Chain Switching: Demonstrates cross-chain capabilities by switching to Polygon Amoy (EVM chain)

This sample is ideal for developers looking to add Solana support to their applications while maintaining the flexibility to work with EVM-compatible chains.