Skip to content

feat: Add a stellar contract info wasm-hash command #1878

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Dhanraj30
Copy link
Contributor

What

Closes: #1877
This PR adds a new command wasm-hash to the stellar contract CLI, allowing developers to retrieve the Wasm hash of a deployed contract directly from the command line.

Why

Currently, developers have to rely on more complex methods, such as using RPC calls or parsing logs, to obtain the Wasm hash of a contract. This new command simplifies the process, making it more convenient and efficient for developers to access the Wasm hash directly. It enhances the usability of the CLI by providing a straightforward command that outputs the hash in a format suitable for scripting and automation.

Get the Wasm hash of a deployed contract.

Usage

stellar contract wasm-hash --network <NETWORK> --contract-id <CONTRACT_ID>

Arguments

  • --network: The network to use (e.g., testnet, futurenet, mainnet, or custom URL)
  • --contract-id: The ID of the deployed contract to get the Wasm hash for

Example

# Get the Wasm hash for a contract on testnet
stellar contract wasm-hash --network testnet --contract-id CDSJWGUPY2HFHYNLT3EZX7YGJ4X7YMWPQWHHGNKB6IVH6WRXAJFI7627

# Output:
283f8e42a3585aa3a511c06c7d09a94d66762773cdf493cc4afc455d7b68adcf

Notes

  • The contract must be deployed on the specified network
  • The hash is returned in hexadecimal format
  • The command requires a network connection to retrieve the contract data


@Dhanraj30 Dhanraj30 marked this pull request as ready for review February 17, 2025 10:11
Copy link
Member

@leighmcculloch leighmcculloch left a comment

Choose a reason for hiding this comment

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

👏🏻 This looks good, thanks for contributing.

There's a few small things that need fixing up. I've left comments inline on each.

The other thing this needs is an test. Tests that use commands and interact with an RPC are located in the following directory:

cmd/crates/soroban-test/tests/it

The way the tests work may not be intuitive because it's pretty bespoke. Let me know if that's something that you get stuck on.

Thanks again!

@sagpatil sagpatil requested a review from fnando May 28, 2025 19:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Backlog (Not Ready)
Development

Successfully merging this pull request may close these issues.

Add a stellar contract info wasm-hash command
2 participants