<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Staking7pc</title>
    <description>The latest articles on DEV Community by Staking7pc (@simplystaking).</description>
    <link>https://dev.to/simplystaking</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F618991%2F30a5ff6d-565e-47e6-9df7-ac3b92f824ec.png</url>
      <title>DEV Community: Staking7pc</title>
      <link>https://dev.to/simplystaking</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/simplystaking"/>
    <language>en</language>
    <item>
      <title>Ewasm with Parastate</title>
      <dc:creator>Staking7pc</dc:creator>
      <pubDate>Thu, 05 Aug 2021 18:16:08 +0000</pubDate>
      <link>https://dev.to/simplystaking/ewasm-with-parastate-b44</link>
      <guid>https://dev.to/simplystaking/ewasm-with-parastate-b44</guid>
      <description>&lt;p&gt;Every decentralised blockchain ecosystem requires a virtual machine to process and execute their operations. The higher the complexity of the smart contract higher the execution time and the computational power required.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EVM (Ethereum Virtual Machine)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The EVM pretty much acts like this global computer, accessible by multiple nodes throughout the world. &lt;br&gt;
So if a developer wants to host their dApp on Ethereum he can do so by deploying it on the Ethereum blockchain.The charges for doing so, is paid as the gas fee.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Whats the problem?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As with any new ecosystem, the blockchain world has evolved so rapidly and has so much adoption the EVM is&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;not as fast as it can be&lt;/li&gt;
&lt;li&gt;not as cheap as it should be&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Whats the solution?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;As with any natural system improving the performance will reduce the cost and push the ecosystem to the next level. In comes WASM or the Ethereum flavour EWASM.&lt;/p&gt;

&lt;p&gt;EWASM stands for Ethereum Web assmebly&lt;/p&gt;

&lt;p&gt;&lt;em&gt;WASM is quick&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;WASM has a stack-based, low-level binary format that’s small by default, it can load and execute quickly.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;EWASM can be precompiled&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Precompiles are unique bits of EVM bytecodes, making efficient cryptographic computations without consuming a tremendous amount of gas&lt;/p&gt;

&lt;p&gt;&lt;em&gt;EWASM supports multiple Programming languages&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;From having to develop smart contracts only in Solidity, WASM lets you develop your contracts in Rust, solidity etc.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;EWASM is the new JS&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;eWASM enjoys native support from all the major JavaScript engines &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;So whats the significance of Parastate in all this?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Given multi chain is the next obvious step, there is a need for the bridge to connect the dapp's to run in multiple blockchains.&lt;/p&gt;

&lt;p&gt;Thats where parastate comes in&lt;/p&gt;

&lt;p&gt;Parastate has the ability to run contracts developed in ethereum on substrate platform.&lt;/p&gt;

&lt;p&gt;It does so by using SSVM the fastest software execution as recognized by IEEE&lt;/p&gt;

</description>
      <category>state</category>
      <category>parastate</category>
      <category>eth</category>
      <category>dot</category>
    </item>
    <item>
      <title>Solpad - All you need to know</title>
      <dc:creator>Staking7pc</dc:creator>
      <pubDate>Sat, 15 May 2021 09:04:42 +0000</pubDate>
      <link>https://dev.to/simplystaking/solpad-all-you-need-to-know-4pbl</link>
      <guid>https://dev.to/simplystaking/solpad-all-you-need-to-know-4pbl</guid>
      <description>&lt;p&gt;Ok, what do we have here. It's the new entrant and yet very promising project Solpad. &lt;/p&gt;

&lt;p&gt;They offer 3 major services as shown below, let's take a look at each of them.&lt;/p&gt;

&lt;p&gt;The token price for the public sale varies from &lt;strong&gt;$0.014 to $0.016&lt;/strong&gt; based on the tier.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwnb23jtch7ofkxvqcv3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmwnb23jtch7ofkxvqcv3.png" alt="Screenshot 2021-05-15 at 08.05.35"&gt;&lt;/a&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                          LAUNCH PAD
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There are a number of launch pads these days and yet Solpad is something that's interesting to watch out for. Why? read below&lt;/p&gt;

&lt;h4&gt;
  
  
  ----------------------------Tier structure-----------------------------
&lt;/h4&gt;

&lt;p&gt;Let's consider a new project X that's being launched by solpad say with 100 tokens. &lt;/p&gt;

