You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We should add an additional sub-command cargo contract info to display information regarding contracts on a chain. This is required to ease the friction for building third-party tooling.
What to implement
The new sub-command cargo contract info should take an argument --contract AccountId, as well as support the alternative CONTRACT environment variable (which we already do for cargo contract instantiate/call). Invoked like this, information regarding the specified contract should be returned.
For most of this ticket you should be able to reuse existing code. I would start by copying the functionality for cargo contract call and modify it to fit the needs of cargo contract info. You will automatically get the same cli flags as cargo contract call/instantiate/upload, so e.g. --suri, --ws-url, etc.
You can throw out everything regarding transaction submission, for cargo contract info you will only need to do RPC queries. In our code those are often behind functions called dry_run, as dry runs of e.g. a contract call happen to estimate the gas costs. This is done via RPC.
Big Picture
We should add an additional sub-command
cargo contract info
to display information regarding contracts on a chain. This is required to ease the friction for building third-party tooling.What to implement
The new sub-command
cargo contract info
should take an argument--contract AccountId
, as well as support the alternativeCONTRACT
environment variable (which we already do forcargo contract instantiate/call
). Invoked like this, information regarding the specified contract should be returned.For this ticket it is sufficient to display just
ContractInfo
. This is a struct inpallet-contracts
that contains information about the contract (like its Wasm code hash). You can take a look at it here: https://github.com/paritytech/substrate/blob/2eb8ad273eeabea380fce00c10893ac788b1cbde/frame/contracts/src/storage.rs#L42-L64.For most of this ticket you should be able to reuse existing code. I would start by copying the functionality for
cargo contract call
and modify it to fit the needs ofcargo contract info
. You will automatically get the same cli flags ascargo contract call/instantiate/upload
, so e.g.--suri
,--ws-url
, etc.You can throw out everything regarding transaction submission, for
cargo contract info
you will only need to do RPC queries. In our code those are often behind functions calleddry_run
, as dry runs of e.g. a contract call happen to estimate the gas costs. This is done via RPC.We don't have logic to query storage of a contract yet in
cargo-contract
, but it should be similar to this code here: https://github.com/paritytech/subxt/blob/master/testing/integration-tests/src/frame/contracts.rs#L214-L219.polkadot-js
supports getting this data. This is how it looks there:The text was updated successfully, but these errors were encountered: