LogoLogo
  • Introduction to the Muse DAO
  • Developer Vision
  • DAPPS
    • Fast Dapp
      • Tutorials
        • Getting started
          • Make an ERC20 transfer app
      • Components
        • Contract Read
        • Contract Write
        • APICall
        • Events
        • Address Display
        • Block Number
        • Ethereum Balance
        • PleaseConnect (Request user connection)
        • Token Balance (ERC20)
        • WatchEvents
        • AirStack
        • Sweep NFT floor
        • Token amount (ERC20)
        • Token name (ERC20)
        • Uniswap tradebox
        • Moment (display date/time)
      • Variables
        • userAddress
        • ABIs
        • connectedChain
        • Passing arbitrary data in query URL parameters
        • location
        • Toast
      • Templates
        • ERC20 Token transfer
        • Nouns Auction
        • AAVE V3
        • Lido Staking page
        • DAI Saving Rate
        • ERC6551
        • Popular NFT collections buy button
        • Non Fungible Message
        • No Shit Sherlock
      • Style
    • Launch
      • How to Launch a project
      • How to buy from a Launch
      • How to sell into a Launch
      • FAQ
    • NFT20
      • Use Cases
      • Liquidity Incentives
      • Guides
        • Adding a project
          • Create Pool
      • Contracts
        • NFT20Factory
          • Source
        • NFT20Pair
          • Source
      • API
      • Fees
    • ETHCMD
    • RolodETH
    • The Very Nifty Gallery
    • CUDL Game
      • Pets
      • $CUDL
      • MILK
      • Bazaar
      • Battles and weapons
    • Feather NFT
    • Dreams of EVM NFT
    • Sudoswap,js
    • The Quest (Sword & Shield)
    • Royal Game
    • Space Goo
    • NFT API
    • Pepesea NFT Marketplace
  • Tokenomics
    • $MUSE
    • Treasury
  • Other resources
    • Governance
    • Links
Powered by GitBook
On this page
  • Props​
  • Basic Example
  • Transform the return value by passing a function​
  • Handle functions with several return values​
  1. DAPPS
  2. Fast Dapp
  3. Components

Contract Read

This component is used to invite users to interact with a smart contract.

PreviousComponentsNextContract Write

Last updated 1 year ago

Props

  • address

  • ABI

  • functionName

  • args an array containing the parameters you want to use

  • returnValue if the function returns several parameters, the index of the one you want to display (starting from 0)

Basic Example

<ContractRead 
    address={tokenAddress} 
    abi={ABIs.ERC20} 
    functionName="symbol" />

You can see .

Transform the return value by passing a function

You can transform the return value by passing a transformation function as a prop.

<ContractRead address={TOKEN_ADDRESS} 
  abi={ABIs.ERC20} 
  functionName="balanceOf"
  args={[TOKEN_RECIPIENT]}
  returnValue={(res) => parseInt(res) / 1e18} />

There are 2 ways of dealing with a function that returns multiple values.

Pass a transformation function

<ContractRead 
    args={[1]}
    address={VNFTAddress}
    abi={ITEM_INFO_ABI}
    functionName="getItemInfo"
    returnValue={(res) => res[0]} />

Index of the value in the array starting from 0.

<ContractRead 
    args={[1]}
    address={VNFTAddress}
    abi={ITEM_INFO_ABI}
    functionName="getItemInfo"
    returnValue={0} />

Handle functions with several return values

Pass the index of the value you want to display

​
several examples in the editor
​
​
​