Solidity – Deploy a Smart Contract for Marks Management System
Solidity is a high-level language. The structure of smart contracts in solidity is very similar to the structure of classes in object-oriented languages. The solidity file has an extension .sol.
What are Smart Contracts?
Solidity’s code is encapsulated in contracts which means a contract in Solidity is a collection of code (its functions) and data (its state) that resides at a specific address on the Ethereum blockchain. A contract is a fundamental block of building an application on Ethereum.
Example: In the below example, the aim is to deploy a Smart Contract for Marks Management System by using Solidity. In this contract, the details of every student like student ID, Name, Marks, etc can be added and if one wants to give some bonus marks to students then they can also be added. After building the contract all the details of every student can be retrieved.
- The first step is to deploy the smart contract using the Remix IDE. After writing the code compile the code. When it is successfully compiled then deploy it. After deploying the contract a deployed Contract is obtained and then add the student details one by one.
- If bonus marks need to be added then add in the bonusMarks section after that click on stdCount and fetch the student details to call the stdRecords.
- Add one or more new student details in this Smart Contract by the increment of stdCount.
Step 1: Open Remix IDE.
Step 2: Click on File Explorers and select Solidity in the environment and create a new file StudentMarksMangmtSys.sol by clicking on New File section.
Step 3: Build a smart contract that contains all the details of the student with the help of Remix IDE by clicking on the file name.
Step 4: After building the contract compile it. Select the compiler version before clicking on Compile button.
Step 6: If the contract is successfully deployed then deployed contract is obtained. Open the deployed contract and add the student details and transact it.
Step 7: Add the bonus marks if you want to give them to the student and transact it after that click on the stdCount. One can see the student details after calling the stdRecords by entering the stdCount.