What are smart contracts? Learn and deploy your first contract.
Tags: web3, blockchain, tutorial, beginners
Published: 2023-06-13 15:27:45

Congratulate and appreciate yourself because you choose to enter the web3 world, a technical underworld that has immense potential and opportunities for devs like us. Checkout more articles related to blockchain and web3 [here ](https://dev.to/siddharthsing/roadmap-to-blockchain-development-on4)on this article series and make a presence in web3 underworld 😎.

Lets enter the web3 underworld: 

![A gif to show we are entering inside web3 underworld](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/91e5txu4xneynien7vew.gif)

##Table Of Content

- [What are Smart Contracts ](#intro)
- [Who uses smart contracts?](#users)
- [Prerequisites ](#prerequisites)
- [IDE for writing Smart Contract](#ide)
- [Miscellaneous FAQs](#misc)
  - [How do I create a smart contract in blockchain?](#q1)
  - [What is a smart contract vs blockchain?](#q2)
  - [What is an NFT smart contract?](#q3)
  - [Is Bitcoin a smart contract?](#q4)
  - [What is the smart contract platform?](#q5)
  - [What is smart contract language?](#q5)
  - [How do I make a smart contract?](#q5)
- [Writer's Support ❤️](#support)

<a name="intro"></a>
##What are Smart Contracts with Example?

Smart contracts are simple programs or codes (written in the solidity programming language) stored in a blockchain that will be triggered upon certain conditions. As simple as that. Let me give a real-life example to better explain this.

Remember the Espresso Machine in offices, 

![Espresso Machine to explain the smart contracts with real life example](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ip8thwb1vdfvcr4omzjb.jpg)

You press Espresso and put the cup below the nozzle then it will serve you the freshly made hot coffee. Your friend Peter Parker wants Cappuccino, he presses that button and got one, woohoo.

Yeah, smart contracts are that simple. They are a simple set of rules which are written in a coding language (Solidity) with the help of variables and functions similar to any other coding language.

![Espresso smart contract written in solidity in remix IDE](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6ifs9mpw5wcyxrevd695.png)

<a name="users"></a>
####Who uses smart contracts?

Anyone working on web3 projects needs to do some work with smart contracts. Now, some of us might not be so much familiar with web3 and blockchains, I advise reading this article to get a more clear understanding.

Coming to smart contracts, if you have decided to build a dApp (Decentralized Application) upon any chain which supports EVM (Ethereum Virtual Machine), you will need to write a smart contract.

* Smart contracts are basically the bridge between the decentralized application and the blockchain. Let's take the previous Espresso Machine example, here suppose Espresso Machine is a Blockchain and you as a user wants a freshly made cappuccino.
 
* What you will do is interact with the menu present on the espresso machine and press the Cappuccino button there. This menu is our smart contract, the bridge between the user and Blockchains (Espresso Machine here). 

* Upon pressing the cappuccino button the smart contract will interact with the Ethereum Blockchain (or any other depending on the user) and transfer 30 wei( = 30* 10e-18 ETH) to the owner of the smart contract and serve you the coffee.

* **The owner** of the smart contract is the address who deploys it. Also, because smart contracts are deployed only once on the main-net, the owner can't be changed, any set of rules are also unchangeable after the deployment of the smart contract.

<a name="prerequisites"></a>
##Pre-requisites

So, since you have decided to enter the web3 world and are eager to write your first smart contract, let us discuss some of the homework which you have to do, 

1. Basic Understanding of Blockchain Technology - Follow [this](https://dev.to/siddharthsing/blockchain-bitcoin-ethereum-why-should-one-care--1naa) article series from the beginning.

2. Learning Solidity - If you are good at any one programming language (c, cpp, python, etc. ) it will hardly take two-three weeks to learn solidity basics, and trust me basics are enough to start.
> Resources: [Solidity Tutorial](https://www.tutorialspoint.com/solidity/index.htm) is a very helpful website for learning solidity. Other than that DEV also has some very good articles and Youtube is always our saviour.

3. Follow me on DEV 😁

<a name="ide"></a>
##IDE (Integrated Development Environment) 

After completing the necessary prerequisites, you are ready to start coding your first Smart Contract.
 
* Now when decide to start coding something, the first thing that crosses our mind is which IDE should prefer. Here, in case of solidity, since this language is still so young, we don't have many options for IDEs available. The one which is globally preferable at this time is Remix. [Remix](https://remix.ethereum.org/#lang=en&optimize=false&runs=200&evmVersion=null) has a variety of test networks and each account in every network gives the user 100 free test ETHs which are more than sufficient for the developers.  

* Remix also gives us the option to connect our MetaMask wallets.
 
* Once you have mastered smart contracts and want to start building dApps, you need both the front end of the web or mobile app along with the backend, then you will use the IDEs preferred for respective dApps. For example, if you want to create a web dApp, you might prefer VS Code Editor.

<a name="misc"></a>
## Miscellaneous FAQs about Smart Contracts

<a name="q1"></a>
**Q1.** **How do I create a smart contract in blockchain?**

>Learn about Blockchain Technology then learn the Solidity programming language, start building your first dApp, then deploy it on the mainnet (Ethereum) or any test networks (Georli, Roopsten, etc.). After deploying you have created your first smart contract in blockchain, woohoo, congrats. One thing is here that since your smart contract is stored inside the blockchain, therefore, if you deployed your smart contract to the mainnet then it is impossible to render that contract because blockchains are immutable and irreversible. But, you can do trial and error as many times as you want with the test network chains like Georli, Ropsten, etc. or with the advanced development environments like Truffle and Ganache, Hardfat, or Foundry.

<a name="q2"></a>
**Q2.** **What is a smart contract vs blockchain?**
>Smart contracts are simple codes or rules written in solidity programming language and Blockchains (Ethereum, Binance chain, polygon, etc.) are the decentralized databases where these contracts are stored so that no one can ever render these contracts.

<a name="q3"></a>
**Q3. What is an NFT smart contract?**
>Smart contracts which deal with minting, listing, buying, selling, collecting, and viewing NFTs are called NFT smart contracts. NFTs are non-fungible tokens, which means these are some digital art, music, photographs, etc. which are up for sale digitally and are unique in the world. The biggest digital art (NFTs) market is [Opensea](https://opensea.io/). I will also be posting an article where I will create an NFT marketplace dApp from scratch soon.

<a name="q4"></a>
**Q4. Is Bitcoin a smart contract?**
>No, Bitcoin is a blockchain and BTC is its cryptocurrency. Also, Bitcoin does not support storing smart contracts on it because the founder (Satoshi Nakamoto) is a ghost. No one in the world can contact him. To run smart contracts on any chain, the chain must support EVM (Ethereum Virtual Machine). Chains like Polygon, Binance chain, and Ethereum support EVM and hence we can store smart contracts on them.

<a name="q5"></a>
**Q5.**  
* **What is the smart contract platform?**
* **What is smart contract language?**
* **How do I make a smart contract?**

> Read the article from the begginning to get all the answers thoroughly.


________________________*--End--*________________________
<a name="support"></a> 
##Writer's Support
* If you find the article useful show some ❤️ by staring some of my repositories and following me on dev.to and github.
 <div>
  <p align="middle">
  <a href="https://www.linkedin.com/in/siddharth-singh-baghel-912866190/">
  <img src="https://img.shields.io/badge/LinkedIn-0077B5?style=for-the-badge&logo=linkedin&logoColor=white">
  </a>
  <a href="https://github.com/Siddharth-sing">
  <img src="https://img.shields.io/badge/GitHub-100000?style=for-the-badge&logo=github&logoColor=white">
  </a>
  <a href="https://dev.to/siddharthsing">
  <img src="https://img.shields.io/badge/dev.to-0A0A0A?style=for-the-badge&logo=dev.to&logoColor=white">
  </a>