This directory contains build, deployment, and contract interaction scripts for the Brain-Storm platform.
Builds all Soroban smart contracts in the contracts/ directory.
Usage:
./scripts/build.shFeatures:
- Loops over all contracts in
contracts/directory - Uses
--releaseflag for optimized builds - Displays WASM file sizes
- Error handling with
set -euo pipefail
Output:
Building Brain-Storm smart contracts...
Building analytics...
Building token...
Building shared...
Build complete. WASM files and sizes:
target/wasm32-unknown-unknown/release/brain_storm_analytics.wasm (123K)
target/wasm32-unknown-unknown/release/brain_storm_token.wasm (456K)
target/wasm32-unknown-unknown/release/brain_storm_shared.wasm (78K)
Deploys a specific contract to Stellar testnet or mainnet.
Usage:
./scripts/deploy.sh <network> <contract_name>Arguments:
network:testnetormainnet(default:testnet)contract_name: Contract name (default:analytics)
Examples:
# Deploy analytics to testnet
./scripts/deploy.sh testnet analytics
# Deploy token to mainnet
./scripts/deploy.sh mainnet tokenRequirements:
STELLAR_SECRET_KEYenvironment variable must be set- Contract must be built first (run
./scripts/build.sh) jqmust be installed for JSON parsing
Features:
- Validates network and contract name
- Checks for WASM file existence
- Automatically updates
deployed-contracts.jsonwith contract ID - Error handling with
set -euo pipefail
Calls a function on a deployed contract.
Usage:
./scripts/invoke.sh <network> <contract_name> <function> [args...]Arguments:
network:testnetormainnetcontract_name: Contract name (must be indeployed-contracts.json)function: Contract function to invokeargs: Function arguments (optional)
Examples:
# Initialize shared contract
./scripts/invoke.sh testnet shared initialize GBUQWP3BOUZX34ULNQG23RQ6F4YUSXHTQSXUSMIQ75XABZXVQRLLOG4
# Record progress
./scripts/invoke.sh testnet analytics record_progress <student_id> <course_id> <progress>Requirements:
STELLAR_SECRET_KEYenvironment variable must be set- Contract must be deployed first (run
./scripts/deploy.sh) deployed-contracts.jsonmust exist with contract IDsjqmust be installed for JSON parsing
Features:
- Reads contract ID from
deployed-contracts.json - Validates network and contract name
- Error handling with
set -euo pipefail
Stores contract IDs for each network and contract.
Format:
{
"testnet": {
"analytics": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4",
"token": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4",
"shared": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4"
},
"mainnet": {
"analytics": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4",
"token": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4",
"shared": "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4"
}
}Auto-updated by: deploy.sh after successful deployment
All scripts require:
STELLAR_SECRET_KEY: Your Stellar account secret key for signing transactions
Example:
export STELLAR_SECRET_KEY="SAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA"
./scripts/deploy.sh testnet analyticsAll scripts use set -euo pipefail for robust error handling:
set -e: Exit on any errorset -u: Exit on undefined variableset -o pipefail: Exit if any command in a pipe fails
bash(v4+)stellar-cli(v21.5.0+)jq(for JSON parsing in deploy.sh and invoke.sh)cargo(for build.sh)
export STELLAR_SECRET_KEY="your-secret-key"Ensure the contract directory exists and contains a Cargo.toml file.
Run ./scripts/build.sh first to build all contracts.
Install jq:
# macOS
brew install jq
# Ubuntu/Debian
sudo apt-get install jq
# CentOS/RHEL
sudo yum install jq