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.
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 3 ways –
- Injected Web3
- Web3 Provider
This article explains how to deploy your contract by using MetaMask as Injected Web3.
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).
After adding MetaMask as an extension in chrome and creating an account, set up your account as follows –
Step 1: Select Ropsten Test Network from a list of available networks as below:
Step 2: Request test ether form here.
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:
Step 4: Now your contract is ready to be deployed. Click on deploy button and the MetaMask will ask for confirmation as follows –
Step 5: After confirmation, the deployed contract will look like –
Step 6: Expand the deployed contract as below and get the output using the get_output() function:
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.
- How to use GANACHE Truffle Suite to Deploy a Smart Contract in Solidity (Blockchain)?
- Steps to Execute Solidity Smart Contract using Remix IDE
- Creating a Smart Contract that Returns Address and Balance of Owner using Solidity
- What is Smart Contract in Solidity?
- What is Escrow Smart Contract?
- What is Wallet Smart Contract?
- Smart Contract to Store Employee Details
- Interacting With Ethereum Smart Contract Using Web3js
- Deploying Smart Contract on Test/Main Network Using Truffle
- Solidity - Abstract Contract
- Blockchain | Smart Contracts
- Blockchain vs Bitcoin
- Create simple Blockchain using Python
- Implementation of Blockchain in Java
- Introduction to Blockchain technology | Set 1
- Introduction to Blockchain technology | Set 2
- How Does the Blockchain Work?
- Blockchain Forks
- Important Blockchain terminologies
- Types of Blockchain and Chain Terminology
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.