Skip to content

Latest commit

 

History

History
99 lines (84 loc) · 2.96 KB

File metadata and controls

99 lines (84 loc) · 2.96 KB

Deployment

Prerequisites

  1. Install Soroban CLI
   cargo install --locked stellar-cli@25.0.0
  1. Create Stellar Account

    • For testnet: Friendbot
    • For mainnet: Use a secure wallet
  2. Configure Environment

   cp .env.example .env
   # Edit .env with your configuration

Deploy to Testnet

# Set network in .env
NETWORK=testnet

Deployment Records

All deployments are automatically saved in deployments:

  • testnet.json - Check for Deployed contract details

Environment Variables

Variable Description Required
NETWORK Target network (testnet/mainnet) Yes
STELLAR_SECRET_KEY Deployment account secret key Yes
TESTNET_RPC_URL Testnet RPC endpoint Yes

Verification

After deployment, verify your contracts details:

# View deployment record
cat deployments/testnet.json

Deploy contracts

Follow the following steps to deploy your contracts using the deploy.sh file

  1. Set the environment variables using set -e
  2. Set the list of contracts to read and deploy using the snippet below:
CONTRACTS=(
  payment_stream
  distributor
)
  1. Load the environment variables using source .env
  2. Created a Deployments folder, inside the folder, create two json files to keep the Contract IDs for deployment on the Testnet and Mainnet.
  3. Allow your deployment script to read the required Stellar Paraphrase using NETWORK_PARAPHRASE=${TESTNET_NETWORK_PASSPHRASE}
  4. When deploying your contracts' wasm files, loop over all the available contracts in your project using the code snippet below:
for CONTRACT in "${CONTRACTS[@]}"; do
  WASM_PATH="contracts/target/wasm32-unknown-unknown/release/${CONTRACT}.wasm"
  1. Get your depoyed CONTRACT_ID by deploying your Stellar contracts using the required details in the code block below:
CONTRACT_ID=$(stellar contract deploy \
  --wasm "$WASM_PATH" \
  --source "$STELLAR_SECRET_KEY" \
  --network "$NETWORK" \
  --network-passphrase "$NETWORK_PARAPHRASE")
  1. And, finally deploy your contract using ./scripts/deploy.sh

Initialize contracts

Once your contracts are successfully deployed, initialize the contracts in the steps below.

  1. Set the environment variables.
  2. Load your contracts in a CONTRACTS variable.
  3. Load the environment variables.
  4. Loop over the deployed contracts' addressess in the deployments folder using the snippet below.
for CONTRACT in "${CONTRACTS[@]}"; do
  CONTRACT_ID=$(jq -r ".${CONTRACT}" "$DEPLOYMENTS_FILE")
  1. Invoke the Contracts using the code block below.
stellar contract invoke \
  --id "$CONTRACT_ID" \
  --network "$NETWORK" \
  --source "$STELLAR_SECRET_KEY" \
  --network-passphrase "$NETWORK_PARAPHRASE"\
  -- \
  initialize \
  --admin "$STELLAR_SECRET_KEY"
  1. Run the code snippet below to initialize your contracts ./scripts/initialize.sh