Step-by-step guide on deploying your DApp on the Calimero private shard
Favour Kelvin
November 30, 2023
•
5 minutes
If you're a blockchain enthusiast or a developer looking to add your decentralized application to the Calimero private shard, then you are in the right place. In this step-by-step guide, we'll walk you through the process of setting up your Calimero private shard and deploying your DApp by running a smart contract in the shard.
Let’s dive in!
Prerequisites
To get started, you will need to have the following :
Next, specify a name for your cluster and choose the region where you want to create it.
Once you've configured the cluster settings, Calimero will initiate the cluster creation process.
Creating Workspaces
The next step is to create your workspaces. We have two workspace types that serve different purposes:
Developer Workspace: Designed to meet your development needs (Testnet)
Professional Workspace: Offers options for both Mainnet and Testnet environments.
Creating your Developer Workspace.
If you choose the developer option, follow these steps to set it up
Add your workspace name and description
Add your chain name and description
Click Create Workspace & Chain
Your Developer Workspace will be created, and your shard will be set up within it.
Creating a Professional Workspace - Mainnet or Testnet Environment
For a professional workspace, you have the Mainnet or Testnet options. You can choose either of them, depending on your needs
Note: The steps below are similar for both Mainnet and Testnet workspace environments.
Select the workspace environment you want to set up
Configure the number of validator nodes, RPC nodes, archive RPC nodes, and indexer nodes you need for your workspace.
Click Next
Add your workspace name and description
Click Next
Your professional workspace environment will be created, and your shard will be set up within it.
Generate an Auth token
Before deploying your DApp on the Calimero private shard, you must generate a Calimero auth token. This token will authenticate and authorize external applications to communicate with the shard.
To create an auth token:
Click on the Security dropdown in the left navigation menu.
Click on Tokens > Create new token.
Choose a name for your auth token.
Select a duration for the token.
Configure the token's permissions by selecting the appropriate checkboxes.
Click on Generate Token.
Once the token is issued, you can copy it to your clipboard or request that it be emailed to you.
Note: Be sure to store it in a secure location, as it will be required to communicate with your private shard. The token cannot be obtained afterwards, which means you’ll have to issue a new token if you forget its value.
Set up the NEAR CLI
Once this is done you need to set up the near-cli to make it work with the Calimero shard. For this, we will make use of the token we generated in the previous step.
In your terminal, run the following commands:
$ near set-api-key https://rpc.testnet.near.org AUTH_TOKEN
A keypair is used to create a subaccount in the console by using a public key. To get the public key, we use near generate-key and the workspace account name you created in the console.
near generate-key $workspace-name
Replace workspace-name with your workspace account name.
The next step is to create a subaccount. This subaccount is created from the Custodial account in the Calimero Console. The public key obtained from the previous step is used to create the subaccount.
In your console, go to Shard Management > Custodial accounts
Click on Add account
Add your account ID and public key generated from the keypair
Note: Your account ID should be both your application name and your workspace name for easy identification. For exampledocschain.ws-chat
Build the smart contract
After successfully creating your subaccount, you’ll need to compile your smart contract and deploy it on the Calimero shard. You can build your contract directly from the terminal by running the following code in your terminal
# Installing Rust in Linux and MacOS
curl --proto '=https' --tlsv1.2 https://sh.rustup.rs -sSf | sh
source $HOME/.cargo/env
# Add the wasm toolchain
rustup target add wasm32-unknown-unknown
In your application code, create a deploy_calimero.sh file and copy the following code
near deploy \
--accountId "YOUR_APPLICATION_NAME.$destination_master_account" \
--wasmFile target/wasm32-unknown-unknown/release/curb.wasm \
--initFunction new --initArgs '{"name": "Calimero"}' \
--nodeUrl "https://api.staging.calimero.network/api/v1/shards/$1-calimero-testnet/neard-rpc" \
--networkId "$1-calimero-testnet"
Run the following command in your terminal to deploy the contract:
./deploy_calimero.sh $workspace-name
This command will deploy the application to the NEAR contract using the provided parameters.
On the console, go to Explorer > Transactions to check the deployed contract
That’s it!
By following the steps above, you can set up your private shard and deploy your contracts in a matter of seconds. You can also connect to private or public blockchain applications like DeFi, NFTs, on-chain KYC, and more without compromising confidentiality and privacy.