A comprehensive educational workshop demonstrating Stellar blockchain development with DeFi protocols including Soroswap and DeFindex integrations.
This repository contains complete workshops that demonstrate DeFi operations on the Stellar blockchain and Soroban smart contract platform:
- Soroswap Workshop (
src/soroswap.ts) - DEX integration and token swapping - DeFindex Workshop (
src/defindex.ts) - Vault creation and asset management - Direct Contract Calls (
src/soroswap-typescript.ts,src/defindex-typescript.ts) - Same flows without SDKs, using direct Stellar SDK contract calls
The workshops demonstrate professional DeFi development patterns using official SDKs on Stellar testnet. The direct contract call versions show how to interact with contracts at the lowest level without SDK/API dependencies.
- Creating and funding wallets on Stellar testnet
- Using the Soroswap SDK for DEX operations
- Swapping tokens (XLM to USDC) through Soroswap
- Quote → Build → Sign → Submit workflow for trading
- Adding liquidity to decentralized exchange pools
- Checking token balances via Soroban contracts
- Integration with Soroban smart contracts
- Creating multi-asset vaults with configurable strategies
- Understanding vault roles (Emergency Manager, Fee Receiver, Manager, Rebalance Manager)
- Deploying vaults with initial deposits
- Managing vault permissions and fees
- Making deposits to existing vaults
- Working with asset management strategies
- Using the DeFindex SDK for vault operations
- Node.js 18+ installed
- TypeScript knowledge
- Basic understanding of blockchain and DeFi concepts
- Stellar testnet account (automatically created in workshops)
- Clone the repository:
git clone https://github.com/paltalabs/stellar-workshop.git
cd stellar-workshop- Install dependencies:
npm install- Create a
.envfile with API keys (optional but recommended):
cp .env.example .env
# Edit .env and add your API keys:
# SOROSWAP_API_KEY=your_soroswap_api_key
# DEFINDEX_API_KEY=your_defindex_api_keynpm run soroswapThis workshop demonstrates:
- Wallet creation and funding via Friendbot
- Token swapping (XLM to USDC) using Soroswap DEX
- Checking token balances
- Adding liquidity to trading pools
npm run defindexThis workshop demonstrates:
- Vault manager wallet creation
- Configuring vault parameters with roles and strategies
- Creating a DeFindex vault with initial deposit
- Creating additional depositor wallets
- Making deposits to existing vaults
Soroswap Direct (src/soroswap-typescript.ts):
npm run soroswap-directDeFindex Direct (src/defindex-typescript.ts):
DEFINDEX_FACTORY=your_factory_address npm run defindex-directThese versions execute the same flows but interact directly with smart contracts using only the Stellar SDK—no Soroswap/DeFindex SDKs or APIs. Perfect for understanding contract interactions at the lowest level and building custom transaction logic.
- Wallet Creation: Generate keypair and fund with testnet XLM
- Token Swap: Swap XLM for USDC using Soroswap SDK
- Balance Check: Query token balances via Soroban contracts
- Add Liquidity: Provide liquidity to XLM/USDC pool
- Vault Manager Setup: Create and fund vault manager wallet
- Configure Vault: Define roles, fees, assets, and strategies
- Create Vault: Deploy vault with initial deposit
- Create Depositor: Generate separate depositor wallet
- Make Deposit: Deposit additional funds to the vault
- Educational Focus: Comprehensive logging and step-by-step explanations
- Production SDKs: Uses official Stellar, Soroswap, and DeFindex SDKs
- Testnet Safe: All operations run on Stellar testnet
- Real-world Patterns: Demonstrates professional DeFi development workflows
- Type-Safe: Full TypeScript implementation with proper error handling
@stellar/stellar-sdk(v14.3.2): Official Stellar SDK for blockchain operations@soroswap/sdk(v0.3.8): Soroswap SDK for DEX operations@defindex/sdk(v0.1.1): DeFindex SDK for vault managementdotenv: Environment variable managementtypescript: Type-safe development
The repository includes Soroban smart contracts written in Rust:
- DeFindex Zap Contract: Advanced vault interaction contract
- Soroswap Integration Contracts: DEX router interfaces
- Built with
soroban-sdkv23.0.2 - Uses OpenZeppelin Stellar contracts for security patterns
- Horizon Server:
https://horizon-testnet.stellar.org - Soroban RPC:
https://soroban-testnet.stellar.org - Soroswap API:
https://api.soroswap.finance - Network: Stellar Testnet
stellar-workshop/
├── src/
│ ├── soroswap.ts # Soroswap DEX workshop (uses SDK)
│ ├── defindex.ts # DeFindex vault workshop (uses SDK)
│ ├── soroswap-typescript.ts # Direct contract calls (no SDK)
│ └── defindex-typescript.ts # Direct contract calls (no SDK)
├── contracts/ # Soroban smart contracts (Rust)
│ ├── defindex-zap/ # DeFindex integration contract
│ ├── soroswap-auth/ # Soroswap authorization contract
│ └── soroswap-simple/# Simple Soroswap integration
├── scripts/ # Deployment and utility scripts
└── Cargo.toml # Rust workspace configuration
By completing these workshops, you will understand:
- Stellar Blockchain: Account creation, funding, and transaction management
- DeFi Protocols: DEX trading, liquidity provision, and vault management
- Soroban Smart Contracts: Interacting with deployed contracts on Stellar
- SDK Integration: Using production-grade SDKs for DeFi development
- Transaction Workflows: Quote → Build → Sign → Submit patterns
- Asset Management: Vault strategies, roles, and permissions
- Best Practices: Error handling, transaction signing, and security
# Build all Soroban contracts
make build
# Or build with Cargo
cargo build --target wasm32-unknown-unknown --releaseThe scripts/deploy/ directory contains deployment scripts for:
- DeFindex vault interactions
- Soroswap router integrations
- Custom token implementations
- All operations use testnet XLM (no real value)
- Private keys are generated randomly for each workshop run
- Never commit private keys or secrets to version control
- API keys should be stored in
.envfile (not committed) - Transactions include proper timeout and fee settings
- Error handling demonstrates production patterns
Common issues and solutions:
- Network Issues: Ensure stable internet connection to Stellar testnet
- Rate Limiting: Wait between workshop runs if hitting Friendbot/API limits
- Transaction Failures: Check Stellar Expert for transaction details
- SDK Errors: Verify API keys in
.envfile - Balance Errors: Ensure wallet has sufficient XLM for transactions and fees
- Contract Errors: Check Soroban RPC connection and contract IDs
- Build Errors: Ensure Rust toolchain is installed for contract compilation
- Stellar Documentation - Core Stellar blockchain docs
- Soroban Documentation - Smart contract platform
- Soroswap Documentation - DEX protocol docs
- DeFindex Documentation - Vault management docs
- Stellar Expert - Testnet blockchain explorer
- Stellar Laboratory - Transaction builder and tester
- Soroswap Interface - DEX trading interface
- @stellar/stellar-sdk - Official JavaScript SDK
- @soroswap/sdk - Soroswap integration SDK
- @defindex/sdk - DeFindex vault SDK
- soroban-sdk - Rust smart contract SDK
This is an educational workshop maintained by Palta Labs. Contributions are welcome!
To contribute:
- Fork the repository
- Create a feature branch
- Make your changes
- Submit a pull request
For bugs or feature requests, please create an issue.
Apache-2.0 License - See LICENSE file for details
Built by Palta Labs for the Stellar developer community.
Ready to start? Run npm install and then npm run soroswap to begin your Stellar DeFi journey!