How to Deploy Solidity Smart Contracts into Ethereum Blockchain Technology?

     

          Ethereum by definition is an open source public service that uses blockchain technology to aid smart contracts and cryptocurrency trading without the third party. Ethereum offers two types of accounts externally owned. The public accounts which we own our private keys. The second one is the contract account, those are the accounts on which Ethereum developers deploy all kinds of smart contracts. Ether is the currency that we are going to use in the development of our smart contract and it is the main currency that sponsors most of the InitialCoinOffering(ICOs). It is expected that at some point in the near future it even beat bitcoin in the market cap. The key difference from the mother of bitcoin is the platforms ability to trade more than just cryptocurrency.
       Wallets: There are online wallets that should be your first choice if you're a security freak or you have a big amount of money invested. But, there are software wallets that have the official blockchain of the coin for instance of Ethereum. In order for the wallet to be functional, you have to synchronize your copy of the blockchain with the official one which depending on the coin might take a lot of your hard drive and time. The software wallet of Exodus provides a user interface that provides a pretty neat user interface that makes managing your assets easy and secure in a software wallet. When you first download and install it, you will be given a mnemonic phrase of 14 words that are your back up key when your PC gets broken or software gets deleted or any kind of situation in which you lose control of your software.
          There are hardware wallets that have nano ledger and hardware devices. The website called Nanoledger looks like a flash drive that has amazing security. If you lose your ledger you can always order a new one and put the coins from the last one to the new one with the mnemonic phrase. The advantage of the hardware wallet to the software wallet is pretty much unhackable.
        Finally, there are exchange wallets that you can use on the exchange accounts to store your assets. One of the biggest exchanges called Binance are getting the security measures better every day so that people can feel safer trusting their assets to the exchanges. For instance, after you make an account you'll notice that you have several layers of protection just to get inside your account. If you try to withdraw funds, you have to verify the transaction by quote send it to your phone or authentication email or whatever option you have in the wallet. The most important thing about handling cryptocurrencies is that your knowledge and only you take the responsibility about what happens to your assets and where you trust them to kept safe.

Solidity Smart Contract Constructor:  Here, we can see the sample contract, on top of every solidity file, there is a so-called version pragma which tells the latest version of solidity supported by the contract like,
     pragma solidity version ^0.4.24
      contract ContractName{
        * Variable Declarations
        * Mapping
        * Constructor
        * Functions
        * Modifiers
   }
There is so-called version pragma which tells the lowest version of solidity supported by the contract. After that, we have the contract and its name inside we can put the variables, mapping, constructors, functions, and modifiers etc., Remix is a great online IDE but we need some kind of Git control so we can commit our changes and rollbacks if needed. The best tool to do is Truffle, Ganache, and Visual Studio code. For setting this up, you need to install node.js as well. In order to install Truffle and Ganache properly on windows, you need to run the following function "npm install -g  -production windows-build-tools". After this is finished, we need to install Truffle on our machine.

Token Creation: Open remix and create a new contract named "basic token" on top as always. Let's define our version pragma type. Below this, we create our contract type contract. Let's define a mapping of addresses into 256 this is public and it is called balanceof, this will store all the balance of wallets that had the token. Now, we would want to create the constructor that would give the creator of the contract or the initial supply of tokens when we deploy the smart contract. Create the constructor unit of initial supply and inside the brackets let's set the balanceof msg sender to be equal to initialsupply. So, it gives the sender all the tokens. For the basic token, we need a function that can transfer the ownership of the token from one wallet address to another.

          Now, let's create a function called transfer that will receive address code to enter using uint256 called value. This function has to be public and return a boolean code success. Inside the function, we need to make some restrictions. Let's first check the sender has enough tokens to send( type require balanceof msg.sender greater or equal to value). Now that we know the sender has enough money, we need to make sure that we will not overflow that number that we have(type require the balance of receiver plus the value should be greater or equal to the balance of the receiver). Now, we are ready to transfer the money. First, let's deduct the money from the sender's account(type balanceof message sender minus equal value). Then, we add this money to the address we want to send them to(type balanceof to equals value). Let's return true. So the core function would know that everything was successful. This is the basics for token creation.

Deploying Token into Rinkeby Test Network: For this work, you need to get some Ether for the Test Network. Once, you have the Ether or go to Rinkeby and get your virtual Ether for testing purposes. There are many ways to deploy your tokens or contract to the test network.
              You can directly do this by Remix.  First, make sure you logged in your metamask and the Rinkeby test network. Once, you selected the Rinkeby, then compile the contract and ensure that there are no errors present in your code. After that, go to the run tab and select the injected web tree environment, then select the account you wish to use for deployment and deploy the contract. Don't forget to specify the initial supply when you deploy the contract. Now, the metamask should pop up and ask you for the confirmation of the transaction. Confirm and wait for the transaction to be validated.
        Another method is to select the website myetherwallet and login to your wallet with metamask and deploy the contracts directly. However, you need a bytecode of the contract in order to deploy it. To get the bytecode, go to the compiled code in Rymix and click on the bytecode. This will copy the bytecode to your clipboard and paste it over there.
         The other way is to select the website of walletethereum and we can deploy the contracts directly with code or bytecode. This wallet also connects with metamask so you can confirm the deployment. These are the methods to deploy the contract in Rinkeby test network.
         Now, let's go back to remix and find out our contract address. The contract deployment must be validated by now. So, go ahead and find the contract address on Eherscan. There we will have the address of the basic token. If you successfully deploy the tokens, You can add your tokens to different wallets and send the tokens to another address.

Adding Tokens to Wallets and Sending to Another Account: Let's open the website walletethreum and add the tokens to your wallet. In order to do that, open the contract, now at the bottom we have a section called custom tokens. Click on the watch token button and add our token. If you lost our token contract address, you can go to metamask and click on the contracts that you have created. You can distinguish the contract from the icon that we have on the site. Now, we have copied the contract address and go back to the website and paste the token contract address and give the name of the token. Then, enter the symbol as MFT and at the bottom are the decimal places of our smallest unit. It means how many decimals points our token has. Let's type 0 and say OK.  You have the token added to your wallet.
      Now, we can send the tokens to another address. Let's copy the address of another wallet from metamask. If you don't have one, just click create an account. Copy the wallet address and let's click on the send buttons inside the Ethreum wallet. Here, let's choose the tokens from our main account. In the To section, let's paste the address of the second wallet. Don't forget to choose the token name and this will cost us the amount of Ether to do so. Even if you're sending custom tokens, you still have to pay for the transaction in Ether. Make sure, you have enough Ether in your account. Now, let's click on Send. The metamask will show up asking for the confirmation of the transaction. Confirm and wait for the transaction to be validated. This we can check on the EtherScan that added successfully the token to that account. We can also send tokens to another account using the metamask.

Comments