Deploying smart contract, how to use this handle?


When I deploy a smart contract I get a transaction hash object in return. How do I use this to address the module afterwards i.e. to create an instance of it?
Do I use this hash to get some indexes or what exactly do I do with this information?

Hi petlan,

Are you using concordium client for this?
If so, this guide will help you: Initialize a smart contract instance — Concordium documentation

You might also be interested in our piggy bank tutorial, which has been expanded with parts three and four, which describe the process of deploying, initializing and interacting with the contract: The piggy bank smart contract — Concordium documentation

Best regards
/ Kasper


I’m using the SDK (C#) and I did do the piggy bank. that’s the contract that I deployed.
The SDK sample for deploying, results in a transaction hash, and I’m not sure how to use this for anything.

Ah okay,

I don’t know if the SDK is complete yet and I haven’t used it myself.
But something like this should work:

  1. Deploy the module and get the transactionHash.
  2. Get the blockHash for the block in which the transaction was included with GetTransactionStatus(transactionHash)
  3. Get a summary of block with GetBlockSummary(blockHash) and find the moduleReference in the data returned.
  4. Use the moduleReference to initialize the contract.

Step 3 might require a bit of digging in the data returned.

Have a nice afternoon
/ Kasper

1 Like

Just to chime in:
I find the transaction and block hash useful as reference for later. I can save it in my frontend app so that I can query the chain later about a particular transaction and which block it was written to. I can for example share the transaction hash (with link to concordium dashboard) with the user/customer so that he/she can see transaction him/herself on the chain for extra info.