Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

490
Views
Trying to debug: _export__WEBPACK_IMPORTED_MODULE_5__.default.methods is undefined in NextJS

I am trying to read a JSON file as a static prop to initialize a method for the project. But the problem is I am getting an error when I try to call the function that calls the method that reads the JSON file.

This is from the component function

import Web3 from "web3"
import fs from 'fs'
import buildData from '../../build/contracts/Betting.json'
// export local copies of contracts

export const getStaticProps = async () => {
    const data =  JSON.stringify(await buildData.abi);
    return {
      props: {data,},
    }
  }


const provider = new Web3.providers.HttpProvider(
    process.env.NEXT_PUBLIC_RINKEBY_RPC_URL
)
const web3 = new Web3(provider)
const abi = await getStaticProps()

const bettingContract = async (web3) => {
    return new web3.eth.Contract(
        await abi,
        "0x65b01f0f4Ec1885bD00D8C6dC8027fcc1316BCC4"
    )
}

export default bettingContract

In my useEffect hook that calls it (EDITED):

    useEffect( () => {
        const getPrizeMoneyHandler = async () => {
            const prizeMoney = await bettingContract.methods.getPrizeMoney().call()
            setPrizeMoney(prizeMoney)
        }
        getPrizeMoneyHandler()
        return () => {
            // this now gets called when the component unmounts
        };  
        
    })

I get the error:

Unhandled Runtime Error

TypeError: _blockchain_resplendent_contract_export__WEBPACK_IMPORTED_MODULE_5__.default.methods is undefined

This is specifically when I try to run getPrizeMoneyHandler() in the useEffect hook in the main application file. I know that I am able to retrieve the abi JSON data within the first code block. But I admit I don't know if it comes in time before I export bettingContract. I am going to assume my issue is not being able to call the promise correctly in the useEffect hook.

What am I doing wrong?

EDIT: I looked a tid tad more into my problem and I reworked the use Effect hook to be the above and I still have the error so I don't think it's a promise issue but something up with the first component function at the top, bettingContract. Any ideas to how to debug this?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!