Skip to content

feat: add scripts/verify_contract.sh to check deployed contract on Stellar Expert#1028

Open
joshuaolabodebello2020-cyber wants to merge 1 commit into
StellarCheckMate:mainfrom
joshuaolabodebello2020-cyber:feature/897-verify-contract-script
Open

feat: add scripts/verify_contract.sh to check deployed contract on Stellar Expert#1028
joshuaolabodebello2020-cyber wants to merge 1 commit into
StellarCheckMate:mainfrom
joshuaolabodebello2020-cyber:feature/897-verify-contract-script

Conversation

@joshuaolabodebello2020-cyber

Copy link
Copy Markdown
Contributor

Summary

Closes #897

After deployment there was no quick way to confirm a contract is live and accessible on Stellar Expert — developers had to manually visit the explorer. This PR adds scripts/verify_contract.sh to solve that.

What this does

  • Reads CONTRACT_ESCROW (required) and CONTRACT_ORACLE** (optional) from .env automatically — no manual argument required for the common case
  • Prints Stellar Expert URLs for both testnet and mainnet:
    • testnet → https://stellar.expert/explorer/testnet/contract/<id>
    • mainnet → https://stellar.expert/explorer/public/contract/<id>
    • futurenet / standalone → informative note that Stellar Expert doesn't index those networks
  • Fetches the WASM hash via stellar contract info when the Stellar CLI is present (skip with --no-wasm)
  • Liveness probe — calls stellar contract invoke … get_admin for each contract and prints ✅/❌ per check
  • Contract ID format validation — warns if the value doesn't look like a valid 56-char Stellar base32 contract ID
  • --network flag to override STELLAR_NETWORK from .env without editing files
  • Exits non-zero on any failed check — composes cleanly with CI pipelines and deploy.sh

Acceptance criteria

Criterion Met
scripts/verify_contract.sh created
Reads CONTRACT_ESCROW from .env
Prints Stellar Expert URL for testnet
Prints Stellar Expert URL for mainnet
Optionally fetches WASM hash via stellar contract info
Prints clear success/failure message

Testing

The script was validated locally against all error paths before the commit:

# Missing CONTRACT_ESCROW → clear error + instructions, exit 1
bash scripts/verify_contract.sh --no-wasm

# Bad network → exit 1
CONTRACT_ESCROW=CAAA... bash scripts/verify_contract.sh --network bogus

# Bad contract ID format → warning printed, continues
CONTRACT_ESCROW=not-a-valid-id bash scripts/verify_contract.sh --no-wasm

# Testnet happy path
CONTRACT_ESCROW=CAAA... bash scripts/verify_contract.sh --network testnet --no-wasm

# Mainnet happy path with oracle
CONTRACT_ESCROW=CAAA... CONTRACT_ORACLE=CBBB... bash scripts/verify_contract.sh --network mainnet --no-wasm

# .env reading
echo 'CONTRACT_ESCROW=CAAA...' >> .env && bash scripts/verify_contract.sh --no-wasm

Files changed

  • scripts/verify_contract.sh — new file, executable (chmod +x)

…ation

Closes StellarCheckMate#897

- Reads CONTRACT_ESCROW (required) and CONTRACT_ORACLE (optional) from .env
- Prints Stellar Expert explorer URLs for testnet and mainnet
- Optionally fetches the WASM hash via `stellar contract info` (skip with --no-wasm)
- Runs a liveness probe via `stellar contract invoke … get_admin` when the
  Stellar CLI is present, printing ✅/❌ per check
- Validates contract ID format (56 uppercase base32 chars) and warns on mismatch
- --network flag overrides STELLAR_NETWORK from .env (default: testnet)
- Exits non-zero on failure so it composes cleanly with CI and deploy.sh
- Matches project script conventions (set -euo pipefail, repo-root resolution,
  emoji output style)
@famvilianity-eng

Copy link
Copy Markdown
Contributor

please resolve conflicts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add scripts/verify_contract.sh to check deployed contract on Stellar Expert

2 participants