&lt;p&gt;48 tokens will be allocated to the whales' pool. To be a part of the whales pool you must have at least 280,000 PAD (solpad tokens). &lt;/p&gt;

&lt;p&gt;Take a look at the various tiers that are available.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzzt53rpjvmqfz4ywjmcw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fzzt53rpjvmqfz4ywjmcw.png" alt="Screenshot 2021-05-15 at 09.29.43"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;No matter how many whales are there the maximum that they can get is 48 and the distribution is amongst the whales not the ones in other tiers. &lt;/p&gt;

&lt;p&gt;Of course, they can be part of the other pools too, but hey! at least we are given a fair chance.&lt;/p&gt;

&lt;p&gt;Maybe the shrimp pool will be crowded. Crabs can have less than whales, anything can happen.&lt;/p&gt;

&lt;p&gt;You formulate your own strategy to give yourself the best chance. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;Everybody gets a chance is all I am trying to say.&lt;/code&gt;&lt;/p&gt;

&lt;h4&gt;
  
  
  ----------------Supports different blockchains----------------
&lt;/h4&gt;

&lt;p&gt;Solpad is built on Solana but its wings spread far and white to even other blockchain ecosystems.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Needless to say, they are no one-trick pony!&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Currently supported: Solana&lt;br&gt;
In the near future: BSC and Ethereum&lt;/p&gt;

&lt;p&gt;The number of blockchains that they will support will constantly increase.&lt;/p&gt;
&lt;h4&gt;
  
  
  ------------------------PAD tokenomics------------------------
&lt;/h4&gt;

&lt;p&gt;You can get more data from &lt;a href="https://docs.solpad.finance/tokenomics/token-metrics" rel="noopener noreferrer"&gt;this official link&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe8d7niuokcjtwtj3k9c9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe8d7niuokcjtwtj3k9c9.png" alt="Screenshot 2021-05-15 at 11.15.07"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  ------------------------------Liquidity------------------------
&lt;/h4&gt;

&lt;p&gt;The initial liquidity will start at 57.7M PAD tokens and from then on it will increase based on the schedule published &lt;a href="https://docs.solpad.finance/tokenomics/token-metrics" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We have depicted our understanding below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqob2kb0jol6nh8m5de7e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqob2kb0jol6nh8m5de7e.png" alt="Screenshot 2021-05-15 at 11.07.47"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  --------------------------Token Utility-----------------------
&lt;/h4&gt;

&lt;p&gt;What makes Solpad stand out from the rest of the fundraising platforms is the token utility.&lt;/p&gt;

&lt;p&gt;PAD token holders apart from being able to participate in the ICO's based on the number of tokens held can also vote in the DAO with the tokens. &lt;/p&gt;

&lt;p&gt;This gives PAD token holders the ability to decide how the platform moves forward like deciding the number of tokens needed for tiers, which IDO's will be conducted in the platform by voting in the governance proposals.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                          AMM DEX
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The next obvious question is after I buy tokens on Solpad how can we trade the tokens. Let's take a look&lt;/p&gt;

&lt;h4&gt;
  
  
  --------------------------------SOLSWAP------------------------
&lt;/h4&gt;

&lt;p&gt;Let's say you have participated in the IDO sale for project Y from the Solpad IDO. &lt;/p&gt;

&lt;p&gt;Usually to trade them you will have to wait until the tokens are listed on exchanges or on decentralized exchanges like Uniswap and wait for the teams to provide sufficient liquidity to be able to trade them. But in Solpad its different&lt;/p&gt;

&lt;p&gt;&lt;code&gt;This is where SOLSWAP comes in.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;SOLSWAP is the multichain DEX and will connect between Solana and other platforms. Projects which conduct their IDO on Solpad will be instantly listed on SOLSWAP.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;This means you will be able to trade instantly on SOLSWAP&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Solswap will also act as a bridge between different blockchains for example between the Solana and BSC chain where the tokens can be instantly swapped between the chains and solswap will take care of the burning the tokens in one chain and minting them in another to maintain the total supply constant.&lt;/p&gt;

&lt;h4&gt;
  
  
  --------------------------Impermanent loss--------------------
&lt;/h4&gt;

