en
Back to the list

Mining ZRC-2 Tokens in Zilliqa – Your Adventure Begins Here

source-logo  cryptoknowmics.com 10 May 2022 02:35, UTC

For the past couple of years, the race to build blockchain applications has seen exponential growth in their adoption by businesses and consumers. As a result, the number of projects within this space has also increased exponentially. And yet, scalability, cost, and security continue to remain major barriers to the adoption of blockchain networks. Zilliqa aims to solve these issues with its high throughput and low-cost transaction capability. Therefore, this article aims to explain how to mine your ZRC-2 tokens in Zilliqa. Mining ZRC-2 Tokens in Zilliqa - Your Adventure Begins Here

Zilliqa Blockchain Platform

Zilliqa is a blockchain platform whose aim is to solve scalability and scalability problems. The Zilliqa platform aims to deliver high performance with low computational cost and scale. This is done at thousands of transactions per second.  With the increasing popularity of blockchain applications, the demand for the use of blockchain networks has soared. However, the scalability issue which has been existing in the blockchain technology domain has been identified as the major cause of failure of blockchain systems.   Zilliqa is trying to solve this problem by developing a new blockchain technology called “sharding.” Sharding is the breaking up of a single network into multiple parallel networks. Each network will be able to run many thousands of transactions per second. Hence, the thorough capability provided by Zilliqa has led to the attention of many enterprises across the world. Zilliqa's main aim is to solve the issues of scalability and transaction costs that have plagued blockchains since their inception. As a result, it has a high throughput capacity and a low transaction cost.  This feature has made it an attractive option for both businesses and individuals who want to conduct decentralized and secure cross-border payments. Their governance mechanism is also unique as it doesn’t reward token holders at the expense of the network.

What is ZRC-2 Token?

Miners can earn a new type of digital token called a ZRC-2 (short for Zilliqa Revenues) when they contribute their computer resources to verifying transactions on Zilliqa. These tokens are created as an incentive for miners to contribute their computer resources, i.e., CPU and GPU power, towards verifying and supporting the secure execution of smart contracts on Zilliqa's scalable platform.  Each time a new block is added to the blockchain, all active miners get awarded with new blocks containing payouts of transaction fees and newly minted tokens (also known as block rewards). In total, about 13% of all new tokens are allocated to mining rewards every year – that’s equivalent to 12.6 million tokens every year!

Creating and Dispersing Coins

  • Querying the token account balance while moving tokens across accounts
  • Obtaining the total number of tokens in circulation.
  • Enabling another person to spend tokens on your behalf, etc

Examples of ZRC

  • XGSD: First Singapore dollar-pegged stablecoin produced by Xfers is ZRC-2# 
  • gZil: ZIl token provided by the Zilliqa Seed Node Staking Program 

Checking The Compliance of the ZRC contract

It is important to ensure that your smart contract is ZRC-2 compliant before starting any integration with ZRC-2. Compatibility issues with other contracts or dApp/exchange integrations may occur if the standard is not met. However, the Developer part of this developer site has a subsection dedicated to the ZRC-2 specification.

Monitoring Arrival of ZRC-2 Deposit

To monitor every new deposit of a specific ZRC-2 token:

  1. Using the API "GetTxnBodiesForTxnBlock," poll the blockchain block by block and execute each transaction.
  2. Perform the following steps for each transaction in the TxBlock:
  • Determine if "toAddr" corresponds to the ZRC-2 token contract address. For instance, the contract address for the gZIL ZRC-2 token is a845c1034cd077bd8.32be0447239c7e4be6b21
  • Verify that the success field contains the value true. If it is false, it indicates that the network did not accept this transaction.
  • Look for Transfer or TransferFrom tag under data. Verify that the value conforms to the base16 address format of your deposit address.
  • If it matches, value is the number of tokens being sent to your deposit address from the sender.
  1. Additionally, you can examine event logs to ensure the following:
  • _eventname is equal to Transfer
  • Both "TransferSuccess" and "address" are equal to your deposit address value
  • vname sender identifies the transaction sender
  • The vname recipient refers to your deposit address.
  • vname amount represents the number of tokens sent.

Mining in Zilliqa

Mining in Zilliqa works in a similar way to Bitcoin mining. However, miners are rewarded with tokens for their contribution to the network in this process. This is done by validating transaction data through sharding and through a process known as ‘Scheduling.’ Therefore, after a transaction is scheduled, the miner will broadcast the transaction to the network to verify it and add it to the network blockchain. In Zilliqa, you can mine ZRC-2 tokens in two ways:

  1. Contracting for Scilla tokens
  2. Utilizing a ZRC-2 token maker

Contracting for Scilla tokens

The creation of ZRC-2 tokens requires a smart contract from Scilla. A ZRC-2 implementation has to allow the maintenance, monitoring, owning, and trading peer-to-peer of fungible tokens using wallets or exchanges. So, using the ZRC-2  contract published on the official website is the simplest method to get started. You can create a new contract in the Neo Savant IDE (https://ide.zilliqa.com/) and paste the reference contract into it to deploy the contract. 

Deploying the Token Contract

Click the DEPLOY button on top of the contract, then fill out the following:

  • contract-owner: This should contain information on the token's owner and the account's address that deployed the contract. It is advisable to let the address format be in base16
  • name — A descriptive name for the token you're creating should be given.
  • Symbol of your token
  • Symbol decimal — The precision level for your tokens. For instance, if you set it to 2, your token’s small denomination can be as low as 0.01. 
  • Unit supply — the total number of tokens in circulation. This number depends on the decimal you've specified. For instance, if the decimal is set to 2, setting the unit supply to 100000 will result in 1000 tokens, which is 100000 / 100. (because of 2 decimal places).

Among other things, the information above will display you the token's name, supply, and current holders (under the HOLDERS tab).

  • To make a copy of the contract's address, click on the copy button.
  • Upon completion of the fields, click the Deploy Contract button to deploy your contract. To complete the transaction, ZilPay will ask for payment. 
  • You can then enter your confirmation code.
  • After payment and deployment, your token will be created.
cryptoknowmics.com