-
Hey, does anyone know any function/method to decode the "Input Data" field on a TX hash event? I know it's possible to do it directly on the Bscscan site, however my intention is to understand how to do it via a script or code. Thanks in advance. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
You can use use the const iface = new ethers.utils.Interface([ "function foo(uint bar)" ])
const info = iface.parseTransaction({ data: "0x2fbebd3800000000000000000000000000000000000000000000000000000000000004d2" })
/*
TransactionDescription {
args: [
BigNumber { _hex: '0x04d2', _isBigNumber: true },
bar: BigNumber { _hex: '0x04d2', _isBigNumber: true }
],
functionFragment: FunctionFragment { ... },
name: 'foo',
signature: 'foo(uint256)',
sighash: '0x2fbebd38',
value: BigNumber { _hex: '0x00', _isBigNumber: true }
}
*/
// Available positionally or via its name (if named)
console.log(info.args[0]);
console.log(info.bar); Let me know if that helps. :) |
Beta Was this translation helpful? Give feedback.
You can use use the
Interface
object to simplify your life.Let me …