Instant onchain executions with Block Triggers

Gelato Team

Nov 10, 2023

Gelato's Functions are serverless, event-driven tools designed for automating blockchain transactions. They offer developers a powerful bridge between on-chain and off-chain activity, enabling execution of on-chain transactions based on arbitrary off-chain data and computation.

Introducing Block Triggers

Block triggers enable Gelato Functions to actively listen for new blocks and automatically execute smart contract functions as soon as a block is mined. This lets Functions synchronize with blocktime and carry out operations instantly.

Advantages for Developers

Block-triggered Web3 Functions bring several advantages:

  • Lower Latency: Functions execute promptly with each new block, reducing wait times.

  • Sync with Blockchain: By executing in tandem with new blocks, functions are always aligned with the latest state.

  • Efficient Time Synchronization: Synchronization with block additions eliminates the risk of missed blocks and ensures timely execution.

Use Cases

Block triggers are beneficial in scenarios requiring immediate action in response to state changes:

  • Limit Orders: Prevent delays in execution, safeguard against missed price targets or slippage, and avoid potential financial losses or missed opportunities.

  • Perpetual Orders: Ensure immediate reactions, maintain the efficacy of perpetual strategies, and prevent suboptimal positions or uncontrolled risk.

How to Enable Block Trigger?

Implementing block-driven Web3 Functions is seamless. To create a new task with a block trigger:

  1. Navigate to https://beta.app.gelato.cloud/.

  2. Choose the "Every Block" option.

  3. Under “What to trigger,” select “Typescript Function.”

  4. Continue with the standard process.

Block Trigger setup

About Gelato

Gelato is a Web3 Cloud Platform empowering developers to create automated, gasless, and off-chain-aware Layer 2 chains and smart contracts. Over 400 Web3 projects have relied on Gelato for years to facilitate millions of transactions in DeFi, NFTs, and gaming.

  • Gelato RaaS: Deploy tailor-made ZK or OP L2 chains in a single click with native Account Abstraction and Gelato middleware baked in.

  • Functions: Serverless, event-driven functions to automate blockchain transactions.

  • Relay: Provide users with reliable, robust, and scalable gasless transactions via a simple API.

  • Account Abstraction SDK: Built in partnership with Safe, combining Gelato's gasless transaction capabilities with secure smart contract wallets.

Subscribe to our newsletter and turn on Twitter notifications for the latest updates about the Gelato ecosystem.
Interested in being part of the Gelato team and building the future of the internet? Browse open positions and apply here.

Ready to build?

Start with a testnet, launch your mainnet in days, and scale with industry-leading UX.

Ready to build?

Start with a testnet, launch your mainnet in days, and scale with industry-leading UX.

Ready to build?

Start with a testnet, launch your mainnet in days, and scale with industry-leading UX.

Ready to build?

Start with a testnet, launch your mainnet in days, and scale with industry-leading UX.