Cronos developer series: create & deploy a smart contract with OpenZeppelin Wizard and Remix (Low-Code)

Ken Timsit
Cronos
Published in
6 min readJul 27, 2022

As an EVM chain build on the Cosmos SDK, Cronos makes it possible for application developers to leverage the very large number of developer tools created by the Ethereum blockchain community.

In this blog post, we explore two well-known tools and explain how you can use them to create and deploy a smart contract in just a few minutes:

  • OpenZeppelin is a smart contract library that includes templates for all the common contract standards (ERC20, ERC721, ERC1155, etc.). They have launched the Contracts Wizard, an interactive user interface that makes creating a contract as easy as clicking a few check boxes.
  • Remix is an open-source online smart contract IDE hosted by the Ethereum Foundation, where developers can compile and deploy their smart contracts. See the official documentation here.

We are going to create a ERC721 NFT collection smart contract, so we are also going to use Pinata, the IPFS gateway, to store our NFT images.

Step 1 — Create and upload the NFT images to Pinata

First, create an account with Pinata.

In theory you can use a free account which will allow you to store your images in IPFS, the decentralized storage protocol, and access them via https://ipft.io/ipfs/insert_your_file_cid_here. In practice, the ipfs.io gateway is very slow and constantly times out, so you need to purchase a paid plan and use a premium gateway if you’d like to offer a proper user experience.

This step is pretty simple:

  • Create a local folder on your laptop.
  • In this folder, create the images of your NFTs and name the files 0.png, 1.png, 2.png, etc.
  • Upload the entire folder into Pinata.
  • Copy and store the CID, you will need it later.

In this example, the folder is at the following URL: https://cronoslabs.mypinata.cloud/ipfs/QmVAoYREZQ1R151ArGuTtkuP1Yz4Wb4ioNrVEtyKc79w4e/ and to access the individual files you need to add 0.png, 1.png, etc. to this string.

Step 2 — Create the NFT metadata

The NFT metadata is a JSON object, contained in a file, that contains the name, description and image URL of each NFT item.

The process is similar as in step 1:

  • Create a local folder on your laptop.
  • In this folder, create the metadata JSONs of your NFTs and name the files 0, 1, 2, etc. You can do this using any text editor, in this example we use VS Code. Each JSON should include the URL of the corresponding image. For example, the file “0” might look like this:
{"name": "Sushi #0", "description": "Sharing my favorite sushis with the world", "attributes": "", "image": "https://cronoslabs.mypinata.cloud/ipfs/QmVAoYREZQ1R151ArGuTtkuP1Yz4Wb4ioNrVEtyKc79w4e/0.png", "external_url": "https://cronos.org"}
  • The resulting folder looks like this on your local machine:
  • Upload the entire folder into Pinata.
  • Copy and store the CID, you will need it later.

In this example, the folder is at the following URL: https://cronoslabs.mypinata.cloud/ipfs/QmVqsxPUr792Pvehde4r2udny36F3SjrG68eip31Z2rVta/ and to access the individual files you need to add 0, 1, etc. to this string.

Step 3— Create the smart contract in OpenZeppelin’s Contracts Wizard

Let’s head to https://wizard.openzeppelin.com/#erc721 and complete the information. We are going to make the smart contract mintable and ownable, and use the metadata folder URL as the base URL (don’t forget the / character at the end): https://cronoslabs.mypinata.cloud/ipfs/QmVqsxPUr792Pvehde4r2udny36F3SjrG68eip31Z2rVta/

Step 4 — Deploy the smart contract to Cronos Testnet

In the OpenZeppelin contracts wizard, let’s click “Open in Remix”. This opens the Remix interface and we can click on “Compile” to check that the contract is compiling properly:

Open MetaMask and add the Cronos Testnet if you do not already have this network in your MetaMask browser extension.

If you already have it, just switch to the Cronos Testnet network.

If you need to top-up your wallet address with Test CRO (TCRO), visit the Cronos Testnet faucet: https://cronos.org/faucet

Select “Deploy and run transactions” in the left hand side menu bar, and select “Injected provider — Metamask” in the list of options under “Environment”. Make sure that the correct Account and Contract name are indicated in the tab on the left side:

Click Deploy and sign the transaction in MetaMask, making sure once again that you are deploying to the correct blockchain network (here, Cronos Testnet).

You can retrieve the contract’s address from the left hand side, and visit the Cronos Testnet block explorer at https://testnet.cronoscan.com if you’d like to see its details.

You may also use the list of functions to check that your contract functions correctly, for example we can SafeMint the first NFT to ourselves, then query the tokenURI of that NFT (number #0) to check that the smart contract returns the correct metadata URL:

What’s next?

Ideally you would like to see the NFTs that you have minted to yourself in your Crypto.com DeFi Wallet, but this will only work on Cronos Mainnet, not on Cronos Testnet.

So, once you have gotten the hang of things, deploy the same smart contract to Cronos Mainnet and mint a NFT to yourself.

Check your contract on Cronoscan (https://cronoscan.com):

You can then also check the Blockscout explorer (this is another block explorer for Cronos with a slightly different feature set, at https://cronos.org/explorer). If you enter your wallet address in the search bar, and then go to the “Tokens” tab, you can see the list of tokens that you own on Cronos.

You can check out the inventory of all the NFT items under your collection by visiting https://cronos.org/explorer/token/your_contract_address/inventory:

Finally, after 30–60 minutes or so, you should be able to see the NFT item in your Crypto.com DeFi Wallet (mobile app) under the NFT tab:

Enjoy!

Follow Cronos chain and Ken Timsit on Twitter.

--

--