This guide walks you through deploying the Navin shipment tracking contracts to Stellar testnet.
Before deploying, ensure you have:
-
Rust toolchain installed with the
wasm32-unknown-unknowntarget:rustup target add wasm32-unknown-unknown
-
Stellar CLI (v22.0.1 or later):
cargo install --locked stellar-cli
-
Build tools: Make sure you can build the contracts locally:
cargo build
The deployment scripts use the following environment variables:
| Variable | Default | Description |
|---|---|---|
STELLAR_IDENTITY |
navin-testnet |
Stellar CLI identity name for signing transactions |
STELLAR_RPC_URL |
https://soroban-testnet.stellar.org:443 |
Stellar testnet RPC endpoint |
STELLAR_NETWORK_PASSPHRASE |
Test SDF Network ; September 2015 |
Network passphrase for testnet |
You can override these by exporting them before running the scripts:
export STELLAR_IDENTITY="my-custom-identity"
export STELLAR_RPC_URL="https://my-rpc-endpoint.com"Build both contracts to optimized WASM:
./scripts/build.shThis will:
- Compile both
navin-tokenandshipmentcontracts - Verify WASM files are generated
- Display file sizes
Expected output:
Building Soroban contracts...
Build successful!
Token WASM: target/wasm32-unknown-unknown/release/navin_token.wasm (XXX KB)
Shipment WASM: target/wasm32-unknown-unknown/release/shipment.wasm (XXX KB)
Deploy both contracts to testnet:
./scripts/deploy-testnet.shThis will:
- Check if the Stellar identity exists (create and fund from friendbot if not)
- Deploy the token contract
- Deploy the shipment contract
- Save contract addresses to
.env.testnet
Expected output:
Deploying contracts to Stellar testnet...
Identity: navin-testnet
RPC URL: https://soroban-testnet.stellar.org:443
Deploying token contract...
Token contract deployed: CXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Deploying shipment contract...
Shipment contract deployed: CXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Deployment complete!
Contract addresses saved to .env.testnet
Initialize both contracts with default parameters:
./scripts/init-testnet.shThis will:
- Initialize the token contract with:
- Name: "Navin Token"
- Symbol: "NAV"
- Total supply: 1,000,000,000.0000000 (10^16 stroops, 7 decimals)
- Initialize the shipment contract with the token contract address
Expected output:
Initializing contracts on Stellar testnet...
Token contract: CXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Shipment contract: CXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Admin address: GXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
Initializing token contract...
Token contract initialized successfully
Initializing shipment contract...
Shipment contract initialized successfully
Initialization complete!
Both contracts are ready to use on testnet
After deployment, verify the contracts are working:
-
Check token balance of the admin:
source .env.testnet stellar contract invoke \ --id "$TOKEN_CONTRACT_ID" \ --source-account "$STELLAR_IDENTITY" \ --rpc-url "$STELLAR_RPC_URL" \ --network-passphrase "$STELLAR_NETWORK_PASSPHRASE" \ -- \ balance \ --id "$(stellar keys address $STELLAR_IDENTITY)"
-
Check shipment contract admin:
stellar contract invoke \ --id "$SHIPMENT_CONTRACT_ID" \ --source-account "$STELLAR_IDENTITY" \ --rpc-url "$STELLAR_RPC_URL" \ --network-passphrase "$STELLAR_NETWORK_PASSPHRASE" \ -- \ get_admin
Install the Stellar CLI:
cargo install --locked stellar-cliRun the build script first:
./scripts/build.shThe deploy script automatically funds new accounts from friendbot. If you're using an existing identity, ensure it has testnet XLM:
ACCOUNT_ADDRESS=$(stellar keys address "$STELLAR_IDENTITY")
curl "https://friendbot.stellar.org?addr=$ACCOUNT_ADDRESS"Contracts can only be initialized once. If you need to redeploy, run the deploy script again to get new contract instances.
Make scripts executable:
chmod +x scripts/*.shAfter successful deployment:
- Save the contract addresses from
.env.testnetfor your application - Test contract functionality using the Stellar CLI or your application
- Monitor transactions on Stellar Expert
For production deployment, follow similar steps but use mainnet configuration and thoroughly test all functionality on testnet first.