BLOG — Updates

239 days ago

Web3 Functions: Instant 1-Second Executions

Gelato's Web3 Functions serve as a powerful bridge between on-chain and off-chain, enabling developers to execute on-chain transactions based on arbitrary off-chain data (APIs, subgraphs, etc.) and computation.

Until now, the Web3 Functions achieved their fastest latency of 5 seconds when executed in a sequential manner. With the introduction of Parallel Executions, we're ushering in a new era of even lower latency, allowing for more frequent runs and increased throughput, which in turn reduces execution time to just 1 second.

Sequential vs. Parallel Executions

In Sequential Mode, Web3 Functions run one after another in a structured order, ideal for tasks with specific sequences, while in Parallel Mode, functions run independently and simultaneously, optimizing speed and efficiency.

Sequential Mode

In this mode, each Web3 Function runs one at a time, waiting for the previous task to finish. This organized approach ensures that operations don't overlap, making it ideal for tasks that need to happen in a specific order. It's a reliable choice for dependable workflow.

Parallel Mode

In this model, functions don't wait for previous ones to complete and are executed independently and simultaneously. While the first instance of a Web3 Function is running (referred to as the first W3F Run), a new instance can be launched (second W3F Run) in the next time interval without waiting for the first one to complete. This mode is optimized for speed and is especially useful for "Send and Forget" tasks where the sequence of transactions or previous states doesn't matter.

New Use Cases Enabled by Parallel Executions

Parallel mode is particularly advantageous for scenarios that demand immediate response, ensuring swift and efficient processing.

For liquidations, it's vital to address rapid collateral value fluctuations to protect both lenders and platform stability in the borrowing & lending ecosystem. If not addressed swiftly, the risk of insolvency rises, endangering the assets of lenders. Platforms like Alpaca Finance and B.Protocol highlight this necessity. The parallel executions will allow them to do this better.

On the other hand, DEX limit orders need to capitalize on transient market opportunities. Platforms such as Pancake Swap and Quickswap, prominent players in the decentralized exchange (DEX) landscape, can utilize parallel executions to ensure timely trade completions at the intended prices.

Regarding Perpetual Protocols, rapid adjustments are essential to reflect the real-time value of underlying assets. By leveraging parallel executions, these protocols can ensure that contract prices remain consistently aligned with market rates, minimizing slippage and providing traders with a seamless experience.

These are just a few examples, suggesting that any use case requiring real-time, instant executions can benefit from parallel executions enabled by Gelato’s Web3 Functions.

How to Enable Parallel Execution

To switch between sequential and parallel execution modes, you’ll need to update the execution mode in your Web3 Functions' schema.json file. You can set it as:

  "executionMode": "sequential" // For sequential tasks


  "executionMode": "parallel" // For parallel tasks

About Gelato

Gelato is web3’s decentralized backend empowering builders to create augmented smart contracts that are automated, gasless & off-chain aware on all major EVM-compatible blockchains including Ethereum, Arbitrum, Polygon, Optimism, zkSync, and many more. Over 400+ web3 projects have relied on Gelato for years to power the execution of millions of transactions across DeFi, NFT, and Gaming.

Gelato currently offers four services:

  • Gelato zkRaaS: Deploy your own tailor-made ZK L2 chains in a single click with native Account Abstraction and all Gelato middleware baked in.

  • Web3 Functions: Connect your smart contracts to off-chain data & computation by running decentralized cloud functions.

  • Automate: Automate your smart contracts by executing transactions automatically in a reliable, developer-friendly & decentralized manner

  • Relay: Give your users access to reliable, robust, and scalable gasless transactions via a simple-to-use API

  • Account Abstraction SDK: Gelato has partnered with Safe, to build a fully-fledged Account Abstraction SDK, combining Gelato's industry best gasless transaction capabilities, with the industry's most secure smart contract wallet

Subscribe to our newsletter and turn on your Twitter notifications to get the most recent updates about the Gelato ecosystem!

If you are interested in being part of the Gelato team and building the future of the internet browse the open positions and apply here.