So I have checked and the smart contract is working perfectly in hardhat but when I am call it in react I am facing problem

// SPDX-License-Identifier: MIT
pragma solidity >=0.5.0 <0.9.0;

contract chai {
    struct Memo {
        string name;
        string message;
        uint256 timestamp;
        address from;

    Memo[] memos;
    address payable owner;

    constructor() {
        owner = payable(msg.sender);

    function buyChai(string memory name, string memory message) public payable {
        require(msg.value > 0, "Please pay greater than 0 ether");
        memos.push(Memo(name, message, block.timestamp, msg.sender));

    function getMemos() public view returns (Memo[] memory) {
        return memos;

This is the smartcontract

import { useState,useEffect, memo } from "react";
const Memos=({state})=>{

        const memosMessage=async()=>{
            const memos=await contract.getMemos();
        contract && memosMessage();

    return ( 
        <table key={memo.timestamp}>
export default Memos;

This is a Memos.js which is imported in App.js but I am finding this problem enter image description here

2 Answers 2


You are missing the ABI in code,

 const contractInstance = new web3.eth.Contract(ABI,contract);

and pass this instance to get your contract data where ever required


You can try checking the following:

  1. Whether your .env is correct or not.
  2. Whether contractAddres in App.jsx is provided as per your test network.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.