A production-ready reference application demonstrating how to integrate the SocketFi Embedded Smart Account into a React application.
This repository showcases the complete end-to-end integration of the SocketFi React SDK and SocketFi Server SDK, including hosted authentication, hosted transaction approval, backend transaction preparation, Paymaster fee sponsorship, and Soroban transaction execution.
Whether you're building a DeFi application, marketplace, game, NFT platform, AI agent, fintech product, or consumer application, this project provides a production-ready foundation for integrating embedded smart wallets into your React applications.
- 🔐 Passkey-based authentication
- 👛 Embedded Soroban smart wallet
- 💸 Native XLM transfers
- 🪙 Stellar Asset Contract token transfers
- ✅ Hosted transaction approval
- ⚡ Automatic transaction submission
- 🧩 Backend transaction preparation using the SocketFi Server SDK
- 💰 Server-side Paymaster fee sponsorship
- 🔒 Backend-controlled transaction validation
- ⚛️ React + TypeScript
- 🚀 Soroban Testnet ready
The following demo showcases the complete authentication and token transfer experience using the SocketFi Embedded Wallet.
This reference application demonstrates how to:
- Authenticate users using SocketFi Passkeys
- Create embedded smart wallets
- Transfer native XLM
- Transfer Stellar Asset Contract tokens
- Submit transactions directly using SocketFi
- Submit transactions through your own backend Paymaster
- Prepare Soroban transactions using the SocketFi Server SDK
This example supports two different transaction workflows depending on your application's architecture.
Recommended for most applications
The frontend requests transaction approval and SocketFi handles everything else.
User
│
▼
React App
│
▼
SocketFi SDK
│
▼
Hosted Approval
│
▼
User signs authorization
│
▼
SocketFi submits transaction
│
▼
Stellar Network
SocketFi handles:
- Wallet authorization
- Transaction approval UI
- Transaction submission
- Fee sponsorship
Your application only needs to request approval.
This is the simplest integration and is recommended for applications that do not require custom backend transaction processing.
Recommended for production applications with backend infrastructure
The frontend requests wallet authorization only.
Your backend assembles the transaction, signs it with your Paymaster, and submits it to the network.
User
│
▼
React App
│
▼
SocketFi React SDK
│
▼
Hosted Approval
│
▼
Signed Authorization
│
▼
Application Backend
│
▼
SocketFi Server SDK
│
▼
Prepare Transaction
│
▼
Paymaster Signature
│
▼
Submit Transaction
│
▼
Stellar Network
Frontend
- Authenticate user
- Request transaction approval
- Receive signed authorization entries
Backend
- Validate transaction parameters
- Prepare the transaction using
socketfi.prepareTransaction() - Sign the prepared transaction using the Paymaster
- Submit the transaction to Stellar RPC
This approach keeps your Paymaster secret securely on your backend while allowing your backend to prepare and validate the transaction before sponsoring and submitting it.
React Application
│
▼
SocketFi React SDK
│
┌────────────────┴────────────────┐
│ │
▼ ▼
Hosted Authentication Hosted Transaction Approval
│ │
└────────────────┬────────────────┘
▼
Embedded Smart Wallet
│
▼
Stellar Soroban Network
git clone git@github.com:Socket-Fi/socketfi-react-integration-reference.git
cd socketfi-react-integration-referencenpm install
npm run install:allA preconfigured .env file is included for convenience and is ready to use with the demo.
If you need to customize the configuration (for example, to use your own SocketFi application or backend), update the following values:
# React Application
VITE_CLIENT_ID=YOUR_SOCKETFI_CLIENT_ID
VITE_NETWORK=TESTNET
VITE_SERVER_URL=http://localhost:4000
# Backend
APP_CLIENT_ID=YOUR_SOCKETFI_CLIENT_ID
APP_SECRET_KEY=YOUR_SOCKETFI_SECRET_KEY
PAYMASTER_SECRET_KEY=YOUR_PAYMASTER_SECRET_KEY
STELLAR_NETWORK=TESTNET
STELLAR_RPC_URL=https://soroban-testnet.stellar.orgTo create your own Client ID and Secret Key, create a new application in the SocketFi Developer Console:
npm run dev.
├── client
│ ├── src
│ │ ├── components
│ │ ├── hooks
│ │ ├── utils
│ │ └── App.tsx
│ └── package.json
│
├── server
│ ├── routes
│ ├── services
│ ├── index.ts
│ └── package.json
│
├── .env.example
└── README.md
| Variable | Description |
|---|---|
clientId |
SocketFi Client ID |
VITE_NETWORK |
TESTNET or PUBLIC |
VITE_SERVER_URL |
Backend server URL |
This reference application uses both SocketFi's React and Server SDKs.
Authentication:
const session = await socketfi.authenticate();Sign transaction authorization:
await socketfi.signTx(...);Sign and submit:
await socketfi.signAndSubmitTx(...);Validate and prepare a transaction for Paymaster signing:
const prepared = await socketfi.prepareTransaction({
contractId,
functionName,
argsXdr,
signedAuthEntriesXdr,
paymasterPublicKey,
});Authentication uses SocketFi's hosted authentication experience.
Features include:
- Passkey authentication
- Embedded wallet creation
- Secure session management
- No browser extensions required
- No seed phrases
After authentication, the SDK returns:
{
address, socketfiAccessToken;
}The access token is required for all protected wallet operations.
This demo supports transferring:
- Native XLM
- Stellar Asset Contract Tokens
The application automatically builds the appropriate Soroban contract invocation before requesting user approval.
When using signAndSubmitTx(), transaction fees are sponsored automatically using the Paymaster configured for your SocketFi project.
When using signTx(), your backend is responsible for:
- Receiving the transaction parameters and signed authorization entries
- Preparing the transaction using
socketfi.prepareTransaction() - Signing the prepared transaction with the Paymaster
- Submitting the transaction to Stellar RPC
This keeps your Paymaster secret securely on your backend while allowing your application to validate and control every sponsored transaction.
The backend uses the SocketFi Server SDK to validate and prepare the transaction before signing it with the Paymaster.
By reconstructing the transaction from the original contract invocation parameters and the user-signed authorization entries, the SDK ensures the authorization is applied to the intended transaction before it is sponsored and submitted.
const prepared = await socketfi.prepareTransaction({
contractId,
functionName,
argsXdr,
signedAuthEntriesXdr,
paymasterPublicKey: paymaster.publicKey(),
});
const tx = new StellarSdk.Transaction(
prepared.transactionXdr,
prepared.networkPassphrase
);
tx.sign(paymaster);
const server = new rpc.Server(RPC_URL);
await server.sendTransaction(tx);The Server SDK automatically:
- Builds the Soroban contract invocation
- Injects the user-signed authorization entries
- Simulates the transaction
- Assembles the transaction
- Returns a ready-to-sign transaction XDR
SocketFi supports two workflows to accommodate different application architectures.
| Workflow | Backend Required | Recommended For |
|---|---|---|
signAndSubmitTx() |
No | Most applications |
signTx() |
Yes | Production applications that require backend-controlled transaction preparation, validation, Paymaster sponsorship, and submission. |
You can easily extend this project to:
- Call custom Soroban contracts
- Read contract state
- Add swaps
- Build NFT applications
- Integrate DeFi protocols
- Add wallet guardians
- Customize branding
- Connect to Mainnet
- React 18+
- React 19+
- TypeScript
- Vite
- SocketFi React SDK v2
- Soroban
- Stellar Testnet
-
Developer Console
Create and manage your SocketFi applications, obtain Client IDs, configure branding, and manage your project settings.
https://console.socket.fi -
Documentation
Integration guides, SDK documentation, API references, and tutorials.
https://docs.socket.fi -
Website
https://socket.fi
This reference project is ideal for developers building:
- DeFi applications
- NFT platforms
- Wallets
- Marketplaces
- Consumer applications
- AI agents
- Fintech applications
- Games
- Soroban smart contract integrations
After exploring this example, consider:
- Integrating your own backend Paymaster
- Calling custom Soroban contracts
- Reading contract state
- Adding wallet guardians
- Customizing the hosted authentication experience
- Deploying to Stellar Mainnet
Contributions, issues, and feature requests are welcome.
If you discover an issue or have suggestions for improving this reference implementation, feel free to open an issue or submit a pull request.
MIT
- 🌐 Website: https://socket.fi
- 📚 Documentation: https://docs.socket.fi
- 📦 SDK: https://www.npmjs.com/package/@socketfi/react
Built with ❤️ using SocketFi, React, and Stellar Soroban.

