MELD Dev Docs
  • Welcome to MELD
  • OVERVIEW
    • Core Concepts
      • EVM Compatible
      • Staking/Block Rewards
      • L1-Subnet
    • Bug Bounties
    • Careers
    • Security & Audits
      • Double Spend Prevention
  • DEVELOP
    • Developing on MELD
    • Basics
      • Kanazawa Testnet
      • Test Tokens & Faucet
      • MELD Mainnet
      • RPC connections
        • RPC Methods
      • Explorers
    • Tools
    • Oracles
      • Integrating Supra Oracles
    • Deploy a Smart Contract
      • Smart Contract Languages
      • Smart Contract Testing
      • Using Remix IDE
      • Using Hardhat
      • Verify Your Smart Contract
    • Token Standards
      • MLD-20: Fungible Tokens
        • Interacting With MLD-20 Tokens
      • MLD-721: NFTs
      • MLD-1155: Multi-token standard
      • MLD-404: Semi-fungible tokens
      • MDL-6551: Token Bound Accounts
    • Deploy NFTs
      • Using Remix
    • dApp
      • Develop a Full Stack dApp on MELD
      • Secure your dApp
    • Decentralized Storage
    • Cross Chain Bridging
      • Integrating Chainport
        • Bridging Between MELD and EVM Chains
          • Main Chain -> Side Chain
          • Side Chain -> Main Chain
          • Side Chain -> Side Chain
      • Akamon Bridge
      • Yield Boost
  • VALIDATORS
    • Overview
    • Consensus
    • Run a Validator node
    • MELD Staking
  • Tutorials
    • Using MELD with your metamask
    • Create a Token
    • Add a Token to Asomi DEX
    • Lock/Burn Liquidity
  • FAQ
    • General FAQ
    • Borrowing & Lending FAQ
    • MELD ISPO FAQ
Powered by GitBook
On this page
  1. DEVELOP
  2. Token Standards
  3. MLD-20: Fungible Tokens

Interacting With MLD-20 Tokens

Using a Front-End Application or Remix

Interacting with MLD-20 tokens, a standard on the MELD blockchain, can be done in various ways depending on your specific needs and technical background.

1. Interacting with MLD-20 Tokens in a Front-End Application

For those developing a front-end application, this typically involves using a web3 framework like Web3.js or Ethers.js, integrated with languages such as JavaScript or TypeScript. These frameworks allow you to connect your application to the MELD blockchain, enabling users to interact with MLD-20 tokens through a familiar web interface.

  • Install Web3.js: First, you'll need to install Web3.js in your project. It's a collection of libraries that allow you to interact with a local or remote ethereum node using HTTP, IPC, or WebSocket.

    npm install web3
  • Connecting to the MELD Blockchain:

    import Web3 from 'web3';
    
    const web3 = new Web3('https://testnet-rpc.meld.com/');
  • Interacting with an MLD-20 Token Contract:

    You'll need the ABI (Application Binary Interface) of the MLD-20 token contract and its address.

    const tokenAddress = 'YOUR_MLD20_TOKEN_ADDRESS';
    const tokenABI = [] // ABI of the MLD-20 token contract
    
    const tokenContract = new web3.eth.Contract(tokenABI, tokenAddress);
    
    // Example: Getting the total supply of the token
    tokenContract.methods.totalSupply().call()
      .then(totalSupply => console.log('Total Supply:', totalSupply));

2. Interacting with MLD-20 Tokens Using Remix

On the other hand, if you prefer a more direct approach, you can interact with these tokens through smart contract functions using platforms like Remix. Remix is a powerful web-based IDE that allows you to write, deploy, and interact with smart contracts directly on the blockchain. We'll be using the $MELD Token as an example here.

  1. Access Remix IDE: Open Remix IDE.

  2. Create a New File for the MELD Token Contract:

    • In the "File Explorers" tab, create a new folder by clicking the "Create New Folder" icon.

    • Name the folder contracts

    • Navigate inside the contracts folder and create a new file by clicking the "Create New Folder" icon.

    • Name the file MELDToken.sol.

  3. Paste the MELD Token Contract Code:

    • Paste the copied code into the MELDToken.sol file you just created.

  4. Compile the Contract:

    • Go to the "Solidity Compiler" tab.

    • Select the appropriate compiler version (0.8.19).

    • Click "Compile MELDToken.sol".

  5. Connect to the MELD Mainnet:

    • Make sure your Web3 environment in Remix is connected to the MELD Mainnet. This might involve configuring a Web3 provider like MetaMask to connect to the MELD network.

  6. Load the Existing Contract:

    • Go to the "Deploy & Run Transactions" tab.

    • In the "Contract" dropdown, select 'MELD ERC20 - contracts/MELDToken.sol'.

    • Below that, paste the MELD Token address 0x333000333528b1e38884a5d1EF13615B0C17a301 into the "At Address" field.

    • Click "At Address" to load the existing contract.

  7. Interact with the Contract:

    • The functions of the MELD Token contract will now be displayed in the "Deployed Contracts" section.

    • You can interact with the contract's functions:

      • For instance, to check the total supply, click on the totalSupply() function.

      • To view the balance of a specific address, input the address into the balanceOf(address) function and execute it.

      • Similarly, you can execute other functions like transfer, approve, and allowance.

  8. Executing Functions:

    • Functions that read data (view and pure) can be queried without a transaction.

    • Functions that alter the state require a transaction. Be sure your connected account has the necessary permissions and funds.

PreviousMLD-20: Fungible TokensNextMLD-721: NFTs

Last updated 1 year ago

Copy the source code of the MELD Token contract. You can find the contract source code .

here
Your Remix IDE should look like this at the end of this tutorial