1

I am very new to this whole ethereum and web3 part. I've learned from this tutorial Link Here about how it is suposed to work and what information should my code deliver to me. But for some reason all the transaction addresses the code returns are wrong.

The whole thing is based on node.js and web3 and looks like this:

        if (block != null && block.transactions != null) {
        for (let txHash of block.transactions) {
            let tx = await this.web3.eth.getTransaction(txHash);
            console.log('Transaction found on block: ' + number);
            console.log({address: tx.from, value: this.web3.utils.fromWei(tx.value, 'ether'), timestamp: new Date()});
            console.log("\n+\n Address" + txHash + "\n+\n");
            console.log(this.web3.eth.getTransaction(txHash).then(console.log));
            
        }
    }

For example this is one of the returned transaction hashes, which if I check on ethereum.io comes as invalid.

0x254fdffeafd45f04d30936f48fdf2c5adeb9732e8bcdd6f4b5ba2b0cf31329d5

5
  • Are these transactions in public Ethereum main network or some other network? How do you determine they are "invalid"? – Mikko Ohtamaa Nov 21 '20 at 12:44
  • @MikkoOhtamaa . I have checked them here etherscan.io/tx/… – Kaly Nov 21 '20 at 13:11
  • @MikkoOhtamaa also , they are on the public network. (It is using infuria) – Kaly Nov 21 '20 at 16:54
  • Narrator: "They were not" 🙂 – Mikko Ohtamaa Nov 23 '20 at 8:53
  • True. They were not – Kaly Nov 24 '20 at 12:21
0

I was connected to the test network. I connected the code to the main network and then it worked.

So if you use infura make sure you use the mainnet!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.