CLV Documentations
Portal
Portal
  • Welcome to Clover
  • Useful Links
  • CLV Token
  • Quick Start
    • Clover Networks
    • Sakura Networks
    • Using Local Node
    • Using Testnet
      • Create an account
      • Faucet
      • Run a Testnet Node
      • Connect to Testnet
  • Development Guide
    • Introduction
      • Prerequisites
      • Setup environment
    • Using MetaMask
    • Using Remix
    • Using Web3.js
      • Query Balance
      • Send Transaction
    • Counter Tutorial
      • Setup dapp project
      • Setup truffle
      • The Counter Contract
      • Deploy Contract
      • Counter Webapp
  • Clover Wallets & Dapps
    • Clover Extension Wallet
      • Getting Started
      • Switch Networks
      • Add Tokens
      • Send Tokens
      • Cross-Chain Transfer
      • View Seed Phrase
      • Import Account
      • dApp Integration
      • Substrate dApp Integration
      • Solana-dApp-Integration
      • dApp Interaction Protocol
      • Wallet Integration QA
    • Clover Mobile Wallet
    • Clover Web Wallet
      • dApp Integration
    • Clover Assets Explorer
    • Clover Cross-Chain Explorer
  • Maintain
    • Running a validator on Clover Network
    • Running a RPC node
    • Staking on Clover
      • Staking via Apps
      • Staking via Clover Wallet
  • Technical Documentation
    • Web3 compatibility
      • eth_protocolVersion
      • eth_syncing
      • eth_hashrate
      • eth_coinbase
      • eth_mining
      • eth_chainId
      • eth_gasPrice
      • eth_accounts
      • eth_blockNumber
      • eth_getBalance
      • eth_getStorageAt
      • eth_getBlock
      • eth_getTransactionCount
      • eth_getBlockTransactionCount
      • eth_getBlockUncleCount
      • eth_getCode
      • eth_sendTransaction
      • eth_sendSignedTransaction
      • eth_call
      • eth_estimateGas
      • eth_getTransaction
      • eth_getTransactionByBlockHashAndIndex
      • eth_getTransactionByBlockNumberAndIndex
      • eth_getTransactionReceipt
      • eth_getUncle
      • eth_getLogs
      • eth_getWork
      • eth_submitWork
      • eth_submitHashrate
      • eth_subscribe
      • eth_unsubscribe
      • net_version
      • net_peerCount
      • net_listening
      • web3_clientVersion
      • web3_sha3
    • Clover Test Cases
    • Clover EVM
    • Clover Accounts Binding
    • Query Balance
    • Transaction Finality
  • Clover Eco Incentive Program
    • Introduction
    • Clover Developer Incentive Program
    • Virtual Ethereum address binding
    • Clover User Incentive Program
  • Parachain Auction
    • About Polkadot Parachain Auction
Powered by GitBook
On this page
  • Create a project using create-react-app
  • Add counter state and buttons
  1. Development Guide
  2. Counter Tutorial

Setup dapp project

PreviousCounter TutorialNextSetup truffle

Last updated 4 years ago

Create a project using create-react-app

Let's start with creating a frontend project using create-react-app.

npx create-react-app counter-dapp

This command takes a little while to complete, be pertinent. You need to confirm the installation of create-react-app if it's your first time using this command.

Once the command complete, start the web app:

cd counter-dapp
yarn start

A browser window will be opened and who the web app. You can visit either.

Add counter state and buttons

We'll add a simple text to show the current value of the counter state.

"Inc" and "Dec" buttons to update the counter state.

Edit src/App.js and set the App() function looks like below:

function App() {
  return (
    <div className="App">
      <header className="App-header">
        <h1>Counter Example</h1>
        <p>
            Current value: n/a
        </p>
        <button className="CounterButton">Inc Counter</button>
        <button className="CounterButton">Dec Counter</button>
      </header>
    </div>
  );
}

Edit src/App.css and add the css class CounterButton. You can make your customizations as you like.

.CounterButton {
  background-color: #4CAF50;
  border: none;
  color: white;
  margin-top: 15px;
  padding: 15px 32px;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  font-size: 16px;
  width: 200px;
}

The webpage will be reloaded after you saved the files.

Now you can see we're having the basic page layout!

The source code of this chapter could be found at the revision fdb1b9e5f in the source repo.

🌽
🛠️
http://localhost:3000/
counter-dapp