This guide provides step-by-step instructions for deploying the PromptHash Stellar application to the Stellar Mainnet.
Before deploying to mainnet, ensure you have:
- A funded Stellar mainnet account with sufficient XLM for deployment and initialization
- The Stellar CLI installed and configured
- Rust and Soroban SDK installed
- Access to the repository with all dependencies installed
- Completed testing on testnet/futurenet
IMPORTANT: Mainnet deployments involve real XLM and cannot be undone. Always:
- Verify you're using the correct network before running deployment commands
- Double-check all environment variables
- Test thoroughly on testnet first
- Ensure you have sufficient XLM for deployment fees
- Backup all keys and configuration files
Copy the mainnet environment template and configure it:
cp env.mainnet.example .envEdit .env and replace all placeholder values:
PUBLIC_PROMPT_HASH_CONTRACT_ID: Will be filled after deploymentPUBLIC_STELLAR_SIMULATION_ACCOUNT: Your funded mainnet accountPUBLIC_UNLOCK_PUBLIC_KEY: Your actual public keyCHALLENGE_TOKEN_SECRET: Generate a secure random stringUNLOCK_PUBLIC_KEY: Your unlock service public keyUNLOCK_PRIVATE_KEY: Your unlock service private keyADMIN_ROTATION_TOKEN: Generate a secure random token (optional but recommended)
The deployment script supports mainnet via the NETWORK environment variable:
export NETWORK=mainnet
export RPC_URL=https://soroban-rpc.mainnet.stellar.org
export NETWORK_PASSPHRASE="Public Global Stellar Network ; September 2015"
export STELLAR_NETWORK=mainnet
export HORIZON_URL=https://horizon.stellar.orgConfigure your admin and fee wallet identities:
export ADMIN_ALIAS=your_admin_alias
export FEE_WALLET_ALIAS=your_fee_wallet_aliasEnsure these identities are funded on mainnet. You cannot use friendbot on mainnet.
Run the deployment script:
NETWORK=mainnet ADMIN_ALIAS=your_admin_alias FEE_WALLET_ALIAS=your_fee_wallet_alias ./scripts/deploy.shThe script will:
- Build and optimize the contract
- Ensure identities exist and are funded
- Resolve the XLM SAC (Stellar Asset Contract)
- Deploy the contract to mainnet
- Initialize the contract with admin and fee wallet
- Update environment files with the deployed contract ID
After deployment, verify the contract is working:
stellar contract invoke \
--id YOUR_CONTRACT_ID \
--source your_admin_alias \
--network mainnet \
-- \
get_active_prompts_page --limit 50Build and deploy the frontend:
npm run buildDeploy the dist folder to your hosting provider (Vercel, Netlify, etc.).
Configure your hosting provider with the environment variables from your .env file (excluding private keys).
Deploy the serverless unlock service:
cd server
npm run buildDeploy to your serverless platform (Vercel, AWS Lambda, etc.) with the appropriate environment variables.
Current fee structure for mainnet transactions:
- Platform fee: 5% of each sale (configurable in contract)
- Deployment fee: Approximately 10-50 XLM depending on contract size
- Transaction fees: Standard Stellar network fees (100 stroops per operation)
- Storage fees: Contract storage costs based on data size
The deployment script includes several safeguards:
- Network confirmation: The script requires explicit
NETWORK=mainnetto deploy to mainnet - Environment checks: Verifies required environment variables are set
- Dry-run mode: Add
DRY_RUN=trueto test without actual deployment
To test deployment without executing:
DRY_RUN=true NETWORK=mainnet ./scripts/deploy.shThe script validates that:
- All required environment variables are set
- The network is explicitly specified
- Admin and fee wallet addresses are valid Stellar addresses
After deploying to mainnet:
- Verify contract is accessible via RPC
- Test prompt creation flow
- Test prompt purchase flow
- Verify unlock service is functioning
- Check analytics dashboard is displaying data
- Verify fee wallet is receiving platform fees
- Set up monitoring and alerting
- Configure backup procedures
- Document all deployed addresses and keys securely
If you encounter "insufficient funds" errors:
- Ensure your admin account has enough XLM (minimum 100 XLM recommended)
- Check the current network fees
- Verify your account is funded on the correct network
If contract initialization fails:
- Verify the XLM SAC ID is correct for mainnet
- Check that admin and fee wallet addresses are valid
- Ensure the contract was deployed successfully
If environment variables aren't being picked up:
- Verify
.envfile exists in the root directory - Check that variable names match exactly
- Ensure no typos in variable values
In case of critical issues:
- Pause the frontend (set maintenance mode)
- Stop the unlock service
- If contract has critical bugs, consider upgrading (see
contract-upgrades.md) - Revert to previous deployment if available
- Communicate with users about any issues
Set up monitoring for:
- Contract RPC endpoint availability
- Unlock service response times
- Error rates in logs
- Transaction success rates
- Fee wallet balance
- Never commit
.envfiles with real secrets - Use strong, randomly generated secrets for production
- Implement proper secret rotation (see
secret-rotation.md) - Use rate limiting on the unlock service
- Monitor for suspicious activity
- Keep dependencies updated
For issues or questions:
- Check the troubleshooting section
- Review the architecture documentation
- Open an issue on GitHub
- Contact the development team