Загрузка...

How can I fix this code? node.js/web3.js

Thread in Node.js created by lilaaron_911 Jan 8, 2024. (bumped Jan 8, 2024) 181 view

  1. lilaaron_911
    lilaaron_911 Topic starter Jan 8, 2024 107 Apr 2, 2020
    JS
    import express from 'express';
    import web3 from 'web3';

    const app = express();
    const port = 3000;

    app.get('/', async(req, res) => {
    const web3 = new Web3(Web3.givenProvider || 'ws://localhost:8545');
    try {
    const accounts = await web3.eth.getAccounts();
    if (accounts.length > 0) {
    res.send('Кош подкючен');
    } else {
    res.send('Кош не подключе');
    }
    } catch (error) {
    console.error(error);
    res.send('установи метамаск лох');
    }
    });

    app.listen(port, () => {
    console.log(`вход - http://localhost:${port}`);
    });
    Хелп пожалуйстоооооооооооо
     
  2. Metzker
    Metzker Jan 9, 2024 17 Jan 14, 2019
    А в чем ошибка собстна
     
Loading...
Top