Quick start

Overview #

Welcome to the Smart Contract Getting Started guide. This overview explains the basic concepts of smart contract development.

If you are new to developing smart contracts on Ethereum/Polygon, we also recommend to see these two guides to learn the basics:

Glossary #

Here is part of the terminology that you will hear a lot from now on.

  • Polygon is a blockchain that runs alongside the Ethereum blockchain. It aims to provide multiple tools to improve the speed and reduce the cost and complexities of transactions on blockchain networks. It’s currency symbol is MATIC.
  • MATIC is the currency of the Polygon blockchain
  • Testnet. A testnet is an instance of a blockchain powered by the same or a newer version of the underlying software, to be used for testing and experimentation without risk to real funds or the main chain.
  • Mumbai is the testnet for Polygon blockchain.
  • Wallet. A blockchain wallet is a digital wallet that allows users to store and manage their Bitcoin, Ether, and other cryptocurrencies. 
  • Metamask is a blockchain wallet that is installed as browser extension. It’s one of the most popular crypto wallets.
  • Smart contracts are programs stored on a blockchain that run when predetermined conditions are met.
  • Remix is a web IDE (integrated development environment) for creating, running, and debugging smart contracts in the browser.
  • Deploy: Send a compiled smart contract to the blockchain.

What is a smart contract? #

When deployed to a blockchain, a smart contract is a set of instructions that can be executed without intervention from third parties. The smart contract code defines how it responds to input, just like the code of any other computer program.

A valuable feature of smart contracts is that they can store and manage on-chain assets (like ERC20 tokens), just like you can with an Ethereum wallet. Because they have an on-chain address like a wallet, they can do everything any other address can. This enables you to program automated actions when receiving and transferring assets.

What language is a smart contract written in? #

The most popular language for writing smart contracts on Ethereum and EVM Chains is Solidity. It was created by the Ethereum Foundation specifically for smart contract development and is constantly being updated. Other languages exist for writing smart contracts on Ethereum and EVM Chains, but Solidity is the language used for QCentroid smart contracts.

If you’ve ever written Javascript, Java, or other object-oriented scripting languages, Solidity should be easy to understand. Similar to object-oriented languages, Solidity is considered to be a contract-oriented language.

What does a smart contract look like? #

The structure of a smart contract is similar to that of a class in Javascript, with a few differences. For example, the following HelloWorld contract is a simple smart contract that stores a single variable and includes a function to update the value of that variable.

// SPDX-License-Identifier: MIT

pragma solidity 0.8.7;

