Howsit guys, I am busy going through the mempool and trying to track various transactions and parts of transactions. As a first step I thought I would list transactions and the bits I might need later on. Here comes the issue.
I cannot get any information out of the transaction input. I have tried all the previous solutions and packages recommended but to no avail.
When I use the web3.utils.toAscii I get gibberish. When I use ethereum-tx-decoders decodeTx I get invalid arrayify value. when I use any of the other web3 tools I get an error.
Please find the latest itteration of my code below after many hours of attempting all the solutions I could find (above are the three most recent failures)
const txDecoder = require("ethereum-tx-decoder");
const express = require("express");
require("dotenv").config();
const Web3 = require("web3");
const curl = `wss://mainnet.infura.io/ws/v3/${process.env.infuraProjId}`;
const web3 = new Web3(new Web3.providers.WebsocketProvider(curl));
let counter = 0;
const subscription = web3.eth.subscribe(
"pendingTransactions",
(error, transactionHash) => {
if (!error) {
web3.eth
.getTransaction(transactionHash)
.then((tx) => {
if (tx !== null) {
counter++;
// console.log(tx.hash);
const decodedInput = txDecoder.decodeTx(tx.input);
console.log(decodedInput);
}
})
.catch((err) => console.error(err));
} else {
console.error(error);
}
}
);
// .on("data", (transactionHash) => {
// web3.eth.getTransaction(transactionHash).then((transaction) => {
// console.log("coming from data");
// console.log(transaction.from, transaction.to);
// });
// });
// ^^ this kept returning null
Please and thank you