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

feat: show contract's code_hash upon deployment #290

Open
brunopgalvao opened this issue Aug 22, 2024 · 1 comment
Open

feat: show contract's code_hash upon deployment #290

brunopgalvao opened this issue Aug 22, 2024 · 1 comment
Labels
contracts Features related to smart contracts enhancement New feature or request UX

Comments

@brunopgalvao
Copy link
Collaborator

brunopgalvao commented Aug 22, 2024

When working with contracts, it is often useful to have the contract's code_hash.

Ask: Have pop up contract also output the contract's code_hash.

Currently, when I deploy the contract using the pop up contract command, the contract's account id is outputted but not the code_hash and depending on my development flow, I need to go to PolkadotJs Apps and look up the contract's code_hash based on the contract's account id.

Here is the output that cargo-contract gives (having the events is nice too):

cargo-contract contract upload --suri //Alice -x
      Events
       Event Balances ➜ Withdraw
         who: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
         amount: 2.376554381mUNIT
       Event Contracts ➜ CodeStored
         code_hash: 0xc5f8f1dd30008a47574c85e4213c2e9fd883fecba5f862858e0bfd68863f6155
         deposit_held: 312.56mUNIT
         uploader: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
       Event TransactionPayment ➜ TransactionFeePaid
         who: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
         actual_fee: 2.376554381mUNIT
         tip: 0UNIT
       Event System ➜ ExtrinsicSuccess
         dispatch_info: DispatchInfo { weight: Weight { ref_time: 2379752023, proof_size: 6085 }, class: Normal, pays_fee: Yes }

   Code hash 0xc5f8f1dd30008a47574c85e4213c2e9fd883fecba5f862858e0bfd68863f6155
cargo-contract contract instantiate --suri //Alice --args true -x
 Dry-running new (skip with --skip-dry-run)
    Success! Gas required estimated at Weight(ref_time: 146425616, proof_size: 16689)
Confirm transaction details: (skip with --skip-confirm or -y)
 Constructor new
        Args true
   Gas limit Weight(ref_time: 146425616, proof_size: 16689)
Submit? (Y/n): Y

      Events
       Event Balances ➜ Withdraw
         who: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
         amount: 3.381873816mUNIT
       Event Contracts ➜ CodeStored
         code_hash: 0x284b1df16ea595a2eb3f15b300d55d758a80651d6dfbafa5c03895a216d9f8cc
         deposit_held: 265.56mUNIT
         uploader: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
       Event System ➜ NewAccount
         account: 5GbGt9yBUmb58u7XBbhf6uDtRETd9MjKQrbDWT4mzy1RmhGb
       Event Balances ➜ Endowed
         account: 5GbGt9yBUmb58u7XBbhf6uDtRETd9MjKQrbDWT4mzy1RmhGb
         free_balance: 1mUNIT
       Event Balances ➜ Transfer
         from: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
         to: 5GbGt9yBUmb58u7XBbhf6uDtRETd9MjKQrbDWT4mzy1RmhGb
         amount: 1mUNIT
       Event Contracts ➜ Instantiated
         deployer: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
         contract: 5GbGt9yBUmb58u7XBbhf6uDtRETd9MjKQrbDWT4mzy1RmhGb
       Event Contracts ➜ StorageDepositTransferredAndHeld
         from: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
         to: 5GbGt9yBUmb58u7XBbhf6uDtRETd9MjKQrbDWT4mzy1RmhGb
         amount: 100.61mUNIT
       Event Contracts ➜ StorageDepositTransferredAndHeld
         from: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
         to: 5GbGt9yBUmb58u7XBbhf6uDtRETd9MjKQrbDWT4mzy1RmhGb
         amount: 100.005mUNIT
       Event Balances ➜ Deposit
         who: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
         amount: 8.886496μUNIT
       Event TransactionPayment ➜ TransactionFeePaid
         who: 5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY
         actual_fee: 3.37298732mUNIT
         tip: 0UNIT
       Event System ➜ ExtrinsicSuccess
         dispatch_info: DispatchInfo { weight: Weight { ref_time: 3377679733, proof_size: 9090 }, class: Normal, pays_fee: Yes }

   Code hash 0x284b1df16ea595a2eb3f15b300d55d758a80651d6dfbafa5c03895a216d9f8cc
    Contract 5GbGt9yBUmb58u7XBbhf6uDtRETd9MjKQrbDWT4mzy1RmhGb
@brunopgalvao brunopgalvao added enhancement New feature or request contracts Features related to smart contracts labels Aug 22, 2024
@brunopgalvao
Copy link
Collaborator Author

brunopgalvao commented Aug 22, 2024

As an ancillary feature: it would be nice to have a pop command to return a contract's info (e.g. code_hash) based on a contract’s account id e.g.:

// Returns contract info including code_hash
pop info contract 5DTZ3vQjvm77YsfcgB1z5JoJFtkw4SLZDVXx9Pdd1wziQYoD

cargo-contract has this command:

cargo-contract contract info --contract 5GbGt9yBUmb58u7XBbhf6uDtRETd9MjKQrbDWT4mzy1RmhGb
                TrieId 0x214a96574380ce769c6f84fa3e133f2264981191effaabcb534926a4611aee71
             Code Hash 0x284b1df16ea595a2eb3f15b300d55d758a80651d6dfbafa5c03895a216d9f8cc
         Storage Items 1
 Storage Items Deposit 100000000000
 Storage Total Deposit 200615000000
       Source Language ink!

@AlexD10S AlexD10S added the UX label Aug 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contracts Features related to smart contracts enhancement New feature or request UX
Projects
None yet
Development

No branches or pull requests

2 participants