πŸͺIntegrate a batch into a Hook using Squid

How to add multiple actions using the batch precompile into a pre-hook on Moonbeam parachain to a route request towards an EVM chain using Squid SDK

Now that you have your encoded batch call made of several encoded subcall data, you can easily add the full encoded batch data to a Hook using Squid SDK.

This is doable by adding a postHook or preHooks parameter to the route object passed to Squid.

         postHook: {
            chainType: "evm",
            calls: [
              {
                chainType: "evm",
                callType: 2,
                target: batchAddress, // 0x0000000000000000000000000000000000000808
                value: "0", // this will be replaced by the full native balance of the multicall after the swap
                callData: batchEncodedData,
                payload: {
                  tokenAddress: "0xAcc15dC74880C9944775448304B263D191c6077F",
                  inputPos: 0, // unused
                },
                estimatedGas: "150000",
              },

By using this technique, you can do multiple calls before bridging to any EVM chain (preHook) and after bridging from any EVM chain to Moonbeam (postHook).

Last updated