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 documentationKey Features
- Openfort embedded wallet creation
- Solana transaction execution
- Cross-chain support (Solana ↔ EVM chains)
- Simple authentication flow
- Chain switching capabilities
| Component | Technology |
|---|---|
| Frontend | React + Vite + TypeScript |
| Blockchain | Solana (+ Polygon Amoy for chain switching) |
| Key Libraries | @openfort/openfort-js, @solana/web3.js |
| Styling | CSS |
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-samplePrerequisites
- Node.js 16+
- Yarn or npm
- Openfort account with configured API keys
- Modern web browser
Configuration
-
Copy the environment template:
cp .env.local.example .env.local -
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:solanaOr from the solana-sample directory:
yarn install
yarn devHow It Works
The application demonstrates three core functionalities:
- User Creation: Creates a new Openfort user with embedded wallet support
- Solana Transactions: Executes transactions on the Solana blockchain using Openfort's signer
- 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.