A quick, step-by-step guide to deploying the Fluxora stream contract to Stellar testnet.
-
Rust installed (v1.70+)
rustup --version rustup target add wasm32-unknown-unknown
-
Stellar CLI installed (install guide)
stellar --version
-
Testnet account with funds
- Create/fund via Stellar testnet faucet
- Funded account = Deployer account (holds the contract, cov gas fees)
-
Environment variables configured
cp .env.example .env # Then edit .env with: export STELLAR_SECRET_KEY="S..." # Deployer secret key export STELLAR_ADMIN_ADDRESS="G..." # Admin/treasury public key export STELLAR_TOKEN_ADDRESS="C..." # USDC or test token contract address export STELLAR_NETWORK="testnet" # (optional) export STELLAR_RPC_URL="https://soroban-testnet.stellar.org" # (optional)
cargo build --release -p fluxora_stream --target wasm32-unknown-unknownExpected output: target/wasm32-unknown-unknown/release/fluxora_stream.wasm (~150 KB)
The deployment script handles WASM upload, contract deployment, and init in one go:
source .env
bash script/deploy-testnet.shWhat it does:
- ✅ Validates env vars and CLI prerequisites
- ✅ Builds the WASM binary
- ✅ Uploads WASM to testnet (idempotent — skips if unchanged)
- ✅ Deploys contract instance (idempotent — skips if already deployed)
- ✅ Invokes
initto set token and admin - ✅ Saves contract ID to
.contract_idfor future use
Output: Contract ID will be saved to .contract_id file (example: CAHUB4AGDYVQ3G5T3B...)
If you prefer to deploy manually:
# Step 1: Upload WASM
WASM_ID=$(stellar contract upload \
--wasm target/wasm32-unknown-unknown/release/fluxora_stream.wasm \
--network testnet \
--source "$STELLAR_SECRET_KEY" \
--rpc-url https://soroban-testnet.stellar.org)
# Step 2: Deploy contract
CONTRACT_ID=$(stellar contract deploy \
--wasm-hash "$WASM_ID" \
--network testnet \
--source "$STELLAR_SECRET_KEY" \
--rpc-url https://soroban-testnet.stellar.org)
# Save for later
echo "$CONTRACT_ID" > .contract_idThe contract requires init to be called exactly once, setting the token address and admin.
The script calls init automatically at the end:
bash script/deploy-testnet.shIf you deployed manually or need to re-initialize:
CONTRACT_ID=$(cat .contract_id) # or use your deployed contract ID
stellar contract invoke \
--id "$CONTRACT_ID" \
--network testnet \
--source "$STELLAR_SECRET_KEY" \
--rpc-url https://soroban-testnet.stellar.org \
-- init \
--token "$STELLAR_TOKEN_ADDRESS" \
--admin "$STELLAR_ADMIN_ADDRESS"Note: init can only be called once. Calling it again will fail (by design).
After deployment, verify the contract is working:
Check that init succeeded by reading the contract config:
CONTRACT_ID=$(cat .contract_id)
stellar contract invoke \
--id "$CONTRACT_ID" \
--network testnet \
--source "$STELLAR_SECRET_KEY" \
--rpc-url https://soroban-testnet.stellar.org \
-- get_configExpected output: {"token": "C...", "admin": "G..."}
Create a sample stream to verify create_stream works:
stellar contract invoke \
--id "$CONTRACT_ID" \
--network testnet \
--source "$STELLAR_SECRET_KEY" \
--rpc-url https://soroban-testnet.stellar.org \
-- create_stream \
--sender "$STELLAR_ADMIN_ADDRESS" \
--recipient "GBRPYHIL2CI3WHZDTOOQFC6EB4CGQOFSNQB37HY5SKBRZGTAE3Z5MJGF" \
--deposit_amount 1000000 \
--rate_per_second 1000 \
--cliff_time 1700000000 \
--end_time 1800000000Expected output: Stream ID (e.g., 0) printed to console
stellar contract invoke \
--id "$CONTRACT_ID" \
--network testnet \
--source "$STELLAR_SECRET_KEY" \
--rpc-url https://soroban-testnet.stellar.org \
-- get_stream_state \
--stream_id 0Expected output:
{
"sender": "G...",
"recipient": "G...",
"deposit_amount": 1000000,
"rate_per_second": 1000,
"start_time": ...,
"cliff_time": ...,
"end_time": ...,
"withdrawn_amount": 0,
"status": "Active"
}- RPC URL:
https://soroban-testnet.stellar.org - Network Passphrase:
Test SDF Network ; September 2015 - Network ID:
testnet
The deployment script uses the RPC URL and network name automatically. No manual configuration needed unless you override with STELLAR_RPC_URL.
After deployment, you can view your contract on the Stellar testnet explorer:
- Stellar Expert Testnet
- Search for your Contract ID (from
.contract_id)
Problem: Deployment script exits with env var error.
Solution:
export STELLAR_SECRET_KEY="S..." # or source .envProblem: CLI is not installed or not in PATH.
Solution:
# Install Stellar CLI
# https://developers.stellar.org/docs/smart-contracts/getting-started/setup
# Verify installation
stellar --versionProblem: Contract deployment failed, usually due to insufficient funds or RPC timeout.
Solution:
- Verify your deployer account has funds:
stellar account info --network testnet --source "$STELLAR_SECRET_KEY" - Re-run the deployment script (idempotency should retry the deploy)
- Check RPC status:
curl https://soroban-testnet.stellar.org/health
Problem: init fails because it's already been called.
Solution:
- This is expected behavior.
initcan only run once. - Verify with
get_config. If it returns token and admin,initsucceeded.
Problem: Script skips WASM re-upload but you want to force a fresh upload.
Solution:
rm .wasm_id .wasm_id.sha256 .contract_id
bash script/deploy-testnet.shThis forces a fresh WASM upload and new contract deployment.
Problem: Testnet RPC is slow or unresponsive.
Solution:
- Check RPC status: https://status.stellar.org/
- Temporarily use alternative RPC (if available)
- Retry the deployment after a few minutes
| Step | Command |
|---|---|
| Setup | cp .env.example .env → fill in env vars |
| Build | cargo build --release -p fluxora_stream --target wasm32-unknown-unknown |
| Deploy | bash script/deploy-testnet.sh |
| Verify | stellar contract invoke --id $(cat .contract_id) -- get_config |
| Test stream | stellar contract invoke --id $(cat .contract_id) -- create_stream ... |
After successful deployment:
- Fund test accounts for stream recipients via testnet faucet
- Create streams with realistic test data (senders, recipients, amounts, durations)
- Monitor accrual by calling
get_stream_stateat different times - Test withdrawals via the
withdrawmethod - Pause/resume/cancel streams to verify state transitions