I'm using an Alchemy rpc endpoint to facilitate all my MetaMask transactions. I sent a transaction a few hours ago and it's stuck in pending, and now every few seconds (or.. every time I open MetaMask browser extension?), I see this eth_sendRawTransaction
request that fails on my Alchemy app dashboard and the explorer.
It looks like this:
In order for me to debug, I want to know more about what the request actually was -- so I want to find out what the request parameters were. However, the string is in hex(?) and I'm not sure how to translate it to something human-readable.
0x02f8700181cf82271084828a55c282520894cbb517e9321304dd52ffc9d5970597ef76c35d2187038d7ea4c6800080c080a0ad7be784d26a3412749f7d548c538aa3c66d9c503ffbe24bb853a442e4183622a05b3e5e73687e4483e047c33ab6986b90603448414aee70813b62b9f37b263b44
I like that there's a tool-tip that links to documentation that explains the -32000
status code error, and that "already known"
means that
This generally means the transaction already posted and is on the node in a pending state. Sometimes this error occurs when transactions fail at first but are retried when the node already knows of them.
But I'd love to see the params here without having to look through a blockchain explorer or the Alchemy mempool.
How do I decode the hex string?
I've tried using web3.utils.hexToString
(errors) and web3.utils.hexToAscii
(decodes to gibberish).
const { createAlchemyWeb3 } = require("@alch/alchemy-web3");
// Using HTTPS
const web3 = createAlchemyWeb3("https://eth-mainnet.alchemyapi.io/demo");
console.log(web3.utils.hexToAscii("0x02f8700181cf82271084828a55c282520894cbb517e9321304dd52ffc9d5970597ef76c35d2187038d7ea4c6800080c080a0ad7be784d26a3412749f7d548c538aa3c66d9c503ffbe24bb853a442e4183622a05b3e5e73687e4483e047c33ab6986b90603448414aee70813b62b9f37b263b44"));
this script returns:
øpÏ'UÂ˵é2ÝRÿÉÕïvÃ]!~¤ÆÀ {çÒj4t}TS£ÆmP?ûâK¸S¤Bä6" [>^sh~DàGÃ:¶k4HAJîp;b¹ó{&;D
What am I missing to decode the params?