&lt;p&gt;Liquidity mining is one of the major components of the Defi space but it comes with its own risk called &lt;em&gt;Impermenant loss.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;To put it in a few words Impermanent loss happens when you provide liquidity to a liquidity pool, and the price of your deposited assets changes compared to when you deposited them. &lt;/p&gt;

&lt;p&gt;To learn more about Impermanent loss refer to &lt;a href="https://academy.binance.com/en/articles/impermanent-loss-explained" rel="noopener noreferrer"&gt;this&lt;/a&gt; article from Binance academy&lt;/p&gt;

&lt;h4&gt;
  
  
  -----------------------------Rewards---------------------------
&lt;/h4&gt;

&lt;p&gt;So to protect token holders from Impermanent loss, liquidity providers of PAD tokens will be rewarded with PAD tokens so they don't lose tokens in case of price appreciation of PAD. &lt;/p&gt;

&lt;p&gt;This provides a good incentive for token holders to provide liquidity&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                          WALLET
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The pain point with supporting multiple chains is that each chain has its own set of wallets and if you hold tokens in multiple chains it becomes difficult to manage multiple wallets. &lt;/p&gt;

&lt;p&gt;Sol wallet will allow storing tokens belonging to multiple tokens in the same wallet. Not only storing them but you can also swap the tokens between chains using the swap that will be implemented in the SOl wallet.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;ONE WALLET TO STORE THEM ALL&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Below are some of the features offered&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Store and transfer digital assets irrespective of their native chains.&lt;/li&gt;
&lt;li&gt;Connect to blockchain applications on different chains&lt;/li&gt;
&lt;li&gt;Swap seamlessly between protocols.&lt;/li&gt;
&lt;li&gt;Manage and track digital assets on different chains.
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                          INVESTORS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is an impressive list of investors who have backed this project big time. Here are a few &lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8uvvxorrqiy8mlwvw48w.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8uvvxorrqiy8mlwvw48w.jpeg" alt="WhatsApp Image 2021-05-15 at 11.12.20"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>solpad</category>
      <category>solana</category>
      <category>pad</category>
      <category>solswap</category>
    </item>
    <item>
      <title>List of 404 on Parastate</title>
      <dc:creator>Staking7pc</dc:creator>
      <pubDate>Sun, 09 May 2021 17:08:31 +0000</pubDate>
      <link>https://dev.to/simplystaking/list-of-404-on-parastate-3m17</link>
      <guid>https://dev.to/simplystaking/list-of-404-on-parastate-3m17</guid>
      <description>&lt;h2&gt;
  
  
  1 - &lt;a href="https://github.com/ParaState/pallet-ssvm"&gt;https://github.com/ParaState/pallet-ssvm&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;The link Substrate on this page as shown in screenshot shows 404&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--JMbOwCwu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/va1samkg6h69s5lhw32a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--JMbOwCwu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/va1samkg6h69s5lhw32a.png" alt="Screenshot 2021-05-09 at 18.05.08"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--_WuO-taC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nsc55lnukznnjd9g45jk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--_WuO-taC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nsc55lnukznnjd9g45jk.png" alt="Screenshot 2021-05-09 at 18.06.11"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  2 - &lt;a href="https://medium.com/ethereum-on-steroids/an-improved-paper-with-go-to-market-strategies-471e45c42dbb"&gt;https://medium.com/ethereum-on-steroids/an-improved-paper-with-go-to-market-strategies-471e45c42dbb&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;In this article the white paper is no longer accessible.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.parastate.io/assets/wp.pdf"&gt;https://www.parastate.io/assets/wp.pdf&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uLo8_wgt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ix76n26byalmhzdr6ob5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uLo8_wgt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ix76n26byalmhzdr6ob5.png" alt="Screenshot 2021-05-09 at 20.03.07"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TefYD4nx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5jkly9ry74l7nmbcv66t.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TefYD4nx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5jkly9ry74l7nmbcv66t.png" alt="Screenshot 2021-05-09 at 20.05.29"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Create Dapps and deploy smart contract with Parastate</title>
      <dc:creator>Staking7pc</dc:creator>
      <pubDate>Sat, 01 May 2021 20:38:23 +0000</pubDate>
      <link>https://dev.to/simplystaking/create-dapps-and-deploy-smart-contract-with-parastate-43ej</link>
      <guid>https://dev.to/simplystaking/create-dapps-and-deploy-smart-contract-with-parastate-43ej</guid>
      <description>&lt;p&gt;In this post, we will discuss how we can create Dapp and deploy Smart contracts in Parastate.&lt;/p&gt;

