{"id":582,"date":"2022-03-03T07:19:02","date_gmt":"2022-03-03T07:19:02","guid":{"rendered":"https:\/\/metaschool.so\/articles\/?p=582"},"modified":"2023-01-06T07:22:20","modified_gmt":"2023-01-06T07:22:20","slug":"remix-ide-ethereum","status":"publish","type":"post","link":"https:\/\/metaschool.so\/articles\/remix-ide-ethereum\/","title":{"rendered":"Getting started with Remix IDE &#8211; Ethereum"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_56_1 ez-toc-wrap-left counter-hierarchy ez-toc-counter ez-toc-custom ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title \" >Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 ' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/metaschool.so\/articles\/remix-ide-ethereum\/#Creating_a_new_Smart_Contract_in_Remix\" title=\"Creating a new Smart Contract in Remix\">Creating a new Smart Contract in Remix<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/metaschool.so\/articles\/remix-ide-ethereum\/#Creating_smart_contract_logic\" title=\"Creating smart contract logic\">Creating smart contract logic<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/metaschool.so\/articles\/remix-ide-ethereum\/#Compiling_and_deploying_the_contract\" title=\"Compiling and deploying the contract\">Compiling and deploying the contract<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/metaschool.so\/articles\/remix-ide-ethereum\/#Updating_the_variable\" title=\"Updating the variable\">Updating the variable<\/a><\/li><\/ul><\/nav><\/div>\n\n<p>Remix IDE is an open-source web and desktop application. It is a powerful open-source tool that helps you <a href=\"https:\/\/metaschool.so\/courses\/writing-your-first-hello-world-contract-in-solidity?ref=Articles&amp;utm_source=Blog_Organic\" target=\"_blank\" rel=\"noreferrer noopener\">write Solidity contracts<\/a> straight from the browser.<\/p>\n\n\n\n<p>Remix-IDE is available at&nbsp;<a target=\"_blank\" href=\"https:\/\/remix.ethereum.org\/\" rel=\"noreferrer noopener\">remix.ethereum.org<\/a>. The project is available at&nbsp;<a target=\"_blank\" href=\"https:\/\/github.com\/ethereum\/remix-project\" rel=\"noreferrer noopener\">GitHub Repository<\/a>&nbsp;and the docs are available at this&nbsp;<a target=\"_blank\" href=\"https:\/\/remix-ide.readthedocs.io\/en\/latest\/\" rel=\"noreferrer noopener\">link<\/a>.<\/p>\n\n\n\n<p>When you first visit Remix IDE you will see this window.<\/p>\n\n\n\n<div class=\"wp-block-image is-style-default\"><figure class=\"aligncenter\"><img decoding=\"async\" src=\"https:\/\/cdn.hashnode.com\/res\/hashnode\/image\/upload\/v1639881331307\/AykYO1kQ5.png?auto=compress,format&amp;format=webp\" alt=\"An Image of remix homepage\"\/><\/figure><\/div>\n\n\n\n<p>There will be three default folders in remix namely&nbsp;<code>contracts<\/code>,&nbsp;<code>scripts<\/code>, and&nbsp;<code>tests<\/code>.<\/p>\n\n\n\n<p>There will be three smart contracts( .sol files ) inside the contracts folder and two scripts( .js files ) inside the scripts folder and one test( .sol file ) inside the test folder.<\/p>\n\n\n\n<p><strong>Explore:<\/strong>\u00a0<a href=\"https:\/\/metaschool.so\/articles\/how-to-get-an-ens-domain\/?ref=Articles&amp;utm_source=Blog_Organic\" target=\"_blank\" rel=\"noreferrer noopener\"><a href=\"https:\/\/metaschool.so\/courses\/how-to-write-a-smart-contract-and-mint-elon-musk-nft-on-opensea\">How to write a smart contract and NFT on OpenSea<\/a><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"heading-creating-a-new-smart-contract-in-remix\"><span class=\"ez-toc-section\" id=\"Creating_a_new_Smart_Contract_in_Remix\"><\/span>Creating a new Smart Contract in Remix<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Create a new&nbsp;<code>MyContract.sol<\/code>&nbsp;file inside the contracts folder. You can create a new file by clicking the file button at the top of the folders.<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/cdn.hashnode.com\/res\/hashnode\/image\/upload\/v1639882223818\/gIITKdVTg.png?auto=compress,format&amp;format=webp\" alt=\"An Image of file icons on top of folders\"><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"heading-creating-smart-contract-logic\"><span class=\"ez-toc-section\" id=\"Creating_smart_contract_logic\"><\/span>Creating smart contract logic<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We will create a simple smart contract that will store and update a variable in the blockchain.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>\/\/ SPDX-License-Identifier: GPL-3.0\n\npragma solidity &gt;=0.7.0 &lt;0.9.0;\n\ncontract MyContract { \n    \/\/ state variable num\n    uint256 public num;\n\n    \/\/ function sets value of variable num equal to _num \n    function setNum(uint256 _num) public returns(uint256) {\n        num = _num;\n        return num;\n    }\n}\n<\/code><\/pre>\n\n\n\n<p>You can view the gist&nbsp;<a href=\"https:\/\/gist.github.com\/AbhinavXT\/7a9ea55b2eac95acbd265e134d3d216a\" target=\"_blank\" rel=\"noreferrer noopener\">here<\/a>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"heading-compiling-and-deploying-the-contract\"><span class=\"ez-toc-section\" id=\"Compiling_and_deploying_the_contract\"><\/span>Compiling and deploying the contract<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>To compile the contract click on the solidity icon on the left menu.<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/cdn.hashnode.com\/res\/hashnode\/image\/upload\/v1639884120059\/7ms0WrEzJ.png?auto=compress,format&amp;format=webp\" alt=\"An Image of solidity compiler on remix\"><\/p>\n\n\n\n<p>Now click on&nbsp;<code>Compile MyContract.sol<\/code>&nbsp;to compile the contract. If the contract compiles perfectly, you will see a green tick with the solidity icon(as shown in the image above).<\/p>\n\n\n\n<p><strong>Bookmark for later<\/strong>:\u00a0<a href=\"https:\/\/metaschool.so\/courses\/how-does-ethereum-work-a-deepdive?ref=Articles&amp;utm_source=Blog_Organic\" target=\"_blank\" rel=\"noreferrer noopener\">How does Ethereum work?<\/a><\/p>\n\n\n\n<p>To deploy the contract click on the Ethereum icon on the left menu and then click on the&nbsp;<code>Deploy<\/code>&nbsp;button.<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/cdn.hashnode.com\/res\/hashnode\/image\/upload\/v1639887732264\/uq3mmmZ6E.png?auto=compress,format&amp;format=webp\" alt=\"An Image of deploy and run transaction on remix\"><\/p>\n\n\n\n<p>After deploying the contract you will see your contract under the deployed contracts (as shown in the image above).<\/p>\n\n\n\n<p>Now we can test the smart contract by updating the&nbsp;<code>num<\/code>&nbsp;variable.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"heading-updating-the-variable\"><span class=\"ez-toc-section\" id=\"Updating_the_variable\"><\/span>Updating the variable<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>We can update the&nbsp;<code>num<\/code>&nbsp;variable, using the&nbsp;<code>setNum<\/code>&nbsp;function by entering an integer value as shown below and then clicking on&nbsp;<code>setNum<\/code>(in orange color). This will store the integer value, that we enter inside the num variable.<\/p>\n\n\n\n<p class=\"has-text-align-center\"><img decoding=\"async\" src=\"https:\/\/cdn.hashnode.com\/res\/hashnode\/image\/upload\/v1639886808726\/M7YPlfM12.png?auto=compress,format&amp;format=webp\" alt=\"An image showing functions and updated variables\"><\/p>\n\n\n\n<p>Now you can check the value of the variable by clicking on&nbsp;<code>num<\/code>(in blue color). The value stored inside num will be displayed below it(as shown in the image above).<\/p>\n\n\n\n<p><strong>Congratulations! You have built and tested a smart contract on Remix IDE. <\/strong><\/p>\n\n\n\n<p>If you need to try out something more challenging, enroll in this course \ud83e\udd19\ud83c\udffc <a href=\"https:\/\/metaschool.so\/courses\/launch-your-own-epic-nft-marketplace?ref=Articles&amp;utm_source=Blog_Organic\" target=\"_blank\" rel=\"noreferrer noopener\">Launch your own epic NFT marketplace<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":5,"featured_media":589,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"neve_meta_sidebar":"","neve_meta_container":"","neve_meta_enable_content_width":"","neve_meta_content_width":0,"neve_meta_title_alignment":"","neve_meta_author_avatar":"","neve_post_elements_order":"","neve_meta_disable_header":"","neve_meta_disable_footer":"","neve_meta_disable_title":"","footnotes":""},"categories":[14],"tags":[31,45,47,46],"class_list":["post-582","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-web3","tag-ethereum-blockchain","tag-remix-ethereum-ide","tag-smart-contracts","tag-solidity"],"_links":{"self":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/582","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/users\/5"}],"replies":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/comments?post=582"}],"version-history":[{"count":9,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/582\/revisions"}],"predecessor-version":[{"id":4454,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/posts\/582\/revisions\/4454"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/media\/589"}],"wp:attachment":[{"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/media?parent=582"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/categories?post=582"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/metaschool.so\/articles\/wp-json\/wp\/v2\/tags?post=582"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}