This playbook provides a comprehensive, step-by-step guide for building, optimizing, deploying, initializing, and verifying the NotifyChain smart contracts on both Stellar Testnet and Stellar Mainnet networks.
Before starting, ensure that your development machine has the following tools installed and configured:
NotifyChain contracts are written in Rust and compile to WebAssembly (wasm32-unknown-unknown).
# Install Rust (if not already installed)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Add the WASM target
rustup target add wasm32-unknown-unknownThe Stellar CLI is used to compile, deploy, and interact with Soroban contracts.
# Install Stellar CLI
cargo install --locked stellar-cli --features opt
# Verify installation
stellar --versionTo deploy and invoke contracts, the CLI must know about the RPC nodes and passphrases of the networks. Add them to your CLI configuration:
# Add Stellar Testnet
stellar network add \
--rpc-url "https://soroban-testnet.stellar.org" \
--network-passphrase "Test SDF Network ; September 2015" \
testnet
# Add Stellar Mainnet
stellar network add \
--rpc-url "https://soroban-rpc.stellar.org" \
--network-passphrase "Public Global Stellar Network ; September 2015" \
mainnetAlternatively, you can configure these directly in your project-specific or global configuration file at .stellar/config.toml.
You need a Stellar account with sufficient XLM to cover fee and rent costs for deploying the contract.
Generate a test deployer account and fund it using Friendbot (Stellar's testnet faucet):
# Generate a test deployer keypair
stellar keys generate deployer --network testnet
# Fund the account with Friendbot
stellar keys fund deployer --network testnetFor production environments, do NOT store raw private keys in plain text. Use a hardware wallet (like Ledger) or secure key manager. To add an existing private key securely:
# Add your mainnet signing identity
stellar keys add mainnet-deployerYou will be prompted to enter your secret key securely. Ensure this account has sufficient mainnet XLM.
Deploying the smart contracts and wiring them to the off-chain stack requires setting up several environment variables.
These variables are commonly exported during CLI deployment scripting:
CONTRACT_ID: The unique 56-character string identifying your deployed contract.ADMIN_ADDRESS: The admin address that is granted authorization rights to manage contract settings.DISPUTE_RESOLVER_ADDRESS: The designated address authorized to resolve disputed tasks inTaskBounty.
Once the contracts are deployed, their IDs must be registered in the listener's environment config listener/.env.example:
STELLAR_NETWORK: Set totestnetorpublic(mainnet).STELLAR_RPC_URL: The Stellar RPC endpoint URL (e.g.,https://soroban-testnet.stellar.org:443).CONTRACT_ADDRESSES: A JSON array specifying the contract addresses and events to subscribe to.CONTRACT_ADDRESSES=[ {"address":"C_AUTOSHARE_CONTRACT_ID_HERE","events":["*"]}, {"address":"C_TASKBOUNTY_CONTRACT_ID_HERE","events":["*"]} ]
Provide the frontend dashboard dashboard/.env.example with details to query the listener:
VITE_EVENTS_API_URL: HTTP URL of the listener event feed (e.g.,http://localhost:8787/api/events).VITE_STELLAR_NETWORK: Network context (TESTNETorPUBLIC).
NotifyChain contains two primary smart contracts that must be compiled and deployed:
AutoShare- Subscription and group management contract located in contract/contracts/hello-world.TaskBounty- Decentralized task and reward board contract located in Documents/Task Bounty.
Navigate to the contract workspace and run the build command.
cd /workspaces/Notify-Chain/contract/contracts/hello-world
# Build using Stellar CLI
stellar contract buildThis outputs the WebAssembly file in target/wasm32-unknown-unknown/release/hello_world.wasm or target/wasm32v1-none/release/hello_world.wasm depending on your version.
Soroban charges transaction fees and rent based on code size. Run the optimization tool to minify the WASM:
stellar contract optimize \
--wasm target/wasm32-unknown-unknown/release/hello_world.wasmThis generates an optimized WASM file at target/wasm32-unknown-unknown/release/hello_world.optimized.wasm.
Upload the optimized WASM to the Stellar ledger using the deployer identity:
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/hello_world.optimized.wasm \
--source deployer \
--network testnetThis will print a 56-character contract ID starting with C (e.g., CAS33...).
Save this contract ID:
export AUTOSHARE_CONTRACT_ID=<returned-contract-id>The AutoShare contract requires initializing the administrator identity before it can accept groups and payments. Call the initialize_admin function:
stellar contract invoke \
--id $AUTOSHARE_CONTRACT_ID \
--source deployer \
--network testnet \
-- \
initialize_admin \
--admin <DEPLOYER_ADDRESS_OR_ADMIN_ADDRESS>Navigate to the Task Bounty folder and compile the contract:
cd /workspaces/Notify-Chain/Documents/Task\ Bounty
# Build using Stellar CLI
stellar contract buildstellar contract optimize \
--wasm target/wasm32-unknown-unknown/release/task_bounty.wasmThis generates the optimized binary at target/wasm32-unknown-unknown/release/task_bounty.optimized.wasm.
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/task_bounty.optimized.wasm \
--source deployer \
--network testnetSave the returned contract ID:
export TASKBOUNTY_CONTRACT_ID=<returned-contract-id>The TaskBounty contract requires setting up the admin address and a dispute resolver. Call the initialize function:
stellar contract invoke \
--id $TASKBOUNTY_CONTRACT_ID \
--source deployer \
--network testnet \
-- \
initialize \
--dispute_resolver <DISPUTE_RESOLVER_ADDRESS> \
--admin <ADMIN_ADDRESS>To ensure reproducible builds, verify contract validity, and guarantee correct function signatures and event catalogs, follow these verification procedures.
You can verify the compiled bytecode interface to ensure it hasn't been altered and is safe to deploy:
# Calculate SHA256 sum of the optimized contract
sha256sum target/wasm32-unknown-unknown/release/*.wasmInspect the contract ABI interface to confirm function names, categories, and parameters match the code specifications:
stellar contract inspect --wasm target/wasm32-unknown-unknown/release/hello_world.optimized.wasmVerify that all administrative, group, and scheduled notification functions appear as expected in the output.
To verify that the contract is deployed correctly, call read-only getter functions.
Query the contract version:
stellar contract invoke \
--id $AUTOSHARE_CONTRACT_ID \
--source deployer \
--network testnet \
-- \
versionExpected output: 1
Verify the contract admin address:
stellar contract invoke \
--id $AUTOSHARE_CONTRACT_ID \
--source deployer \
--network testnet \
-- \
get_adminVerify total tasks counter (should return 0 initially after deployment):
stellar contract invoke \
--id $TASKBOUNTY_CONTRACT_ID \
--source deployer \
--network testnet \
-- \
get_total_tasksTo verify that the contract is emitting events correctly:
- Call a state-changing method (such as creating an AutoShare group or task).
- Query the Stellar network logs for the emitted events.
# Query recent ledger events for the contract
stellar contract event \
--network testnet \
--id $AUTOSHARE_CONTRACT_ID \
--start-ledger <ledger-number-of-deployment>Verify that the output contains the correct event topics (e.g. AutoshareCreated) and matching data values.