&lt;p&gt;Watch this created here in the below video&lt;/p&gt;

&lt;p&gt;&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/XqdTUAtVlSs"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;*Step1: Create a Metamask account for Parastate&lt;br&gt;
*Step2: Fund the account and connect&lt;br&gt;
*Step3: Write a Smart contract&lt;br&gt;
*Step4: Compile and deploy&lt;br&gt;
*Step5: Write Dapp with Web3.js&lt;br&gt;
*Step6: Connect Web3 with Smart contracts&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1: Create a Metamask account for Parastate
&lt;/h2&gt;

&lt;p&gt;There are numerous articles on this, you can refer one here.&lt;br&gt;
Few things to note is the &lt;/p&gt;

&lt;p&gt;&lt;code&gt;RPC url: https://rpc.parastate.io:8545/&lt;/code&gt;&lt;br&gt;
&lt;code&gt;chain id: 123&lt;/code&gt;&lt;br&gt;
&lt;code&gt;Currency symbol: STATE&lt;/code&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 2: Fund the account and connect
&lt;/h2&gt;

&lt;p&gt;To fund the account, you need to take the account created from step1 and go to the &lt;a href="http://faucet.parastate.io/" rel="noopener noreferrer"&gt;faucet&lt;/a&gt; here and request STATE tokens&lt;/p&gt;
&lt;h2&gt;
  
  
  Step3: Write a Smart contract
&lt;/h2&gt;

&lt;p&gt;To write a smart contract you need 2 things&lt;br&gt;
1 - IDE &lt;br&gt;
2 - Language&lt;/p&gt;

&lt;p&gt;We use &lt;a&gt;Buidl&lt;/a&gt; a Online IDE developed by Secondstate &lt;/p&gt;

&lt;p&gt;And for the language, we have to use Solidity. &lt;/p&gt;

&lt;p&gt;An example smart contract can be found below&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pragma solidity &amp;gt;=0.4.0 &amp;lt;0.6.0;

