Abstract

Smart contract is the heart of the Blockchain based decentralized applications. Smart contracts are the programs that get executed automatically on the Blockchain when the pre-set conditions are met. Ethereum is one of the world's largest platforms for creating decentralized applications. In Ethereum, gas (in Ether, Ethereum cryptocurrency) is used to pay miners for using their resources and running the smart contracts. It has been observed that if a smart contract is not optimized, it costs more than the required gas and therefore, the user is overcharged. Hence, optimization techniques are required to apply on smart contracts before deploying it onto the main chain. The work is broken into three modules. (1.) Designing a smart contract for storing an educational certificate on Blockchain, (2.) Writing the smart contract in Solidity using Sublime Text 3 and Remix Ethereum IDE for storing an educational certificate and then finally, (3.) Analyzing the smart contract for calculation of the gas cost which has been optimized based on the following three parameters:(a.) data types - when applied bytes32 data type is used in place of string data type, gas cost is reduced to 0.18%, (b) packaging variables into a single slot through the SOLC-using structure for packing reduces the gas cost up to the 256 bits (32 bytes) length of packed variables. Here, packed variables' length is more than 256 bits (32 bytes), hence it did not reduce the gas cost and, (c) error handling functions - no change in the cost of gas while using revert () in place of throw. So, optimization of gas cost has been considerably achieved and it can be further enhanced by increasing the number of transactions.

Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call