Skip to content

Decoding Calldata

Loop Decoder provides a decodeCalldata method that decodes a transaction calldata. This method handles special cases:

  • Gnosis Safe Multisend or Multy Transfer transactions
  • Multicalls and deeply nested calls
  • Proxy contract resolutions

Setting up Loop Decoder

To use decodeCalldata method, you need to setup a TransactionDecoder instance with the necessary data stores. For setup instructions, refer to:

Decoding Calldata

In the example below, we will decode a transaction calldata for for Gnosis Safe Multisend transaction that has deep nested calls.

async function main() {
try {
const decoded = await decoder.decodeCalldata({
data: '0x8d80ff0a000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000006b2002d8880bcc0618dbcc5d516640015a69e28fdc406000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003046a761202000000000000000000000000e3c408bd53c31c085a1746af401a4042954ff7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000e0d8be1dc2affefab9c066fd73a4b9788d3d3d4500000000000000000000000000000000000000000000000000064e5a6479f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001045f938ab87e466dca3d4953d42efc1fde996dcd7888622c9db2827bde3ecb169067e93c03124f4558edfed7819f454599a24aa75c8ba0aecb707bb6d7e8a265911f0ecd835bf25f1d74e4d89e30acb4176113c07d8a43a42712f4b1c6b658ff87f927e05f54ebf5b8c91ba843aefbb8e7d88ab73aaa66ede612e620d9847dc2260d1bbaa39fdd8469f14ea2342526d20e4458cbf9323a04ff6752acd302021067c84a7b59e4bc389954aa3a7daafe9b4a30fba791aab53266b9a7bbd78c31adba05571c29a581b2fa3ecb44c85cead416f6bfe0038b5d7e60202926e8e409c285a391d719858122d2f9a00e07417ac26b4c5370f0f6459332006edc20c65220acac58a32000000000000000000000000000000000000000000000000000000000002d8880bcc0618dbcc5d516640015a69e28fdc406000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003046a761202000000000000000000000000e3c408bd53c31c085a1746af401a4042954ff7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000008b31d6018d2ee253379e98475c59c934549e62b00000000000000000000000000000000000000000000000000006651728988000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104946f3bb1ed2ba0acc722eec299e4fa02a741f6e5868f0643445f0ead1fe2b2f64cc28e5d2268f1f5f5e0239aaf1e4237be9bc67fb5bc1d8eae2c1d602089dcf720f7a65592538de69348f49784d27e7145ab96ffee198cab2d0c49f77a9cb415424881898c3df33e9318665e73e40ee66de96c5222d2b833edcf115a9b4a16cbd61c31c2a6240ac498822e1c6a61eb5a7271ad305f911985662b9a47e50249d88a7e53e187b542c9cf69dbccecc543fb76d7480a1d29c9db2a6fc81e04ecbfdf609b1bd3f85f39ff0f226493f3f5c8934507c92f24cd5b3365bd5e8bc4a4a2b23e6dcd28654caa13a0f5418f4cc642de81bff61d01b913883acf8c0794e94794a9405320000000000000000000000000000000000000000000000000000000000000000000000000000000000000',
chainID: 1,
contractAddress: '0x40A2aCCbd92BCA938b02010E17A5b8929b49130D',
})
console.log(JSON.stringify(decoded, null, 2))
} catch (e) {
console.error(JSON.stringify(e, null, 2))
}
}
main()

Expected output:

{
"name": "multiSend",
"signature": "multiSend(bytes)",
"type": "function",
"params": [
{
"name": "transactions",
"type": "bytes",
"value": "0x002d8880bcc0618dbcc5d516640015a69e28fdc406000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003046a761202000000000000000000000000e3c408bd53c31c085a1746af401a4042954ff7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000044a9059cbb000000000000000000000000e0d8be1dc2affefab9c066fd73a4b9788d3d3d4500000000000000000000000000000000000000000000000000064e5a6479f0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001045f938ab87e466dca3d4953d42efc1fde996dcd7888622c9db2827bde3ecb169067e93c03124f4558edfed7819f454599a24aa75c8ba0aecb707bb6d7e8a265911f0ecd835bf25f1d74e4d89e30acb4176113c07d8a43a42712f4b1c6b658ff87f927e05f54ebf5b8c91ba843aefbb8e7d88ab73aaa66ede612e620d9847dc2260d1bbaa39fdd8469f14ea2342526d20e4458cbf9323a04ff6752acd302021067c84a7b59e4bc389954aa3a7daafe9b4a30fba791aab53266b9a7bbd78c31adba05571c29a581b2fa3ecb44c85cead416f6bfe0038b5d7e60202926e8e409c285a391d719858122d2f9a00e07417ac26b4c5370f0f6459332006edc20c65220acac58a32000000000000000000000000000000000000000000000000000000000002d8880bcc0618dbcc5d516640015a69e28fdc406000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000003046a761202000000000000000000000000e3c408bd53c31c085a1746af401a4042954ff7400000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001c00000000000000000000000000000000000000000000000000000000000000044a9059cbb0000000000000000000000008b31d6018d2ee253379e98475c59c934549e62b00000000000000000000000000000000000000000000000000006651728988000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000104946f3bb1ed2ba0acc722eec299e4fa02a741f6e5868f0643445f0ead1fe2b2f64cc28e5d2268f1f5f5e0239aaf1e4237be9bc67fb5bc1d8eae2c1d602089dcf720f7a65592538de69348f49784d27e7145ab96ffee198cab2d0c49f77a9cb415424881898c3df33e9318665e73e40ee66de96c5222d2b833edcf115a9b4a16cbd61c31c2a6240ac498822e1c6a61eb5a7271ad305f911985662b9a47e50249d88a7e53e187b542c9cf69dbccecc543fb76d7480a1d29c9db2a6fc81e04ecbfdf609b1bd3f85f39ff0f226493f3f5c8934507c92f24cd5b3365bd5e8bc4a4a2b23e6dcd28654caa13a0f5418f4cc642de81bff61d01b913883acf8c0794e94794a940532000000000000000000000000000000000000000000000000000000000",
"valueDecoded": {
"name": "transactions",
"signature": "transactions((uint256,address,uint256,uint256,bytes)[])",
"type": "function",
"params": [
{
"name": "unknown",
"type": "tuple",
"components": [
{
"name": "unknown",
"type": "tuple",
"components": [
{
"name": "operation",
"type": "uint256",
"value": "0"
},
{
"name": "to",
"type": "address",
"value": "0x2D8880BcC0618DBCC5d516640015A69e28fdC406"
},
//...

Try it live

Try decoding the above or any other calldata in our Playground.