contract HelloWorld {
  string public message;

  constructor(string memory initialMessage) {
    message = initialMessage;

  function updateMessage(string memory newMessage) public {
    message = newMessage;

What does “deploying” mean? #

Deploying a smart contract is the process of pushing the code to the blockchain, at which point it resides with an on-chain address. Once it’s deployed, the code cannot be changed and is said to be immutable.

As long as the address is known, its functions can be called through an interface, on Etherscan, or through a library like web3jsweb3pyethers, and more. Contracts can also be written to interact with other contracts on the blockchain.

What is Remix? #

Remix is a web IDE (integrated development environment) for creating, running, and debugging smart contracts in the browser. It is developed and maintained by the Ethereum foundation. Remix allows Solidity developers to write smart contracts without a development machine since everything required is included in the web interface. It allows for a simplified method of interacting with deployed contracts, without the need for a command line interface. Remix also has support for samples. This means that Remix can load code from Github.

The Remix IDE home page

Access Remix from your browser: https://remix.ethereum.org/

What is Metamask? #

Contracts are deployed by other addresses on the network. To deploy a smart contract, you need an address. Not only that, but you need an address which you can easily use with Remix. Fortunately, MetaMask is just what is needed. Metamask allows anyone to create an address, store funds, and interact with Ethereum compatible blockchains from a browser extension.

MetaMask wallet

Deploy your first contract #

You can write your first smart contract and run it in your browser without any knowledge about Ethereum or blockchains. This guide shows you how easy it is to develop smart contracts using the Solidity language, a MetaMask wallet and the Remix Development Environment. You can use all of these tools in your browser for free with no signup required.

Overview #

In general, you create and deploy your smart contracts operate using the following process:

  1. Write: Write a contract to define how the contract functions, what data it can store, what other contracts it interacts with, and what external APIs it might call.
  2. Compile: Pass your smart contract code through a compiler to translate the contract into byte code that the blockchain can understand. For example, Solidity code must be compiled before it can run in the Ethereum Virtual Machine.
  3. Deploy: Send the compiled smart contract to the blockchain. From that point forward, the contract cannot be altered. However, you can still interact with the contract in several ways.
  4. Run functions: When you run the functions that you defined for the contract, the network processes those functions and modifies the state of your contract. For some functions, the network charges a small fee to complete the work. Your contract can also have functions that transfer funds to other contracts or wallets.

This guide walks you through each step, but you must install and fund your MetaMask wallet first.

In QCentroid we use the Polygon blockchain with is more efficient and requires less gas fees than the most popluar Ethereum blockchain.

Install and fund your MetaMask wallet #

Deploying smart contracts on-chain requires a wallet and MATIC. The MATIC pays for the work required by the Polygon network to add the contract to the blockchain and store the variables. The wallet holds the MATIC that you need to pay for the transaction. Install MetaMask, configure it to use the Mumbai test network, and fund your wallet with free testnet MATIC.

  1. Install and configure the MetaMask extension in your browser.
  2. After you install the extension, open your browser extension list and click MetaMask to open MetaMask.
  3. Follow the instructions in MetaMask to create a new MetaMask wallet. The new wallet includes a 12-word mnemonic phrase. This phrase is the key to your wallet. Copy that phrase down in a very secure location that only you can access. You can use this phrase to retrieve your wallet later or add it to another browser.
  4. Set MetaMask to use the Mumbai test network:
    • Step 1: Connect your wallet and click on the dropdown of networks
    • Step 2: Click on “Custom RPC”
    • Step 3: Add the following information in the parameters in blank. Metamask Network Parameters:
      Network Name: Mumbai Testnet
      New RPC URL: https://rpc-mumbai.maticvigil.com
      Chain ID: 80001
      Currency Symbol: MATIC
      Block Explorer URL: https://polygonscan.com/
    • Step 4: Click on “Save” and you’re good to go. After completing these steps you can find the custom network in the dropdown list.
  5. Go to the a Mumbay Faucet and follow the steps to send 1 test MATIC to your MetaMask wallet address. You can copy your wallet address by clicking your account name in MetaMask. After the faucet completes the transaction, you should have 1 MATIC in your MetaMask wallet on the Mumbai testnet.

Now that you configured your wallet and funded it with testnet MATIC, you can write, compile, and deploy your contract.

Write, compile, and deploy your first smart contract #

Your first contract is a simple HelloWorld.sol example. This example shows you how to set and retrieve variables in a smart contract on-chain.

// SPDX-License-Identifier: MIT

pragma solidity 0.8.7;

contract HelloWorld {
  string public message;

  constructor(string memory initialMessage) {
    message = initialMessage;

  function updateMessage(string memory newMessage) public {
    message = newMessage;
  1. Open the example contract in the Remix IDE. Remix opens and shows the contents of the smart contract. You can modify the code in this editor when you write your own contract.Open in RemixWhat is Remix?
  2. Because the code is already written, you can start the compile step. On the left side of Remix, click the Solidity Compiler tab to view the compiler settings.
  3. For this contract, use the default compiler settings. Click the Compile HelloWorld.sol button to compile the contract. This converts the contract from Solidity into bytecode that the Ethereum Virtual Machine can understand. Remix automatically detects the correct compiler version depending on the pragma that you specify in the contract.
  4. After Remix compiles the contract, deploy it. On the left side of Remix, click the Deploy and Run tab to view the deployment settings.
  5. In the deployment settings, select the Injected Web3 environment. This tells Remix that you want to deploy your contract to the blockchain that you configured in MetaMask. You could optionally use one of the Javascript VM options, but they run in a virtual environment with no connection to an actual blockchain or QCentroid contracts.
  6. Next to the Deploy button, enter a message that you want to send with the smart contract when you deploy it. This contract has a constructor that sets an initial message when you deploy the contract.
  7. Click the Deploy button to deploy the contract and its initial message to the blockchain network. MetaMask opens and asks you to confirm payment to deploy the contract. Make sure MetaMask is set to the Mumbai network before you accept the transaction. Because these transactions are on the blockchain, they are not reversible.
  8. In the MetaMask prompt, click Confirm to approve the transaction and spend your testnet ETH required to deploy the contract.
  9. After a few seconds, the transaction completes and your contract appears under the Deployed Contracts list in Remix. Click the contract dropdown to view its variables and functions.
  10. Click the message variable. Remix retrieves and prints the initial message that you set.

The contract has an address just like your wallet address. If you save this address, you can return to your deployed contract at any time to retrieve variables or execute functions. To see details about your deployed contract, copy the contract address from the list in Remix and search for it in the Mumbai Testnet Explorer.

Run functions in your contract #

Because you deployed the contract to an actual blockchain, several nodes on the test network confirmed your payment for the smart contract. The contract, its variables, and its functions remain in the blockchain permanently. To change the message variable that is stored with your contract, run the updateMessage function.

  1. In your deployed contract, enter a new message next to the updateMessage function.
  2. Click the updateMessage button to set the new message in the contract data. MetaMask opens and asks you to confirm payment to update the state of your contract.
  3. In the new MetaMask prompt, click Confirm to approve the transaction.
  4. Click the message variable again to see the updated value. It might take a few seconds before the transaction updates the variable.

Now you know how to deploy example contracts to a test network and run the functions in those contracts. You can write your own contracts and test them using this same process.

Next, read the Quantum Random Function guide to learn how to connect your smart contracts to QCentroid QRF and retrieve on-chain quantum random numbers that your smart contracts can use for multiple purposes.

What’s next #