CLV Documentations
CLV DOC
CLV DOC
  • Intro to CLV
    • About CLV πŸ€
    • Clover Finance Rebrands to CLV
    • What is CLV Chain?
    • What is CLV Wallet?
    • What is $CLV Token?
    • πŸ“£ CLV Official Channels
    • 🏘 CLV Community Channels
  • Use CLV Chain
    • πŸ“š Beginner’s Guide
      • Setup CLV Wallet
      • Setup Metamask Wallet
      • How to Get $CLV
      • Bridge Other Assets to CLV P-Chain (Parachain)
    • 🌐 Network Details
    • 🏦 Economics
      • Tokenomics
      • Inflation Design
    • πŸ—³οΈGovernance
    • πŸ™‹πŸ» CLV Chain FAQ
    • CLV P-Chain EVM Explorer
    • $CLV Cross-Chain Explorer
    • $CLV Cross-Chain Transfer
  • CLV Validator & Staking
    • What are Nominator & Validator?
    • Stake as a Nominator
    • Running a Validator or RPC Node
    • Staking FAQ
  • Use CLV Wallet
    • πŸ’° Download CLV Wallet
      • Browser Extension (Google Chrome & Brave)
      • Apple iOS (Mobile)
      • Android (Mobile)
      • Web Wallet (Universal)
    • πŸ“± CLV Mobile Wallet
    • πŸ–₯ CLV Extension Wallet
    • πŸ•ΈοΈ CLV Web Wallet
  • CLV Chain Developer Guide
    • Getting Started
    • Using Local Node
      • Using MetaMask
      • Using Remix
      • Using Web3.js
    • Using Testnet
      • Create an account
      • Faucet
      • Run a Testnet Node
      • Connect to Testnet
    • dApp Example
      • Setup dApp project
      • Setup truffle
      • The Counter Contract
      • Deploy Contract
      • Counter Webapp
    • Test Cases
    • Technical Documentations
      • CLV EVM
      • Developers Incentive
      • CLV Accounts Binding
      • Virtual Ethereum Address Binding
      • Query Balance
      • Transaction Finality
      • 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
      • CLV P-Chain Integration
  • CLV Wallet Developer Guide
    • EVM dApp Integration
    • Substrate dApp Integration
    • Solana dApp Integration
    • Kadena dApp Integration
    • Aptos dApp Integration
    • Web Wallet dApp Integration
    • dApp Interaction Protocol
    • Wallet Integration QA
  • CLV Ecosystem
    • 🏞️ Ecosystem Partners
      • CLV Chain
      • CLV Wallet
    • 🌱 Incentive Programs
      • CLV Ecosystem Grant
      • CLV Wallet Integration Grant
      • CLV Bug Bounty Program
    • Whitelist Assets on Clover P-Chain
    • Bridge assets into CLV P-Chain
  • Assets
    • πŸ”€ Glossary
      • Blockchain (in General)
      • Polkadot
      • Wallet
    • 🎟️ CLV - Polkadot Parachain Auction 2021
      • Parachain Auction Rule Announcement
      • Parachain Winning Reward Announcement
    • πŸ›οΈ Brand Pack
    • πŸ“„ Whitepaper
Powered by GitBook
On this page
  • Checking Prerequisites
  • Getting Started with Remix
  • Deploying a Contract to CLV Using Remix
  • Interacting with a CLV-based ERC-20 from MetaMask
  1. CLV Chain Developer Guide
  2. Using Local Node

Using Remix

Interacting Remix with CLV

PreviousUsing MetaMaskNextUsing Web3.js

Last updated 3 years ago

This guide shows how to create and deploy a Solidity-based smart contract to a CLV standalone node using the .

Remix is one of the most popular Solidity IDE used to write, compile and debug Solidity code. With CLV Ethereum compatibility features, Remix can be used directly with a CLV node.

This guide assumes that you have a running local CLV node running in --dev mode, and that you have a installation configured to use this local node. If you don't know how to do it, you can find instructions for running a local CLV node and to connect MetaMask to it .

Checking Prerequisites

We assume you have followed the guides above, and have a local CLV node producing blocks. It should look like this:

And you should have installed MetaMask connected to your local CLV dev node. You should have at least one account that has a balance. It should look like this (expanded view):

Getting Started with Remix

Now that we can start with Remix to exercise some advanced functionalities in CLV.

Now we can create a new file to save the Solidity smart contract. Click the "+" button under "File Explorers" at the top left. Give it a name "MyToken.sol" in the popup box.

Now paste the following smart contract code into the editor tab on the right side:

// SPDX-License-Identifier: MIT
pragma solidity ^0.6.2;

import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.3.0/contracts/token/ERC20/ERC20.sol";

contract Token is ERC20 {

    constructor (uint256 initialSupply) public ERC20("MyToken", "ABC") {
        _mint(msg.sender, initialSupply);
    }
}

This is a simple ERC-20 contract based on the current Open Zeppelin ERC-20 template. It creates MyToken with symbol ABC and mints the entirety of the initial supply to the creator of the contract.

Now the editor should look like this:

Now navigate to the compile sidebar option first and then click the β€œCompile MyToken.sol” button at the bottom left:

You will see Remix download all of the Open Zeppelin dependencies and compile the contract.

Deploying a Contract to CLV Using Remix

To deploy the contract, you need to navigate to the Deployment sidebar option on the left. Change the topmost β€œEnvironment” dropdown from β€œJavaScript VM” to β€œInjected Web3”. Thus you can use the MetaMask injected provider, which will point it to your CLV standalone node.

Note that you should allow Remix to access your MetaMask account after selecting "Injected Web3", by clicking the "Next" and then the "Connect" button.

Now you should see the account in metamask showing up on the Remix side, ready for deployment. Let’s specify an initial supply of 5M tokens in the box next to the Deploy button. Since this contract uses the default of 18 decimals, the value is 5000000000000000000000000.

Then, click the Deploy button. You will need to confirm the contract deployment transaction in Metamask.

After the deployment is complete, you will see the transaction record listed in MetaMask. Also, the contract will appear under Deployed Contracts in Remix.

After the contract is deployed, you can interact with it from within Remix.

Now you can try clicking on name, symbol, and totalSupply. There should return β€œMyToken,” β€œABC,” and β€œ5000000000000000000000000” respectively. If you copy the address and paste it into the balanceOf field, you should see the entirety of the balance of the ERC20 as belonging to that user.

Interacting with a CLV-based ERC-20 from MetaMask

To add the newly deployed ERC-20 tokens, you need to copy the contract's address from Remix first. Then back in MetaMask, click on β€œAdd Token” as shown below. Make sure you are in the account that deployed the token contract.

Paste the copied contract address into the β€œCustom Token” field. The β€œToken Symbol” and β€œDecimals of Precision” fields should automatically show up.

Then click the β€œNext” and then the β€œAdd Tokens” button, you should see a balance of 5M MyTokens in MetaMask:

Now we can send some of these ERC-20 tokens to the other account. Hit β€œsend” to initiate the transfer of 500 MyTokens. Select the destination account and hit β€œnext,” you will be asked to confirm this transaction as shown below.

Click β€œConfirm” to send. After the transaction is complete, you will see a confirmation and a reduction of the account balance from the sender account in MetaMask:

If you own the account which you send to, you can check the account balance to verify that the transaction has been successfully.

To launch Remix, you need to navigate to . In the main screen, select Solidity to configure Remix for Solidity development, then navigate to the File Explorers view:

https://remix.ethereum.org/
Remix IDE
MetaMask
here
here