How To Deploy And Interact With Smart Contract Using Cirrus Core Wallet On Stratis Blockchain

Introduction

This article provides you with detailed information on how to deploy and call a contract using Cirrus core Private net wallet. So, once your contract code is ready to deploy and you have already validated the contract, generated the byte code and contract hash using the Smart Contract tool (Sct tool) then you can follow the below steps. The process of deploying and calling contracts using Cirrus Core wallet in mainnet, testnet, and privatenet are similar. However, in this article, we will deploy and interact with the contract in the private network using Cirrus Core private Net wallet.

Prerequisites

  • Cirrus Core Private Net Wallet
  • Contract Bytecode

Deploy Smart Contract using Cirrus Core Private Net wallet

At this point, you might have already been familiar with Cirrus Core Private Net Wallet. If not you can check the previous article. Once you have this wallet, Login to Wallet using the default wallet name: cirrusdev and password: password.

Step 1 - Go to Smart Contract Tab

For deploying and interacting with Smart Contract, go to the Smart Contract Tab. To deploy the Contract, click on Create Contract button as illustrated below.

deploy Smart Contract using Cirrus Core Private Net wallet

Step 2 - Deploy Contract

Then, provide all necessary fields and parameters specific to your contract, the byte code of your contract, and finally, click create contract button as shown below. In this demonstration, we are going to use the bytecode of the Hello world contract that we already obtained in the previous article. If you are new to this article, you can follow the article obtain bytecode and hash of Smart contract, and get the contract bytecode from there.

As this example Contract doesn’t need parameters to pass, I haven’t supplied it. However, if you need you must supply the parameters based on your contract code by clicking the Add a parameters option.

deploy Smart Contract using Cirrus Core Private Net wallet

Note: Depending on the Smart Contract, Gas limit can be varied. Follow the Stratis Academy for Gas pricing. If your contract requires parameters then see the parameters serialization to know how to pass.

Step 3 - Check Contract Dashboard

When it is deployed you can see the contract is created in the Smart contract Dashboard as illustrated below.

deploy Smart Contract using Cirrus Core Private Net wallet

Step 4 - View in Swagger

You can click the View button to view it in the Swagger as shown below.

deploy Smart Contract using Cirrus Core Private Net wallet

Once you click the view button, it will launch in the Browser and you can interact/call with the deployed contract from there as well.

deploy Smart Contract using Cirrus Core Private Net wallet

Step 5 - Check Receipt

You can view the receipt of your transaction by clicking on the hash as depicted below.

deploy Smart Contract using Cirrus Core Private Net wallet

A receipt will look like below and contains information including the new Contract Address. This new Contract Address is the address of the deployed contract.

deploy Smart Contract using Cirrus Core Private Net wallet

Note: if you face any issue deploying and calling the contract, you can see the errors in the receipt itself.

Furthermore, once the Cirrus Core Private Net Wallet is running in your machine, you can interact and explore with the RESTFul API through Swagger available on http://localhost:38223/Swagger.

Contract deployment is done. Now we will interact or call deployed contract.

Calling Contract from Cirrus Core Private Net Wallet

Step 1 - Get Contract Address

From the Smart Contract tab, copy the Contract Address as depicted below.

Calling Contract from Cirrus Core Private Net Wallet

Step 2 - Go to Call Contract

Click on Call Contract Button as illustrated below.

Calling Contract from Cirrus Core Private Net Wallet

Provide the parameters, Method name, Contract address, Wallet password. In this demo my contract Method Name is SayHello and there are no parameters for this contract, so I haven’t provided those. At this step, you can refer to the code of HelloWorld contract or the contract you are going to deploy to check the required parameters.

Calling Contract from Cirrus Core Private Net Wallet

Note: Depending on the Smart Contract Gas limit can be varied. Follow the Stratis Academy for Gas pricing. If your contract requires parameters then see the parameters serialization to know how to pass.

Step 3 - Check the called contract in Dashboard

Once it is called you can see the transaction in the Smart Contract dashboard and click on the Hash as shown below to view the receipt of the Contract Call.

Calling Contract from Cirrus Core Private Net Wallet

Step 4 - Check Contract call Receipt

Once you click on Hash, your receipt of the contract call will be visible as depicted below.

You can see the return value of the Contract method.

Calling Contract from Cirrus Core Private Net Wallet

As we can see, the receipt return value contains the “Hello World!”. This is what we have coded in the Hello World Contract.

Summary

Hence, we learned to deploy the Smart Contract using Cirrus Core Private Net wallet on Stratis blockchain as well as interacted/called the contract method and got the desired result on the receipt. The process of deploying and calling or interacting with the contract using Cirrus Core wallet in testnet, mainnet, and the private network is similar. You can follow these steps to deploy and call the contract in the main net and test net as well.

In addition to Cirrus Core wallet, Smart contract deployment, and call can be done through API endpoints. For this, you check the previous article here.

Moreover, to deploy the contract in the main/live network you can find the guide here.

Complete hands-on on Stratis Blockchain can be found below.

Reference

  1. Stratis Academy
  2. Getting Started with Stratis Blockchain Development


Similar Articles