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");
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(
    (error, transactionHash) => {
        if (!error) {
                .then((tx) => {
                    if (tx !== null) {
                        // console.log(tx.hash);

                        const decodedInput = txDecoder.decodeTx(tx.input);

                .catch((err) => console.error(err));
        } else {
// .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

1 Answer 1


you are missing a vital piece. You wont be able to decode the input or logs until you have the ABI of the "receiver" contract for TX input and the FROM contract for the logs.

To get the ABI: either use etherscan, use https://sourcify.dev/ or find it in IPFS/BZZ by reading the bytecode and parsing out the address if the solidity compiler was allowed to upload it.

AFTER you have the ABI, you pass it to the ethersjs/web3js/web3py and those libraries will be able to parse the input/output.

Edit: Also please keep in mind: if the receiver contract is a "Proxy" contract, you will then need to hunt down the "end receiver" contract address from the internal transactions.

  • Thank you for your reply. So if I get an ABI for the contract I am trying to find transactions to and one of the pending transactions can fit into the ABI, or match it (sorry for the poor terminology), then I should get the results I want but only for the transactions that are interacting with contracts that I already have the ABI for?
    – street rat
    Commented Aug 23, 2021 at 17:40
  • @streetrat you only need the "TO" contract ABI, the one that is receiving the transaction. That is the ABI you will use to decode the TX input. So yes: when you have the Receiving ABI and you have the TX that is sent to that contract, that is when you decode your input data. Commented Aug 24, 2021 at 0:36
  • @streetrat also edited the answer for when/if you hit a proxy contract. Commented Aug 24, 2021 at 0:38
  • 1
    thank you so much for your replies! I really appreciate the help (:
    – street rat
    Commented Aug 25, 2021 at 22:58

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.