♈
Bootcamp-2024
  • Intro
  • 1. Blockchain & Wallet Fundamentals
    • Blockchain Introduction
    • State Machines
    • Cryptography
    • Distributed Networks
    • Game Theory
    • What is Web3
    • MetaMask Wallet Installation
    • Transferring Tokens with MetaMask
  • 2. Smart Contract & Solidity Fundamentals
    • Using Remix
    • Create, compile and publish your first smart contract
    • Interact with already published smart contracts
    • Blockchain Explorer
    • Verify source code on Etherscan
  • 3. Oracles, ERC20 & Chainlink Data Feeds
    • Oracles
    • Create & Deploy ERC20
    • Data Feeds
  • 4. Cross-Chain Tokens With Chainlink CCIP
    • Setting up MetaMask
    • Getting USDC Testnet Tokens
    • Create Smart Contract In Remix
    • Compile and Deploy
    • Approve USDC
    • Send LINK to your Contract
    • Send USDC from Fuji to Sepolia
    • USDC on Sepolia
  • 5. Mentoring Session
  • 6. NFTs & Chainlink Automation
    • NFT Basics
    • Dynamic NFTs
    • Creating an NFT Smart Contract
    • Deploying Your Dynamic NFTs
  • 7. Chainlink CCIP & Cross-Chain NFT dApps
    • Create and deploy CCIP NFT Contracts
    • Mint on Source Chain
    • Fund Contract
    • Mint On Sepolia From Fuji
    • Mint from Destination 2 - Base Sepolia
  • 8. Random Numbers with Chainlink VRF
    • Introduction to Chainlink VRF
    • Hands On Game Using VRF
  • 9. Off-Chain Data with Chainlink Functions
    • Chainlink Functions Playground
    • Setting up MetaMask
    • Remix
    • Functions Subscription
    • Creating The Functions Consumer Contract
    • Sending a Request from Remix
    • City Weather and Examples
    • City Weather on Chainlink Functions
  • 10. Connecting the 🌏 with Chainlink
  • Glossary
Powered by GitBook
On this page
  • Create
  • Compile
  • Publish
  • Other Helpful Resources
  1. 2. Smart Contract & Solidity Fundamentals

Create, compile and publish your first smart contract

How do I make these distributed web3 concepts functional?

PreviousUsing RemixNextInteract with already published smart contracts

Last updated 1 year ago

Create

First, if we navigate back to our Workspace in Remix, we will see some folders already there for us. Click and expand the Contracts folder. This folder will already have a couple of demo Solidity files, denoted by the .sol extension, already present in the directory. We are going to right click and add a new file called Register.sol

A new file will open on the right potion of the screen. This section of the IDE is where you are able to paste the following code which creates a smart contract called "Register".

// SPDX-License-Identifier: MIT
pragma solidity 0.8.19;

contract Register {
    string private info;

    function getInfo() public view returns (string memory) {
        return info;
    }

    function setInfo(string memory _info) public {
        info = _info;
    }
}

Compile

Like we said previously, Solidity is the human readable instructions that we want to execute. In order to to get the smart contract into a machine readable format, we need to first compile the code. We perform this by selecting the compile tab. You will see that the compiler version is already selected to the correct one because our code specifies that it needs to be compiled using the second line of the file you copied.

pragma solidity 0.8.19

You will see a green checkmark on the compile tab icon once the code has been successfully compiled.

Publish

Now that we have the code we wrote in our human readable language in the machine readable format, we can deploy it to a test network. To do this, we navigate to the Deploy & Run transactions tab.

Now you are ready to "deploy" (put) your smart contract on the blockchain. All you need to do is press Deploy. You will be presented with a MetaMask Pop-up with the similar details to those found when we sent LINK between our accounts.

This window is displaying that, in order to deploy the contract to the blockchain, we must pay a gas fee. This fee is what is paid to the miners to keep the chain secure, and transfer the blockchain from one state to the next. Once the Confirm button is selected, you will see the phrase Creation of Register pending in the log output portion of the remix IDE. You will get an update in the log portion of the Remix IDE when the contract creation transaction has been fully mined to the block that the contract deployment transaction has been recorded in. You will also get a link to view that transaction and block in Etherscan.

If we return to the Deploy & Run Transaction tab on the left side of the IDE, we will see that we now have another dropdown named REGISTER AT <Contract Address>. This is a UI element that is given to us so we can interact with the deployed Register contract using a convenient graphical interface. We will explain how to using this UI to interact with our Register contract in the next section.

Other Helpful Resources

To become more familiar with the Solidity programming language and syntax feel free to visit the resources below for more help.

Learn Solidity – A Handbook for Smart Contract DevelopmentfreeCodeCamp.org
Learn Solidity
Logo
Create a New File Called Register.sol
Compiler tab compiling using our pragma
Deploy & Run Transactions Tab in Remix
Deployment contract confirmation pop-up
Example successful Deployment of the Register Smart Contract
Example deployed contract in Remix