Q Remix Documentation
  • INTRODUCTION
    • Welcome to Q-Remix IDE's documentation
    • Navigating Q-Remix
    • Using Q-Remix Safely
    • Q-Remix Links
    • FAQ
  • CORE MODULES
    • File Explorer
    • Search in Files
    • Settings
    • Editor
    • Autocompletion & Suggestions in Editor
    • Contract Creation & Compiling
    • Deploy & Run
    • Accessing and Interacting with the Deployed Contracts
    • Terminal
  • Solidity modules
    • Solidity Compiler
    • AI Assistant
    • Q-Remix Chatbot
    • AI Code Generation
    • Multi AI Models switch
    • AI Project Generation
    • Debugger
  • Guide
    • Creating and Deploying a Contract
    • Importing and Loading Source Files in Solidity
  • Unit Testing
    • Testing by Example
  • MISCELLANEOUS
    • Q-Remix as Code Viewer
    • Code Contribution Guide
Powered by GitBook
On this page
  • Contract Creation
  • Compilation
  1. CORE MODULES

Contract Creation & Compiling

PreviousAutocompletion & Suggestions in EditorNextDeploy & Run

Last updated 5 days ago

Contract Creation

Q-Remix IDE uses the Monaco Editor — the same editor that powers Visual Studio Code (VS Code). This ensures a rich editing experience with features designed for both beginners and advanced smart contract developers.

Key Features:

  • Syntax Highlighting: Supports Solidity, JavaScript, and other popular languages

  • Real-time Error Highlighting: Integrated with the Solidity compiler (solc) to display errors and warnings inline

  • Auto-indentation and Bracket Matching: Enhances code readability

  • Multi-file Support: Easily switch between files and manage tabs

  • Integrated Compiler Feedback: View compilation messages, errors, and warnings directly within the editor

  • Lightweight and Fast: Runs directly in the browser without the need for setup or installation

Along with the traditional manner of coding, Q-Remix offers a unique solution to writing a simple contract to building entire projects the use of AI.

To get started with writing your smart contract in Q-Remix, follow these steps:

  1. Create a New File:

    • Navigate to the File Explorer on the left sidebar.

    • Right-click on a folder or the workspace and choose Create File.

    • Name your file with the .sol extension, such as MyContract.sol.

  2. Write Your Solidity Code:

    • The Monaco editor will open your new file where you can start writing your Solidity code.

    • Example of a simple contract:

    // Welcome to Q Remix IDE! 
    // Visit all Quranium websites at: https://quranium.org
    // Write your Solidity contract here...
    // pragma solidity ^0.8.7;
    // contract MyContract {
    // Your contract code goes here
    // }
    // SPDX-License-Identifier: MIT
    pragma solidity ^0.8.0;
    
    contract MyContract {
        uint256 public value;
    
        constructor(uint256 _value) {
            value = _value;
        }
    
        function setValue(uint256 _value) public {
            value = _value;
        }
    }

Compilation

Q-Remix uses the widely trusted Solidity Compiler (solc) to compile smart contracts directly in the browser.

After writing your smart contract, it’s time to compile it using Q-Remix's Solidity Compiler (solc). The steps below guide you through the compilation process.

1. Select the Compiler Icon

  • In the left toolbar, click the third icon from the top (🛠️ Compiler Icon).

  • This opens the Compiler Panel.

We get to choose which files to compile like following:

2. Configure the Compiler Settings

  • Solidity Compiler Version: Select the desired Solidity version from the dropdown. It’s essential to match the version that your smart contract is written for to avoid compatibility issues.

  • Target File: By default, the currently open .sol file is selected, but you can choose another file by selecting it from the file explorer if needed.

Example: If you are using the Solidity version 0.8.0, make sure you select it in the dropdown to avoid compatibility issues with newer or older versions.

3. Compile the Contract

  • Once you’ve selected the Solidity version and the target file, click Compile.

  • This will initiate the compilation process. If there are no errors, Q-Remix will generate an artifacts/ folder containing the compiled ABI (Application Binary Interface) and Bytecode.

The file currently being edited will automatically be chosen as the file to get compiler. One can change the solidity version as well as the file they want to compile in the menu. after selecting the desired compiler version and the smart contract to be compile, just click on the compile button. This will generate a artifacts folder with the contract abi and bytecode in it.

This concludes the compilation section of the smart contract you have created.

What Happens After Compilation?

  • If Compilation is Successful:

    • An artifacts/ folder will be created.

    • Inside the folder, you’ll find:

      • ABI: This is a JSON file that defines how to interact with the compiled contract.

      • Bytecode: The compiled bytecode of the contract ready for deployment.

    Example Output (Artifcats Folder):

    artifacts/
       MyContract.sol/
          MyContract.json (includes ABI, bytecode)
  • If There Are Errors:

    • The editor will highlight errors directly in the code.

    • Compilation errors and warnings will appear in the compiler panel at the bottom of the editor.

Note: Always ensure the correct Solidity version is selected to avoid compatibility issues with the imported libraries or smart contract syntax.

Best Practices:

  • Save files using Ctrl + S before compiling

  • Frequently check for compiler warnings even if compilation succeeds

  • Maintain clean and modular code structure for better AI suggestions and project generation

Important Notes

  • Correct Compiler Version: Always ensure that the correct version of Solidity is selected. Using an incompatible version may cause errors or unexpected behavior, especially if you are using libraries like OpenZeppelin or Uniswap.

    Example: If you're using OpenZeppelin contracts that require ^0.8.0, make sure the compiler is set to that version.

  • Save Your Work: It’s a good practice to save your files regularly using Ctrl + S before compiling to avoid losing any changes.

Best Practices

  • Check for Warnings: Even if the compilation is successful, always check for warnings in the compiler panel. Warnings may indicate areas of your contract that could be improved or might behave unexpectedly.

  • Modular Code: Keep your code organized and modular. This not only makes your smart contract easier to maintain, but also helps Q-Remix’s AI Assistance generate more accurate suggestions.

  • Frequent Compilation: Compile your contract frequently during development to catch errors early, especially when importing libraries or using new features.

By following this guide, you can smoothly create, compile, and deploy your smart contracts directly within Q-Remix. The combination of the Monaco Editor, integrated compiler, and AI assistance makes Q-Remix an excellent choice for developers looking to build and manage Ethereum-based projects.