Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

492
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda