Skip to content

Add stellar contract info hash command#2576

Merged
fnando merged 3 commits intomainfrom
contract-info-hash
May 8, 2026
Merged

Add stellar contract info hash command#2576
fnando merged 3 commits intomainfrom
contract-info-hash

Conversation

@fnando
Copy link
Copy Markdown
Member

@fnando fnando commented May 8, 2026

What

Add a new stellar contract info hash subcommand that outputs the SHA-256 hash of a contract's Wasm. The source can be a local .wasm file or a deployed contract ID/alias on a network. The two flags are mutually exclusive:

stellar contract info hash --wasm path/to/file.wasm
stellar contract info hash --id CDSJWGUPY...
stellar contract info hash --id my-alias --network testnet

The hash is printed as a hex string to stdout so it can be captured into shell variables.

$ stellar contract info hash --wasm target/wasm32v1-none/release/auth.wasm
6e5ca0a5beee928ce7796abd4daa35c00d01eca176a295e53b4995831db95eb2

$ stellar contract info hash --id auth
6e5ca0a5beee928ce7796abd4daa35c00d01eca176a295e53b4995831db95eb2

$ stellar contract info hash --id $(stellar contract alias show auth 2> /dev/null)
6e5ca0a5beee928ce7796abd4daa35c00d01eca176a295e53b4995831db95eb2

$ stellar contract info hash --id $(stellar contract id asset --asset native)
❌ error: cannot fetch wasm for contract because the contract is a network built-in asset contract that does not have a downloadable code binary

Why

Closes #1877. Retrieving the Wasm hash of a deployed contract previously required either chaining curl, jq, and stellar xdr decode, or scraping informational stderr logs from unrelated commands — neither convenient for scripting.

For the --id path the implementation reads ContractExecutable::Wasm(hash) directly from the contract instance ledger entry rather than downloading the full Wasm blob, so it's a single RPC round trip with a small payload.

Known limitations

A Stellar Asset Contract has no Wasm and therefore no hash; using --id against a SAC errors out.

Copilot AI review requested due to automatic review settings May 8, 2026 21:01
@github-project-automation github-project-automation Bot moved this to Backlog (Not Ready) in DevX May 8, 2026
@fnando fnando self-assigned this May 8, 2026
@fnando fnando moved this from Backlog (Not Ready) to Needs Review in DevX May 8, 2026
@fnando fnando requested review from leighmcculloch and mootz12 May 8, 2026 21:01
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new stellar contract info hash subcommand to retrieve a contract Wasm SHA-256 hash either by hashing a local .wasm file or by reading the ContractExecutable::Wasm(hash) from a deployed contract instance via RPC (without downloading the full Wasm).

Changes:

  • Introduces stellar contract info hash CLI subcommand (with mutually exclusive --wasm and --contract-id/--id sources).
  • Adds an RPC helper to read a deployed contract’s Wasm hash from the contract instance ledger entry.
  • Adds integration tests covering local file hashing, deployed contract ID, alias resolution, and basic argument validation.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
FULL_HELP_DOCS.md Documents the new stellar contract info hash subcommand.
cmd/soroban-cli/src/wasm.rs Adds helper to fetch Wasm hash from a deployed contract’s instance entry.
cmd/soroban-cli/src/commands/contract/info/hash.rs Implements the new contract info hash command and argument parsing.
cmd/soroban-cli/src/commands/contract/info.rs Wires the new hash subcommand into contract info.
cmd/crates/soroban-test/tests/it/integration/contract/mod.rs Registers the new integration test module.
cmd/crates/soroban-test/tests/it/integration/contract/info_hash.rs Adds integration tests for contract info hash.

Comment thread cmd/soroban-cli/src/wasm.rs
Comment thread FULL_HELP_DOCS.md
Comment thread cmd/crates/soroban-test/tests/it/integration/contract/info_hash.rs
@fnando fnando force-pushed the contract-info-hash branch from 4723530 to 6652ccf Compare May 8, 2026 21:15
@fnando fnando enabled auto-merge (squash) May 8, 2026 23:36
@fnando fnando merged commit ab25f39 into main May 8, 2026
211 checks passed
@fnando fnando deleted the contract-info-hash branch May 8, 2026 23:51
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in DevX May 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Add a stellar contract info wasm-hash command

3 participants