Skip to content
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

Add a stellar contract info wasm-hash command #1877

Open
leighmcculloch opened this issue Feb 13, 2025 · 2 comments · May be fixed by #1878
Open

Add a stellar contract info wasm-hash command #1877

leighmcculloch opened this issue Feb 13, 2025 · 2 comments · May be fixed by #1878

Comments

@leighmcculloch
Copy link
Member

leighmcculloch commented Feb 13, 2025

What problem does your feature solve?

It would be handy for devs to be able to retrieve the wasm hash of a contract.

What would you like to see?

$ stellar contract info wasm-hash --network testnet --contract-id CDSJWGUPY2HFHYNLT3EZX7YGJ4X7YMWPQWHHGNKB6IVH6WRXAJFI7627
283f8e42a3585aa3a511c06c7d09a94d66762773cdf493cc4afc455d7b68adcf

What alternatives are there?

There are some other ways to get the Wasm hash that a contract ID is deployed with.

Using RPC + XDR

The RPC and any XDR decode can be used to manually retrieve the details, however this is not convenient for a developer needing the value at the command line. For example:

curl -sSLX POST https://soroban-testnet.stellar.org \
  --header 'content-type: application/json' \
  --data '{
    "jsonrpc": "2.0",
    "id": 1,
    "method": "getLedgerEntries",
    "params": {
      "keys": ["'"$(echo '{
        "contract_data": {
          "contract": "CDSJWGUPY2HFHYNLT3EZX7YGJ4X7YMWPQWHHGNKB6IVH6WRXAJFI7627",
          "key": "ledger_key_contract_instance",
          "durability": "persistent"
        }}' | stellar xdr encode --type LedgerKey)"'"]
    }
  }' | jq -r '.result.entries[0].xdr' | \
  stellar xdr decode --type LedgerEntryData | \
  jq -r '.contract_data.val.contract_instance.executable.wasm'
283f8e42a3585aa3a511c06c7d09a94d66762773cdf493cc4afc455d7b68adcf

Using log output

I'm pretty sure there are some commands in the cli where the wasm hash is outputted when retrieving the wasm for other purposes. I can't remember which one it is at the moment, but these commands exist for other purposes an the hash is only outputted in informational stderr logs, which is not accessible for scripting.

@github-project-automation github-project-automation bot moved this to Backlog (Not Ready) in DevX Feb 13, 2025
@willemneal
Copy link
Member

I advocate for hash or wasm-hash. When I read the title I thought it was going to be about the spec or wasm related info.

@leighmcculloch leighmcculloch changed the title Add a stellar contract info wasm command Add a stellar contract info wasm-wash command Feb 13, 2025
@leighmcculloch leighmcculloch changed the title Add a stellar contract info wasm-wash command Add a stellar contract info wasm-hash command Feb 13, 2025
@leighmcculloch
Copy link
Member Author

Good point. wasm-hash would remove the most ambiguity and be consistent with option names --wasm-hash that are littered throughout the cli. I've updated the title to match.

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 a pull request may close this issue.

2 participants