0

I have a file with over 1 million+ ethereum addresses and private keys grouped together in a single file separated only using a ','.

Example:

0x7256bCf73C2309893AA12d6b26A142AB3097560c,0x5281130a3a84f531a1e30649a881207a65ce17fae084e0ae6e78xxxxxxxxxxxx

I want to use nodejs to check the balances of each address in the line to be greater than 0.000 and then export the valid addresses along with private keys to another file.

I always experience this error whenever I run my script.


        var error = new Error(message);
                    ^

Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.6.8)
    at Logger.makeError (C:\Users\Asus\Downloads\eth-fast-mnemonic-checker-main\eth-fast-mnemonic-checker-main\node_modules\@ethersproject\logger\lib\index.js:233:21)
    at Logger.throwError (C:\Users\Asus\Downloads\eth-fast-mnemonic-checker-main\eth-fast-mnemonic-checker-main\node_modules\@ethersproject\logger\lib\index.js:242:20)
    at WebSocketProvider.<anonymous> (C:\Users\Asus\Downloads\eth-fast-mnemonic-checker-main\eth-fast-mnemonic-checker-main\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:561:54)
    at step (C:\Users\Asus\Downloads\eth-fast-mnemonic-checker-main\eth-fast-mnemonic-checker-main\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:48:23)
    at Object.throw (C:\Users\Asus\Downloads\eth-fast-mnemonic-checker-main\eth-fast-mnemonic-checker-main\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:29:53)
    at rejected (C:\Users\Asus\Downloads\eth-fast-mnemonic-checker-main\eth-fast-mnemonic-checker-main\node_modules\@ethersproject\providers\lib\json-rpc-provider.js:21:65)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  reason: 'could not detect network',
  code: 'NETWORK_ERROR',
  event: 'noNetwork'
}

Here's the initial script , would be grateful if you could fix the error for me, thanks.

const fs = require('fs')
const ethers = require('ethers')
require('colors')

const provider = new ethers.providers.WebSocketProvider(
    'wss://eth-mainnet.g.alchemy.com/v2/k5d8RoDGOyxZmVWy2UPNxxxxxxxxxxxx'
)

const addresses = fs
    .readFileSync('hits.txt', 'utf8')
    .split('\n')
    .map((val) => {
        return val.split(',')
    })

;(async () => {
    for (let i = 0; i < addresses.length; i++) {
        const address = addresses[i][0]
        const balance = await provider.getBalance(address)

        if (balance.gt(0)) {
            console.log(address.bgGreen.black, balance.toString().bgGreen.black)
            console.log('Private Key: '.yellow, addresses[i][1])
        } else {
            console.log(address, 0)
        }
    }
})()

I also tried using other domains like eth-mainnet.ws.alchemyapi.io to no avail..

1 Answer 1

0

If you still want an answer here it is: You need to go to this page https://www.alchemy.com/smart-websockets and make an account and copy and paste your websocket API to your codeenter image description herereplace this wss address

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.