Skip to content

Latest commit

 

History

History
184 lines (125 loc) · 3.18 KB

File metadata and controls

184 lines (125 loc) · 3.18 KB

Contract Deployment Guide (Stellar Testnet)

This guide explains how to deploy all smart contracts to the Stellar Soroban testnet.


1. Prerequisites

Ensure you have the following installed:

  • Rust (latest stable)
  • Soroban CLI
  • Stellar CLI
  • A funded Stellar testnet account (via Friendbot)

Recommended: Use the tokenbound CLI (cross-platform)

This repo includes a Node-based CLI that wraps the Soroban CLI and automates the dependency-ordered deployment.

From the repo root:

npm install
npm run tokenbound -- deploy --network testnet --source deployer

Deployment output is written to soroban-contract/deployments/<network>.json by default.

Install Soroban CLI

cargo install --locked soroban-cli

Add WASM target

rustup target add wasm32-unknown-unknown

2. Setup Environment

Create environment variables:

export NETWORK=testnet
export SOROBAN_RPC_URL="https://soroban-testnet.stellar.org"
export ADMIN_SECRET_KEY="S..."
export ADMIN_ADDRESS="G..."

Fund your account:

curl "https://friendbot.stellar.org?addr=$ADMIN_ADDRESS"

3. Build Contracts

From the root directory:

cargo build --target wasm32-unknown-unknown --release

Optimise contracts:

soroban contract optimize --wasm target/wasm32-unknown-unknown/release/*.wasm

4. Deployment Order

Deploy contracts in the following order:

  1. ticket_factory
  2. event_manager
  3. tba_registry

5. Deploy Contracts

Deploy Ticket Factory

soroban contract deploy \
  --wasm <path_to_ticket_factory.wasm> \
  --source $ADMIN_SECRET_KEY \
  --rpc-url $SOROBAN_RPC_URL

Save the returned Contract ID:

export TICKET_FACTORY_ID="C..."

Deploy Event Manager

soroban contract deploy \
  --wasm <path_to_event_manager.wasm> \
  --source $ADMIN_SECRET_KEY \
  --rpc-url $SOROBAN_RPC_URL
export EVENT_MANAGER_ID="C..."

Deploy TBA Registry

soroban contract deploy \
  --wasm <path_to_tba_registry.wasm> \
  --source $ADMIN_SECRET_KEY \
  --rpc-url $SOROBAN_RPC_URL
export TBA_REGISTRY_ID="C..."

6. Contract Initialization

Initialize each contract with required parameters.

Example:

soroban contract invoke \
  --id $TICKET_FACTORY_ID \
  --source $ADMIN_SECRET_KEY \
  --rpc-url $SOROBAN_RPC_URL \
  -- initialize \
  --admin $ADMIN_ADDRESS

Repeat for other contracts using their respective parameters.

7. Verification Steps

After deployment:

  • Confirm contract IDs are returned
  • Call a read method:
soroban contract invoke \
  --id $TICKET_FACTORY_ID \
  --source $ADMIN_SECRET_KEY \
  --rpc-url $SOROBAN_RPC_URL \
  -- some_view_function
  • Ensure no errors are returned
  • Check events on Soroban explorer

8. Troubleshooting

Contract fails to deploy

  • Ensure account has enough XLM
  • Check RPC URL

WASM not found

  • Ensure build step completed successfully

Initialization fails

  • Ensure correct parameters are passed
  • Check contract already initialized

CLI errors

soroban --version

9. Notes

  • Always deploy in the correct order
  • Store contract IDs securely
  • Never expose secret keys in code