contract BasicContract {
  int s_amount;
  address s_owner;
  constructor() public {
  s_owner = msg.sender;
  s_amount = 0;
}

modifier onlyOwner() {
  require(msg.sender == s_owner);
  _;
}

function deposit(int v) public   {
  require(v &amp;gt;= 0);
  s_amount = s_amount + v;
}

function withdraw(int v) public onlyOwner { require(v &amp;gt;= 0);
  require(s_amount &amp;gt;= v);
  s_amount = s_amount - v;
}

function getBalance() constant public returns (int retVal) { 
  return s_amount;
}

function getAddress() constant public returns (address a) { 
  return s_owner;
}
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step4: Compile and deploy
&lt;/h2&gt;

&lt;p&gt;Once the smart contract is written you have to compile it and deploy it. &lt;/p&gt;

&lt;p&gt;To compile, click on the Compile button then you will get the ABI and the BYTECODE created, these two are important for us to connect the Smart contract code with the Dapp that we will create with Web3&lt;/p&gt;

&lt;p&gt;Once these two are done we will tap on deploy to chain.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg5re7an31nwp76myb42h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg5re7an31nwp76myb42h.png" alt="Screenshot 2021-05-01 at 21.10.38"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So to test the Smart contracts, you do not need the Dapp. &lt;br&gt;
You can see clearly there are 4 tabs, currently we should on the contracts section.&lt;/p&gt;

&lt;p&gt;After compiling and deploying, now tap on the Deployed tab. &lt;/p&gt;

&lt;p&gt;Here you will see all the functions inside the smart contract exposed. In this example we can see a deposit, withdraw, get balance and get address sections. &lt;/p&gt;

&lt;p&gt;You can click on get balances to see your balance and then you can enter an amount and tap on the deposit button. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3iglyaq631m8uhu8deo9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3iglyaq631m8uhu8deo9.png" alt="Screenshot 2021-05-01 at 21.16.31"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now move to the logs section, you can see something like this&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5qt6m2cy09fx5vhacnma.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F5qt6m2cy09fx5vhacnma.png" alt="Screenshot 2021-05-01 at 21.20.36"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is a confirmation that your smart contract was successfully deployed. &lt;/p&gt;
&lt;h2&gt;
  
  
  Step5: Write Dapp with Web3.js
&lt;/h2&gt;

&lt;p&gt;To write a Dapp UI, we need the usual suspects HTML, CSS and JS. &lt;/p&gt;

&lt;p&gt;Here is the HTML and JS code for your reference&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;html&amp;gt;
&amp;lt;body&amp;gt;
    &amp;lt;h1&amp;gt; Parastate Spartan Task &amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;label id = "AccNo-lbl"&amp;gt;&amp;lt;/label&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;label&amp;gt;Enter the amount&amp;lt;/label&amp;gt;
        &amp;lt;input id="Enter_amount"/&amp;gt; 
    &amp;lt;/div&amp;gt;
    &amp;lt;p&amp;gt; &amp;lt;/p&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;label&amp;gt;Select action&amp;lt;/label&amp;gt;        
        &amp;lt;button id="Deposit"&amp;gt;Deposit&amp;lt;/button&amp;gt;
        &amp;lt;button id="Withdraw"&amp;gt;Withdraw&amp;lt;/button&amp;gt;    
    &amp;lt;/div&amp;gt;
    &amp;lt;p&amp;gt; &amp;lt;/p&amp;gt;
    &amp;lt;label&amp;gt; Options available &amp;lt;/label&amp;gt;
    &amp;lt;p&amp;gt; &amp;lt;/p&amp;gt;
    &amp;lt;div&amp;gt;
        &amp;lt;button id="balance"&amp;gt;Get-balance&amp;lt;/button&amp;gt;        
    &amp;lt;/div&amp;gt;
    &amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;label id = "balance-lbl"&amp;gt;&amp;lt;/label&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Javascript. i have explained below how to get the values for the three variables &lt;code&gt;abi&lt;/code&gt; &lt;code&gt;bytecode&lt;/code&gt; and &lt;code&gt;cAddr&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var abi = ''
var bytecode = '';
var cAddr = '';

var instance = null;
window.addEventListener('web3Ready', function () {
  var contract = web3.ss.contract(abi);
  instance = contract.at(cAddr);
  document.getElementById('AccNo-lbl').innerHTML = "Account No : "+instance.getAddress()
});


document.querySelector("#Deposit").addEventListener("click", function () {
  var amount = document.getElementById('Enter_amount').value
  instance.deposit(amount)
});

document.querySelector("#Withdraw").addEventListener("click", function () {
  var amount = document.getElementById('Enter_amount').value
  instance.withdraw(amount)
});

document.querySelector("#balance").addEventListener("click", function () {  
  var curr_bal=instance.getBalance()
  document.getElementById('balance-lbl').innerHTML=curr_bal;  
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step6: Connect Web3 with Smart contracts
&lt;/h2&gt;

&lt;p&gt;In the JS section we need the connectivity between the Smart contract with the help of web3. &lt;/p&gt;

&lt;p&gt;Here in this example we have 3 variables&lt;/p&gt;

&lt;p&gt;var abi&lt;br&gt;
var bytecode &lt;br&gt;
var cAddr &lt;/p&gt;

&lt;p&gt;you can get &lt;code&gt;abi&lt;/code&gt; and &lt;code&gt;bytecode&lt;/code&gt; by tapping on the Contracts tab and clicking on the Compiled section&lt;br&gt;
&lt;code&gt;cAddr&lt;/code&gt; can be taken from the Deployed tab as shown in figure below&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8jo854o0czudqs1y3aa.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fp8jo854o0czudqs1y3aa.png" alt="Screenshot 2021-05-01 at 21.25.41"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once you have the above set, the below lines code gives you the smart contract instance in the variable instance.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var instance = null;
window.addEventListener('web3Ready', function () {
  var contract = web3.ss.contract(abi);
  instance = contract.at(cAddr);
  document.getElementById('AccNo-lbl').innerHTML = "Account No : "+instance.getAddress()
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;All you have to do is call the function from the instance as shown below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;document.querySelector("#Withdraw").addEventListener("click", function () {
  var amount = document.getElementById('Enter_amount').value
  instance.withdraw(amount)
});
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now you can play around with the Dapp you have created.&lt;br&gt;
Happy Coding!&lt;/p&gt;

</description>
      <category>parastate</category>
      <category>state</category>
      <category>secondstate</category>
    </item>
  </channel>
</rss>
