Implementation Of Cryptocurrency Using Smart Contract

Introduction

 
Cryptocurrency is a type of digital currency used as a form of currency that can be transferred without the use of bank. Transaction between the two persons are usually done by the centralized platforms like bank and without the involvement of bank the transaction is not possible and to avoid such problem, cryptocurrency can be used as a mode to transfer our assets. Sometimes the bank may have some security issues and limited amount of asset can only be transferred and in cryptocurrency there is no such problems. Large amount of asset can be transferred in the form of cryptocurrency and no network issues and security issues. While making a transaction with the bank we may face high transaction fee and to avoid large transaction fee, cryptocurrency can be used and very low transaction fee is used to transfer our assets. It is peer to peer electronic cash system.
 
Own cryptocurrency and tokens can be created in the Ethereum platform. ERC 20 is a token that runs on the Ethereum blockchain and many ERC 20 tokens run on the Ethereum and Ethereum is used as the main asset to transfer the asset. Ethereum is used as gas fee to transfer the cryptocurrency and very low gas is used to transfer the digital asset and the transaction will not fail due to network issues and to speed up the transaction more gas needed to be used and very fast transaction can be possible as compared to the bank.
 
Smart contract is the set of code that runs on the top of the blockchain and it cannot be changed after the executed and the smart contract execute automatically as programmed and so it is very secure to transfer asset between the two parties. The smart contract must be deployed to the network to make the transaction and the remaining process will be automated by the smart contract with safe and secure.
 

Blockchain Technology

 
Blockchain is a decentralized digital ledger that records the transaction from many computers as blocks. The block contains list of hashes of previous blocks and transaction data. Once the data is recorded, the data cannot be altered or changed without changing the entire block.
 
 
Implementation Of Cryptocurrency Using Smart Contract
Fig 1: Working Process in Blockchain
 

Smart Contract

 
Smart contract is a set of program which implements set of operations as programmed. Smart contract runs in blockchain which is immutable once executed. Solidity is a high level language which is used to for smart contract creation. The smart contracts are executed by paying cost and the cost depends on the gas of the cryptocurrency. Smart contract execute automatically because when the contract is executed once it cannot be changed and it works automatically as coded and Smart contract audit is the process of testing the smart contract for design issues and rectify the bugs and issues in the smart contract. Smart contract is successfully deployed in the Ethereum network.
 

Compile Transaction

 
Implementation Of Cryptocurrency Using Smart Contract 
Fig. 2: Smart Contract Deployment
 

Requirements

 
Text editor
 
Text editor is used to editing the smart contract before Deployment.
 
Extension
 
Metamask extension is used to make transactions for deployment of the Smart Contract.
 
Compiler
 
Remix Ethereum is an online compiler and used for creating, compiling, and deploying the smart contract.
 
Wallet
 
Wallet is required to deploy the smart contract and the wallet address is recorded in the deployment of smart contract.
 
Byte Code
 
Byte code is generated after the smart contract and the byte code is an assembly language made up of many opcodes. Byte code is a low level language that is compiled from high level language like solidity and smart contract run on any machine and so the byte code is not human readable and machine readable.
  1. Pragma solidity ^0.4.18;  
  2. Contract sample  
  3. {  
  4.    …………….  
  5. }  
Metamask Extension
 
Metamask is a google chrome extension and this extension is used to connect local Ethereum network to the account and interact with smart contracts. Metamask extension is available in the chrome web store and install the plugin and enable the plugin to use the metamask.
 

Verifying smart contract

 
Smart contract will be public after the deployment and the verifying the smart contract is the best practice after deployment of smart contract. Any one can view the smart contract, once it is deployed and nothing will be hidden. Once contract is deployed, it will be in the Ethereum blockchain and the etherscan is the site for Ethereum blockchain and enter the contract address generated at the deployment.
 

Steps to verify smart contract

  • Click the contract tab to verify the smart contract
  • Enter verify and publish smart contract.
  • Enter the contract address and compiler version.
  • Choose the solidity files that need to be verified
  • Upload the solidity files and click to upload selected files
  • Click verify and publish.
  • A smart contract is verified successfully.

Functionalities in smart contract

 
Many functions are used to create a smart contract and the smart contract can be created in a text editor or in the remix IDE. Each function performs a different and unique operation in the solidity. The function is a set of code that can be used anytime by calling the function name. Writing the same code, again and again, will be avoided by the functions. Solidity supports modular code to write its own functions in solidity. The function keyword is used to define the function in solidity and the example for defining the function is shown below,
  1. function function-name(parameter-list) scope returns() {  
  2.    //statements  
  3. }   

Implementation of Smart Contract

 
Smart contract is written in the solidity and the smart contract must be saved in the extension of .sol. The remix Ethereum is an online platform for designing, compiling and deploying the smart contract. It has updated versions of compilers and many folders can be created as based on the requirements. Click the file option to create a new file and name it as filename.sol and there is git integration to store the smart contract in the github.
 
Implementation Of Cryptocurrency Using Smart Contract
Fig. 3: Smart contract in Online platform
 
The cryptocurrency has some properties like total supply, token name, and token symbol, and owner account and these are the details that need to be defined in the smart contract. Token name is the identifier of the token and it represents the info of the cryptocurrency. Total supply is the total number of cryptocurrencies that need to be created in the smart contract and it cannot be changed after smart contract deployment.
 
The Owner account needs to be defined in the smart contract to use burn functions to burn the token if required. Remix Ethereum is the online integrated development environment to describe the smart contract and compile the smart contract. Code the smart contract in the IDE and change the variables of the token in the smart contract.
 
The total supply of the token must be related with the decimal of the currency to mention the number of digits of the currency. The smart contract must be deployed in the testnet to avoid the errors in the mainnet and once the smart contract successfully deployed in the testnet and it will deploy in the mainnet without any errors.
 
The deployed smart contract can be viewed in the etherscan to view all the records and transactions of the smart contract.
 

Compiling and Deploying Smart Contract

 
Smart Contract is compiled in the online compiler platform Remix Ethereum and it has all compiler versions. The solidity files can be compiled in the online compiler and support two programming languages as solidity and Yul. Solidity files can be compiled in many versions and no need for any application to compile the smart contract and the Bytecode will be displayed after the compilation of the smart contract.
 
Implementation Of Cryptocurrency Using Smart Contract
Fig. 4: Compiling of Smart contract
 
Implementation Of Cryptocurrency Using Smart Contract
Fig.5 Deploying of smart contract
 
Smart contract is deployed in the same platform and three environments are available to deploy the smart contract and the injected web 3 directly connect with the wallet and make the transaction and select the contract that needs to be deployed and select deploy and the smart contract is successfully deployed and it is recorded in the blockchain.
 
The deployed contracts will be displayed below.
 

Conclusion

 
The Cryptocurrency is created from the proposed system and two solidity files are created to perform various functions to create it. The smart contract cannot be changed once it is deployed and different tasks are performed by the smart contract automatically as programmed and no need for any manual operation.Smart contract needs to be audited to ensure that there is no bug or issues in the smart contract and smart contract audit helps to remove the design issues in the contract. The cryptocurrency is launched in the blockchain and they needs to be implemented in the exchange to buy and sell and many other operations can be performed like staking and farming as they needs to be predefined in the smart contract.