Smart contracts are self-executing contracts. They were first proposed by Nick Szabo in the 90s. They are set of rules and protocols which two parties agree upon and have to follow. One of the main features is that they are immutable once deployed on the blockchain. It is widely used in the Ethereum blockchain. The main language used for writing smart contracts in Solidity.
IDE
To write and execute solidity codes, the most common IDE used is an online IDE known as REMIX. You can either open it online on https://remix.ethereum.org/ or install it in your system from https://github.com/ethereum/remix-ide. You can also use Mist (the Ethereum DApp browser).
After you write the code and compile it you can deploy it in following ways –
- Remix VM (London)
- Remix VM (Berlin)
- Injected Provider – MetaMask
- Hardhat Provider
- Ganache Provider
- Foundry Provider
- Wallet Connect
- External Http Provider
- L2 – Optimism Provider
- L2 – Arbitrum One Provider
This article explains how to deploy your contract by using MetaMask as Injected Provider – MetaMask.
MetaMask
MetaMask is a type of Ethereum wallet that bridges the gap between the user interfaces for Ethereum (e.g. Mist browsers, DApps) and the regular web (e.g. Chrome, Firefox, websites).
Its function is to inject a JavaScript library called web3.js into the namespace of each page your browser loads. Web3.js is written by the Ethereum core team. MetaMask is mainly used as a plugin in chrome. You can add it from here or download it directly from this link.
After adding MetaMask as an extension in chrome and creating an account, set up your account as follows –
Step 1: Select Goerli Test Network from a list of available networks as below:
.png)
Metamask
Step 2: Request test ether by using this link : https://goerlifaucet.com/
-(1).png)
Goerli Faucet
Step 3: MetaMask is ready for deployment. To know more about MetaMask visit the MetaMask official guide.
Steps to deploy your contract
Step 1: Open Remix IDE in your browser. After opening click on + and write the filename as follows:

Step 2: Write the following sample code for testing and compile by clicking on the compile button as shown:
Solidity
pragma solidity ^0.8.17;
contract shreyansh_05
{
function get_output() public pure returns (string memory){
return ( "Hi, your contract ran successfully" );
}
}
|
.png)
Compile the ni.sol file
Step 3: After compilation and move to deploy section just below the compilation and select Injected Provider – MetaMask in place of Remix VM as shown below –

Select the Injected Provider – Metamask
Step 4: Now your contract is ready to be deployed. Click on deploy button and the MetaMask will ask for confirmation as follows –

Click the Confirm Button
Step 5: After confirmation, the deployed contract will look like –

Deployed Contract
Step 6: Expand the deployed contract as below and get the output using the get_output() function:

Output
Step 7: Now, to verify whether your transaction (process) executed successfully, you can check your balance on MetaMask.
Now your contract is completely ready to function. Make sure the compiler version matches the version of your solidity code. This is the basic implementation of MetaMask with solidity.
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
08 Jan, 2023
Like Article
Save Article