How to read Teal from Front End React - Algorand

How to read Teal from Front End React

post by bhaney44 on Sep 24, 2024

I am working on an application that needs to read the result of a TEAL computation to a front end display in a React app. I am wondering how this has been done by others. I looked into the storage mechanisms, but nothing is standing out as an optimal solution.

post by Maugli on Sep 25, 2024

Hi, @bhaney44 , you can write an AVM contract, and use a contract method to return the result from the storage. Then you can call the method from the React app, and display the result. E.g. the HelloWorld sample app displays the return value like this in AppCall.tsx:


const response = await appClient.hello({ name: contractInput }).catch((e: Error) => {
      enqueueSnackbar(`Error calling the contract: ${e.message}`, { variant: 'error' })
      setLoading(false)
      return
    })