What We’re Building
A React (Next.js) app that connects Dynamic’s embedded wallets to Kalshi-style prediction markets on Solana, allowing users to:- Browse active prediction markets with real-time prices
- Buy Yes/No outcome shares on markets using SOL
- View and manage portfolio positions
- Sell positions and redeem winning outcomes
- Deposit funds via multiple methods (QR, cross-chain swap)
Key Components
- Dynamic JS SDK Embedded Wallets - Non-custodial Solana wallets with seamless auth
- DFlow - Order execution protocol for Kalshi markets on Solana
- Solana Network - All trades execute on Solana mainnet
Building the Application
Project setup
Scaffold a Next.js project withcreate-next-app. This recipe uses the Dynamic JS SDK (@dynamic-labs-sdk/client + @dynamic-labs-sdk/solana) for authentication and embedded Solana wallet management.
Dashboard: Under Chains & Networks, enable Solana. Under Sign-in Methods and Wallets, enable what your flow needs (including Embedded wallets). Under Security → Allowed Origins, add your origin (for example
http://localhost:3000).Install Dependencies
Add the Dynamic JS SDK and Solana dependencies:Configure Environment
Create a.env.local file with your Dynamic environment ID:
.env.local
Initialize Dynamic Client
Createsrc/lib/dynamic.ts to initialize the Dynamic client with the Solana extension:
src/lib/dynamic.ts
addSolanaExtension() call registers Solana wallet support and must be called immediately after creating the client.
Configure Providers
Set up a wallet context using the JS SDK. Createsrc/lib/providers.tsx:
src/lib/providers.tsx
Build the Auth Button
Create a customDynamicButton component at src/components/dynamic/DynamicButton.tsx. This handles Google OAuth, email OTP, and external Solana wallet connection:
src/components/dynamic/DynamicButton.tsx
Create the Trading Hook
Build the Kalshi trading hook that handles Solana transactions. Createsrc/lib/hooks/useKalshiTrading.ts:
src/lib/hooks/useKalshiTrading.ts
- Use
getActiveNetworkDatafrom@dynamic-labs-sdk/clientto get network configuration for the wallet - Use
getSolanaConnectionfrom@dynamic-labs-sdk/solanato get aConnectioninstance - Use
signTransactionfrom@dynamic-labs-sdk/solanato sign transactions with the embedded wallet
Create the Layout
Updatesrc/app/layout.tsx to include the Roboto font and providers:
src/app/layout.tsx
Run the Application
Start the development server:http://localhost:3000.
How Trading Works
When a user places a trade on Kalshi through this app:- Authentication: The user signs in via Google, email OTP, or external Solana wallet using the custom
DynamicButton - Wallet Provisioning: After auth, a Solana embedded wallet is automatically created via
createWaasWalletAccounts({ chains: ["SOL"] }) - Connection:
getActiveNetworkDataretrieves the RPC configuration, andgetSolanaConnectioncreates a web3.jsConnection - Order Preparation: The app fetches a swap transaction from the DFlow API
- Transaction Signing:
signTransactionfrom@dynamic-labs-sdk/solanasigns the transaction with the embedded wallet - Broadcast: The signed transaction is sent to the Solana network via the
Connection - Confirmation: The app polls for confirmation and shows success/error feedback
Conclusion
If you want to take a look at the full source code, check out the GitHub repository. This integration demonstrates how Dynamic’s JS SDK enables seamless Solana wallet management for prediction markets. ThesignTransaction function from @dynamic-labs-sdk/solana provides a clean interface for signing transactions with embedded wallets, while getSolanaConnection handles network connectivity.