The use of this site and the content contained therein is governed by the Terms of Use. When you use this site you acknowledge that you have read the Terms of Use and that you accept and will be bound by the terms hereof and such terms as may be modified from time to time.
All text, graphics, audio, design and other works on the site are the copyrighted works of nasscom unless otherwise indicated. All rights reserved.
Content on the site is for personal use only and may be downloaded provided the material is kept intact and there is no violation of the copyrights, trademarks, and other proprietary rights. Any alteration of the material or use of the material contained in the site for any other purpose is a violation of the copyright of nasscom and / or its affiliates or associates or of its third-party information providers. This material cannot be copied, reproduced, republished, uploaded, posted, transmitted or distributed in any way for non-personal use without obtaining the prior permission from nasscom.
The nasscom Members login is for the reference of only registered nasscom Member Companies.
nasscom reserves the right to modify the terms of use of any service without any liability. nasscom reserves the right to take all measures necessary to prevent access to any service or termination of service if the terms of use are not complied with or are contravened or there is any violation of copyright, trademark or other proprietary right.
From time to time nasscom may supplement these terms of use with additional terms pertaining to specific content (additional terms). Such additional terms are hereby incorporated by reference into these Terms of Use.
Disclaimer
The Company information provided on the nasscom web site is as per data collected by companies. nasscom is not liable on the authenticity of such data.
nasscom has exercised due diligence in checking the correctness and authenticity of the information contained in the site, but nasscom or any of its affiliates or associates or employees shall not be in any way responsible for any loss or damage that may arise to any person from any inadvertent error in the information contained in this site. The information from or through this site is provided "as is" and all warranties express or implied of any kind, regarding any matter pertaining to any service or channel, including without limitation the implied warranties of merchantability, fitness for a particular purpose, and non-infringement are disclaimed. nasscom and its affiliates and associates shall not be liable, at any time, for any failure of performance, error, omission, interruption, deletion, defect, delay in operation or transmission, computer virus, communications line failure, theft or destruction or unauthorised access to, alteration of, or use of information contained on the site. No representations, warranties or guarantees whatsoever are made as to the accuracy, adequacy, reliability, completeness, suitability or applicability of the information to a particular situation.
nasscom or its affiliates or associates or its employees do not provide any judgments or warranty in respect of the authenticity or correctness of the content of other services or sites to which links are provided. A link to another service or site is not an endorsement of any products or services on such site or the site.
The content provided is for information purposes alone and does not substitute for specific advice whether investment, legal, taxation or otherwise. nasscom disclaims all liability for damages caused by use of content on the site.
All responsibility and liability for any damages caused by downloading of any data is disclaimed.
nasscom reserves the right to modify, suspend / cancel, or discontinue any or all sections, or service at any time without notice.
For any grievances under the Information Technology Act 2000, please get in touch with Grievance Officer, Mr. Anirban Mandal at data-query@nasscom.in.
Polygon zkEVM is a preferred choice for prominent dApps such as QuickSwap, Celer cBridge, and Coinstats because of its ability to offer a fully Ethereum-equivalent zero-knowledge ecosystem for near-infinite scalability, reduced gas fees, and interoperability. If you are planning to build your dApp on the Polygon zkEVM ecosystem, this article provides a step-by-step process for deploying a smart contract on the Polygon zkEVM.
Why choose Polygon zkEVM for your dApps?
Polygon zkEVM is a zero-knowledge based Layer-2 rollup scaling solution designed to offer massive scalability while maintaining enterprise-grade security, interoperability, and quick finality for the decentralized applications running on its ecosystem. Powered by cryptographic zk-proofs, Polygon zkEVM computes all the transactions off-chain, produces validity proofs, and publishes them on the mainnet. With this innovative approach, Polygon zkEVm allows dApps to maintain EVM-equivalency, inherit security from the underlying Layer-1, and leverage ZKP-powered scalability.
Building and deploying smart contract on Polygon zkEVM
There are multiple ways to deploy a smart contract on the Polygon zkEVM ecosystem. For example, you can deploy using Hardhat, Foundry, and Remix. For this guide, let’s consider Remix IDE-based deployment.
Wallets– Any Polygon zkEVM-compatible wallet like Metamask or Coinbase wallet.
Tools- Remix.IDE for development, testing, debugging, and deployment of Polygon zkEVM smart contract. Polygon zkEVM block explorer for checking the transactions.
Assuming that you have all the prerequisites, let’s start the deployment process.
Note that these steps represent Polygon zkEVM testnet deployment. You can follow exactly the same steps for deploying smart contracts on Polygon zkEVM Mainnet..
Step:1 Configuring the Polygon zkEVM Network
To deploy your dApp on Polygon zkEVM, you first need access to the network. To do this, you need a RPC endpoint, which you can either deploy through the traditional programming-based process or the no-code way. Zeeve allows you to deploy Polygon zkEVM node via low-code, do-it-yourself method within a few clicks. Plus, the node infrastructure at Zeeve is highly optimized for load balancing, 10x faster response time, rapid synchronization, and 99.95% uptime.
Once your node is deployed, you will get a public RPC url and chain ID. Add all these details to your Metamask wallet, including the testnet explorer url; https://testnet-zkevm.polygonscan.com.
Click on Save to add Polygon zkEVM Network to your wallet’s network list. Reload the page and navigate to the ‘Select a network’ option from the wallet. A drop-down menu with all the added networks will appear. Select Polygon zkEVM testnet and switch to the network.
Step:2 Funding your Metamask wallet with test tokens
Now that you have configured the Polygon zkEVM network is configured, it’s time to fund your wallet with some test tokens. These tokens will be used to pay smart contract transaction fees during the deployment process. Before you request tokens, ensure that you are a member of Polygon discord server, because it needs authentication. Now, to get test tokens, navigate to the Polygon zkETH Faucet, select Polygon zkEVM as network, select token-type, and add wallet address.
Click on ‘Submit’. The faucet will now ask you to confirm the details once again. After that, ETH will be transferred to your wallet within 5 minutes. If you want, you can check the transaction details on the explorer.
Step:3 Building the Smart contract
The next step is to create the smart contract. For this guide, let’s build a card game-related contract similar to the popular game like Blackjack or 21. Here, the player’s objective is to obtain a hand of cards with total value close to 21 without overcalling.
The key functions of our smart contract code include:
CardValue Struct: Defines properties of a playing card, such as its symbol (suit), card (rank), and weightage (numerical value).
Mapping and Arrays: The contract has a mapping– ‘deck’ that associates each card index with its CardValue. Plus, it includes arrays for the card ranks, their associated weightage values, and the card suits.
Card Deck Initialization: The contract initializes the deck of cards by iterating across the card rank’s arrays and suits, creating a deck of 52 cards with their weightage values.
pickCardFromDeck Function: This function generates a random card index based on a combination of the caller’s address and the current block’s timestamp. Hence, it returns a random card index between 0 and 51.
hit Function: This function represents a player drawing a card from the deck. It uses the pickCardFromDeck function to select a random card, adds it to the player’s hand array, and logs the drawn card’s rank and suit. Plus, this function also determines the current total value of the player’s hand and logs whether the player has won (reached 21), lost (exceeded 21), or should continue the game.
readHandValue Function: This function calculates and returns the total weightage of the player’s hand by determining the weightage values of the cards in their hand. It also logs the total weightage in the hand.
The below smart contract is just an example. You can write your own dApp-specific smart contract, such as for DeFi app, crypto gaming app, bridges, wallet, etc, and deploy it to the Poygon zkEVM using these same methods, just the contract code will change.
Open Remix IDE, click on WORKSPACES and then create a new workspace by clicking on +create option. Within this workspace, create a new file and let’s name it Newcardgame.sol.
Next, paste the above smart contract code into the file.
Note that the above code is not fully compiled. Therefore, let’s first compile this in Solidity. Paste the entire code into the Remix console, run the ‘Solidity Compiler’ (as you can see in the below image). You will see a green check mark, upon successful compilation.
Step:4 Deploying the Smart contract on Polygon zkEVM
Finally, let’s deploy the compiled Solidity smart contract on the Polygon zkEVM testnet. Navigate through the ‘Deploy & Run Transactions’ tab on the Remix and add all the essential details such as Environment, Account address, Gas limit configuration, etc.
For our setup, we have added the following details:
The contract name will appear automatically, which is ‘Casino-New card game. Sol’ in our case.
Click on ‘Deploy’ and confirm the transaction from your Metamask wallet. Once confirmed, the contract will be deployed in a few seconds. Also, as you can see in the below image, an output representing the successful smart contract transaction will appear at the bottom of the Remix console with a green check mark.
And, that’s done! Congratulations on successfully deploying the smart contract on Polygon zkEVM. For further verification of deployment, you can check the transactions on the Polygon zkEVM block explorer.
Step:5 Calling functions from the deployed smart contract
Let’s test our Polygon zkEVM smart contract by calling some of its functions. For example, we are calling ‘hit’ and ‘readHandvalue’ functions listed at the bottom of the Remix.IDE console.
Click on hitto call this function. It will draw additional cards and check if you win or lose. The result will appear in the console.
Similarly, click on readHandvalueto call this function. This determines the game’s outcome by checking the total weightage. If the hand value touches 21, it’s a win; if it exceeds 21, it’s a loss. Again, the results will appear in the console.
As you can see, we just interacted with our Polygon zkEVM smart contract by calling some of its functions! You can call more functions, make changes in the code, or re-deploy this contract to offer more specific dApp functionalities.
About The Author
Dr. Ravi Chamria is co-founder CEO of Zeeve Inc, an Enterprise Blockchain company. He has an experience of 18+ years in IT consulting spanning across Fintech, InsureTech, Supply Chain and eCommerce. He is an executive MBA from IIM, Lucknow and a prolific speaker on emerging technologies like Blockchain, IoT and AI/ML.
Passionate About: Blockchain, Supply Chain Management, Digital Lending, Digital Payments, AI/ML, IoT
That the contents of third-party articles/blogs published here on the website, and the interpretation of all information in the article/blogs such as data, maps, numbers, opinions etc. displayed in the article/blogs and views or the opinions expressed within the content are solely of the author's; and do not reflect the opinions and beliefs of NASSCOM or its affiliates in any manner. NASSCOM does not take any liability w.r.t. content in any manner and will not be liable in any manner whatsoever for any kind of liability arising out of any act, error or omission. The contents of third-party article/blogs published, are provided solely as convenience; and the presence of these articles/blogs should not, under any circumstances, be considered as an endorsement of the contents by NASSCOM in any manner; and if you chose to access these articles/blogs , you do so at your own risk.
Zeeve is an enterprise-grade Blockchain Infrastructure Automation Platform. Join the growing list of clients that trust us with their Blockchain initiatives
Would be interesting to see how Europe’s GDPR legislation pans out with this in mind. Interesting times.Blockchain can help, but is it really the best tool for privacy?Blockchain is a secure transaction history and management system. Privacy is…
A lot of small or large businesses have realized that the Blockchain is the technology of next age. In next decades, the Blockchain Application Development is going to emerge as a revolutionary technological advancement. As a result, you can easily…
A group of major automakers from around the world, including General Motors, BMW, Ford, Bosch, ZF, and Groupe Renault has teamed up with leading blockchain experts to form a major initiative, designed to provide businesses and consumers with more…
This is the second in a Blog series titled: Blockchain Powered Smart Grid Evolution. In our previous blog we discussed electrical power distribution in economic terms and that both power and energy is a commodity to be bought, sold, and traded. [1]…