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

229
Visualizações
TypeError: Cannot read properties of undefined (reading ':Voting')

I am getting this type error when i try to run this file in localhost

TypeError: Cannot read properties of undefined (reading ':Voting')
at C:\Users\Evote\index.js:93:53
    at Layer.handle [as handle_request] (C:\Users\Evote\node_modules\express\lib\router\layer.js:95:5)
    at next (C:\Users\Evote\node_modules\express\lib\router\route.js:137:13)
    at Route.dispatch (C:\Users\Evote\node_modules\express\lib\router\route.js:112:3)
    at Layer.handle [as handle_request] (C:\Users\Evote\node_modules\express\lib\router\layer.js:95:5)
    at C:\Users\Evote\node_modules\express\lib\router\index.js:281:22
    at Function.process_params (C:\Users\Evote\node_modules\express\lib\router\index.js:335:12)
    at next (C:\Users\Evote\node_modules\express\lib\router\index.js:275:10)
    at SendStream.error (C:\Users\Evote\node_modules\serve-static\index.js:121:7)
    at SendStream.emit (node:events:390:28)
    at SendStream.error (C:\Users\Evote\node_modules\send\index.js:270:17)
    at SendStream.onStatError (C:\Users\Evote\node_modules\send\index.js:421:12)
    at next (C:\Users\Evote\node_modules\send\index.js:736:16)
    at onstat (C:\Users\Evote\node_modules\send\index.js:725:14)
    at FSReqCallback.oncomplete (node:fs:198:21)

This is my code

app.get('/info', function(req, res){
    var cookie_pass = req.cookies['auth'];
    var cookie_otp = req.cookies['show'];
    if (cookie_pass == null || cookie_pass == '' || cookie_otp == null || cookie_otp == '') {
        res.redirect('/app');
    } else {
        web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
         code = fs.readFileSync('Voting.sol').toString()
        
         compiledCode = solc.compile(code)
         abiDefinition = JSON.parse(compiledCode.contracts[':Voting'].interface)
         VotingContract = web3.eth.contract(abiDefinition)
         byteCode = compiledCode.contracts[':Voting'].bytecode
         deployedContract = VotingContract.new(['Sanat','Aniket','Mandar','Akshay'],{data: byteCode, from: web3.eth.accounts[0], gas: 4700000})
contractInstance = VotingContract.at(deployedContract.address)

        res.sendFile(path.join(__dirname, 'ui', 'clist.html'));
    }
    
});

The error is in the line

abiDefinition=JSON.parse(compiledCode.contracts[':Voting'].interface)

I was trying to build an evoting system based on the ethereum network and when i run the code it is showing as type error

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