Files
proxmox/scripts/xdc-zero/cast-deploy-simplecsc-chain138.sh
defiQUG dbd517b279 Sync workspace: config, docs, scripts, CI, operator rules, and submodule pointers.
- Update dbis_core, cross-chain-pmm-lps, explorer-monorepo, metamask-integration, pr-workspace/chains
- Omit embedded publish git dirs and empty placeholders from index

Made-with: Cursor
2026-04-12 06:12:20 -07:00

46 lines
1.6 KiB
Bash
Executable File

#!/usr/bin/env bash
# Deploy SimpleCsc (test contract — spike only) on Chain 138 via cast.
# Usage: bash scripts/xdc-zero/cast-deploy-simplecsc-chain138.sh
# Optional: GAS_PRICE_WEI=500000000000 (raise if Besu reports replacement underpriced)
set -eo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
# shellcheck source=/dev/null
source "${PROJECT_ROOT}/scripts/lib/load-project-env.sh"
ART="${XDC_ZERO_ENDPOINT_DIR:-${HOME}/projects/XDC-Zero/endpoint}/artifacts/contracts/test/SimpleCsc.sol/SimpleCsc.json"
[[ -f "$ART" ]] || {
echo "ERROR: compile XDC-Zero endpoint first (artifact missing): $ART" >&2
exit 1
}
command -v cast >/dev/null 2>&1 || {
echo "ERROR: cast (foundry) required" >&2
exit 1
}
BC=$(jq -r '.bytecode' "$ART")
[[ -n "$BC" && "$BC" != null ]]
EXTRA=()
if [[ -n "${GAS_PRICE_WEI:-}" ]]; then
EXTRA+=(--gas-price "$GAS_PRICE_WEI")
fi
echo "Deploying SimpleCsc to RPC_URL_138=$RPC_URL_138 ..."
out=$(cast send --json --rpc-url "$RPC_URL_138" --private-key "$PRIVATE_KEY" --create "$BC" "${EXTRA[@]}" 2>&1) || {
echo "$out" >&2
echo "See docs/03-deployment/CHAIN138_XDC_ZERO_DEPLOYMENT_TROUBLESHOOTING.md (replacement / pending tx)." >&2
exit 1
}
echo "$out"
contract=$(printf '%s' "$out" | jq -r '.contractAddress // empty' 2>/dev/null || true)
if [[ -z "$contract" || "$contract" == null ]]; then
contract=$(printf '%s' "$out" | grep -oE '0x[a-fA-F0-9]{40}' | tail -1 || true)
fi
if [[ -n "$contract" ]]; then
echo "SIMPLE_CSC_CHAIN138=$contract"
echo "Append to config/xdc-zero/deployed/endpoint-chain138.env if desired."
fi