<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Blockflow on Medium]]></title>
        <description><![CDATA[Stories by Blockflow on Medium]]></description>
        <link>https://medium.com/@blockflowhq?source=rss-ab72e246dfce------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*2e0nRpZtZ3ElD6MTGSBk3A.png</url>
            <title>Stories by Blockflow on Medium</title>
            <link>https://medium.com/@blockflowhq?source=rss-ab72e246dfce------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 10:37:51 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@blockflowhq/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Introducing CCTPScan: The Real-Time Native Explorer for Circle’s CCTP]]></title>
            <link>https://medium.com/@blockflowhq/introducing-cctpscan-the-real-time-native-explorer-for-circles-cctp-bf34636e37cf?source=rss-ab72e246dfce------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf34636e37cf</guid>
            <dc:creator><![CDATA[Blockflow]]></dc:creator>
            <pubDate>Fri, 06 Sep 2024 12:57:42 GMT</pubDate>
            <atom:updated>2024-09-06T12:57:42.602Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jonrJS7JRNvqamc7yBUF9w.png" /></figure><p>Today, we’re thrilled to unveil <a href="https://www.cctpscan.xyz/">CCTPScan</a> , the real-time native explorer for Circle’s Cross-Chain Transfer Protocol (CCTP), powered by Blockflow. This launch marks a significant milestone in cross-chain interoperability and stablecoin monitoring.</p><p><strong>Why CCTPScan Matters</strong></p><p>As USDC, the second-largest stablecoin by market capitalization, expands its reach across multiple blockchains, the need for robust monitoring tools becomes critical. CCTP Explorer provides unparalleled visibility into USDC flows across Ethereum, Layer 2 networks (Optimism, Arbitrum, Base), and other major chains like Polygon and Avalanche.</p><p><strong>Key Features of CCTPScan:</strong></p><ol><li>Real-time tracking of USDC transfers across multiple networks.</li><li>Support for multiple networks: Ethereum, Optimism, Arbitrum, Polygon, Base, and Avalanche</li><li>Detection of pending transactions and confirmation time lags</li><li>Anomaly detection for unusual transaction sizes or counterparties.</li></ol><p><strong>Understanding CCTP</strong></p><p>CCTP is a permissionless on-chain utility facilitating secure USDC transfers between blockchain networks through native burning and minting. As a token-anointed bridge, CCTP offers:</p><ul><li>Improved capital efficiency</li><li>Minimized trust requirements</li><li>Secure, 1:1 transfers of USDC across chains</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JrotfEOPv8An6Azylc-Yag.png" /><figcaption>Source: <a href="https://developers.circle.com/stablecoins/docs/generic-message-passing">https://developers.circle.com/stablecoins/docs/generic-message-passing</a></figcaption></figure><p>Unlike traditional lock-and-mint or liquidity pool bridges, CCTP doesn’t tie up USDC liquidity in third-party smart contracts, enhancing overall security and efficiency.</p><p><strong>How CCTP Works</strong></p><ol><li>USDC is burned on the source chain</li><li>Circle provides a signed attestation of the burn event</li><li>USDC is minted on the destination chain</li></ol><p>This process ensures a seamless, secure transfer of USDC across supported blockchains.</p><p><strong>Powered by Blockflow</strong></p><p>CCTP Explorer is built on Blockflow, a state-of-the-art modular data infrastructure that offers:</p><ul><li>Serverless functions for filtering and transforming blockchain data</li><li>Managed storage for custom blockchain data</li><li>Flexible querying with custom GraphQL APIs</li></ul><p>Blockflow’s infrastructure allows crypto teams to focus on building powerful features rather than managing complex backend systems, making CCTP Explorer the most efficient and scalable bridge explorer in the market.</p><p><strong>Are You a Chain or Bridge Looking to Master Your Cross-Chain Transactions and Flows?</strong></p><p>Unlock the full potential of your cross-chain data with Blockflow — the ultimate solution for multi-chain data aggregation and analysis.</p><p>With Blockflow, you can:</p><ul><li>Aggregate data across multiple networks effortlessly</li><li>Create specialised explorers tailored to your specific needs</li><li>Detect anomalies and optimize cross-chain operations</li><li>Scale your data infrastructure without the headache</li></ul><p>Solve smart contract indexing and monitoring today at <a href="https://app.blockflow.network/">Blockflow</a></p><p><strong>What’s Next?</strong></p><p>The launch of CCTP Explorer is just the beginning. We’re launching CCTPscan APIs to help developers monitor minting and burning of USDC across these EVM networks.</p><p>Register here for early access to CCTP APIs: <a href="https://forms.gle/uLYVmfNeTMgbyxJb9">https://forms.gle/uLYVmfNeTMgbyxJb9</a></p><p>We invite developers, users, and ecosystem partners to explore CCTP Explorer and provide feedback as we continue to enhance its features.</p><p>Experience the future of cross-chain USDC monitoring.</p><p>Visit <a href="https://www.cctpscan.xyz/">https://www.cctpscan.xyz/</a> to start exploring today.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf34636e37cf" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner’s Guide to Blockflow: Making Web3 Data Easy]]></title>
            <link>https://medium.com/@blockflowhq/a-beginners-guide-to-blockflow-making-web3-data-easy-22cf613ad1ad?source=rss-ab72e246dfce------2</link>
            <guid isPermaLink="false">https://medium.com/p/22cf613ad1ad</guid>
            <dc:creator><![CDATA[Blockflow]]></dc:creator>
            <pubDate>Fri, 14 Jun 2024 09:57:09 GMT</pubDate>
            <atom:updated>2024-06-14T10:54:18.777Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pWWWY2GYYH4h5WgF_yLcUA.png" /></figure><h3>What is Blockflow?</h3><p>Hey there! 👋</p><p>If you’re starting to explore decentralized applications (dApps) and blockchain technology, you might notice that handling blockchain data can be tricky.</p><p>🤠Blockflow is here to simplify this process!</p><p>Blockflow helps you manage, stream, and store blockchain data without the hassle.</p><p>⚒️It’s like a toolkit for building the backend of your Web3 apps.</p><h3>Why Blockflow?</h3><h3>🥵The Challenge with On-Chain Data</h3><p>Building a decentralized application involves interacting with blockchain data. This data can be vast, complex, and difficult to manage.</p><p>Developers often face issues with:</p><ul><li><strong>Real-time Data</strong>: Keeping data synchronized with the blockchain.</li><li><strong>Data Integration</strong>: Getting data from different blockchains.</li><li><strong>Scalability</strong>: Handling more data as your app grows.</li><li><strong>Resource Management</strong>: Spending a lot of time and money on infrastructure.</li></ul><h3>😎The Blockflow Solution</h3><p>Blockflow addresses these challenges by offering a suite of tools and services designed to handle the intricacies of on-chain data management. Here’s how Blockflow makes your Web3 journey easier:</p><h3>Managed Databases</h3><p>Blockflow provides databases that are optimized for performance and reliability.</p><p>You define your configurations and schema, and Blockflow handles the rest. This means you don’t have to worry about database maintenance, scaling, or performance issues!</p><p><a href="https://docs.blockflow.network/overview/databases">Read more…</a></p><h3>Chain Instances</h3><p>Chain Instances are powerful automation tools. They let you set up tasks that happen when certain blockchain events occur.</p><p>For example, you can trigger an action whenever a particular event occurs on-chain, such as a smart contract interaction or a transaction from a specific address.</p><p><a href="https://docs.blockflow.network/overview/instances">Read more…</a></p><h3>Custom APIs</h3><p>Blockflow makes it easy to create custom APIs that pull together data from different blockchains. This means you can get real-time data into your app with just a few lines of code.</p><p><a href="https://docs.blockflow.network/overview/apis">Read more…</a></p><p>Simple, right?</p><h3>🙂Why You’ll Love Blockflow</h3><h3>Speed Up Your Development</h3><p>Blockflow helps you ship your Web3 products faster. By providing ready-to-use infrastructure, you can focus on building unique features for your dApp instead of managing backend complexities.</p><h3>Save Time and Resources</h3><p>Running your own node and managing infrastructure can be expensive and time-consuming. Blockflow handles all of that for you, so your team can focus on on core application features and improvements.</p><h3>📍Getting Started with Blockflow</h3><p>Ready to dive in?</p><p><a href="https://www.blockflow.network/"><strong>Sign up</strong></a><strong> now</strong>!</p><p>Start your journey with Blockflow today and unlock the full potential of your Web3 applications!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22cf613ad1ad" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Indexing Oracles (Chainlink)]]></title>
            <link>https://medium.com/@blockflowhq/indexing-oracles-chainlink-c5d2a860a1c4?source=rss-ab72e246dfce------2</link>
            <guid isPermaLink="false">https://medium.com/p/c5d2a860a1c4</guid>
            <category><![CDATA[indexing]]></category>
            <category><![CDATA[oracles-network]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <dc:creator><![CDATA[Blockflow]]></dc:creator>
            <pubDate>Fri, 17 May 2024 15:31:46 GMT</pubDate>
            <atom:updated>2024-06-22T05:38:07.366Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide will focus on indexing Chainlink price oracles using the Blockflow CLI.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yqMVGCRV9MvSHoVzS4_h4g.png" /></figure><p>If you’re new to Blockflow, we highly recommend checking out our <a href="https://medium.com/@flow_block">previous</a> blogs first to get a solid foundation. But for those who can’t wait to dive in, let’s quickly recap what Blockflow is all about.</p><h4>What is blockflow?</h4><p><a href="https://blockflow.network/">Blockflow</a> is a serverless backend infrastructure provider for web3 that helps you build trigger-based backends with ease. It offers a feature-rich CLI that simplifies the indexing process, as we’ll demonstrate in this guide.</p><p>One of the key features of Blockflow is its support for managed databases like MongoDB. You can store your indexed data effortlessly and access it through convenient REST and GraphQL APIs. No more worrying about database setup and management!</p><h4>What are oracles?</h4><p>Before we put on our nerd hats and start exploring the Blockflow CLI, let’s take a moment to understand what we’ll be indexing today: “<em>Chainlink oracles</em>”.</p><blockquote>Blockchain oracles are entities that bridge the gap between blockchains and the external world. They enable smart contracts to execute based on real-world inputs and outputs. Imagine a smart contract that needs to know the current price of a cryptocurrency. That’s where oracles come into play!</blockquote><p><em>Chainlink</em> is a leading oracle provider that offers comprehensive price oracles. These oracles supply up-to-date pricing information for a wide range of cryptocurrency tokens. By integrating Chainlink oracles, you can ensure that your smart contracts have access to reliable and accurate price data.</p><p>Now that we have a basic understanding of Blockflow and oracles, let’s roll up our sleeves and start indexing!</p><blockquote>The code is available on our public repo <a href="https://github.com/BlockFloww/cli-examples">cli-examples</a>, under folder oracles.</blockquote><h4>Installing the Blockflow CLI</h4><p>To get started, we need to install the Blockflow CLI. Open your terminal and run the following command to download the latest version:</p><pre>npm i -g @blockflow-labs/cli</pre><h4>Configuring the CLI</h4><p>After installing the CLI, it’s time to get authenticated into your account. <em>(you can skip this step as well, auth is mainly required while deployment)</em></p><p>Run the following command:</p><pre>blockflow configure</pre><p>You’ll be prompted to enter your <strong>email</strong> and <strong>password</strong>. These are the same credentials you use to log in to the <a href="https://app.blockflow.network/">Blockflow console</a>. Once you’ve entered your credentials, you’re ready to create your first Blockflow project!</p><h4>Initializing a New Project</h4><p>To create a new project, navigate to the directory where you want to store your project and run the following command<em> (make sure the folder is empty):</em></p><pre>blockflow init</pre><p>The CLI will prompt you to select various options for your project, such as the project name, chain, Blockflow user ID, and project ID. Fill in the details, and the CLI will populate your directory with the necessary files for indexing. (shown in the image below)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5O9D79xQWk7K_TPqNWKhrg.png" /></figure><h4>Configuring the studio.yaml file</h4><p>One of the key files in your project is the studio.yaml file. This file contains the details you entered during the blockflow init command.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s6zjkW2_fChwSqEk3B7c9Q.png" /><figcaption>studio.yaml</figcaption></figure><p>Now you must be seeing a lot of things here, let’s decode them one by one:</p><ol><li><strong>name</strong>: This is the name of your project. In this case, it’s “chainlink price oracles”.</li><li><strong>description</strong>: A brief description of what your project does. Here, it’s “Indexing chainlink price oracles”.</li><li><strong>startBlock</strong>: The block number from which you want to start indexing. You can specify a specific block number or use “latest” to start from the most recent block.</li><li><strong>userId and projected</strong> are unique identifiers for your Blockflow user account and project. They are automatically populated when you run the blockflow init command.</li><li><strong>network</strong>: The blockchain network you’re working with. In this example, it’s “Ethereum”.</li><li><strong>user</strong>: The Blockflow username associated with your account.</li><li><strong>schema</strong>: It contains a file path to your database schemas. Here, our schema is stored at the path ./studio.schema.ts.</li><li><strong>execution</strong>: It tells our system how to run the indexing process over the specified block range. You can choose between “parallel” or “sequential” execution. Parallel execution can speed up the indexing process by processing multiple blocks concurrently.</li><li><strong>Resources</strong>: This section defines the smart contracts and events you want to index. You can provide multiple entries here.</li></ol><ul><li><strong>Name</strong>: A name for the resource. In this case, it’s “priceOracle”.</li><li><strong>Abi</strong>: The path to the smart contract&#39;s ABI (Application Binary Interface) file. The ABI defines the contract’s interface and is used to interact with it.</li><li><strong>Type</strong>: The type of resource. Here, it’s “contract/event”, indicating that we’re indexing events emitted by a smart contract.</li><li><strong>Address</strong>: The address of the smart contract you want to index. You can specify a single address or provide a file path to a JSON file containing multiple addresses.</li><li><strong>Triggers</strong>: This section defines the specific events you want to listen to and the corresponding handlers that will process the event data.</li><li><strong>Event</strong>: The name and signature of the event you want to index. For example, <em>“AnswerUpdated(int256 indexed,uint256 indexed,uint256)”.</em></li><li><strong>Handler</strong>: The path to the handler function that will be executed whenever the specified event is emitted. The handler is responsible for processing the event data and storing it in the database.</li></ul><p>The studio.yaml file serves as a configuration file for your Blockflow project. It tells the Blockflow CLI which smart contracts to index, which events to listen to, and how to process the event data. By defining your project’s configuration in this file, you can easily manage and customize your indexing setup.</p><blockquote>Remember to keep your studio.yaml file organized and up to date as you add more resources and handlers to your project. It acts as a central point of reference for your indexing configuration.</blockquote><p>Since we’ll be indexing multiple Chainlink price oracles, instead of manually entering each address and trigger, we can create a separate tokens.json file and populate it with the addresses. In the studio.yaml file, update the Address section to reference the <em>tokens.json </em>file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Hmnd3TkszpyGzivD_wHBTQ.png" /><figcaption>updated studio.yaml</figcaption></figure><h4>Creating the Database Schema</h4><p>Before we dive into writing the handler logic, let’s define the structure of our databases. In Blockflow, creating databases is as simple as writing TypeScript interfaces.</p><p>First, navigate to the schema file path mentioned in the studio.yaml file. In our case, it’s ./studio.schema.ts. This is where we’ll define our database schemas.</p><p>Open the studio.schema.ts file and add the following code:</p><pre>export interface PriceDB {<br>  id: string;<br>  contractAddress: string;<br>  name: string;<br>  symbol: string;<br>  decimals: number;<br>  quoteCurrency: string;<br>  rawPrice: string;<br>  price: string;<br>}<br><br>export interface ChainlinkPair {<br>  id: string;<br>  updateCount: number;<br>  transactionHash: string;<br>  lastBlockNumber: number;<br>  roundId: number;<br>}</pre><p>Here, we define two interfaces: PriceDB and ChainlinkPair. These interfaces represent the structure of our databases.</p><p>The PriceDB interface defines the schema for storing price information:</p><ul><li>id: A unique identifier for each price entry.</li><li>contractAddress: The address of the Chainlink price Oracle contract.</li><li>name: The name of the token.</li><li>symbol: The symbol of the token.</li><li>decimals: The number of decimal places for the token.</li><li>quoteCurrency: The quote currency for the price (e.g., USD, ETH).</li><li>rawPrice: The raw price value without any formatting.</li><li>price: The formatted price value.</li></ul><p>The ChainlinkPair interface defines the schema for storing additional information related to Chainlink price pairs:</p><ul><li>id: A unique identifier for each Chainlink pair entry.</li><li>updateCount: The number of times the price has been updated.</li><li>transactionHash: The hash of the transaction that triggered the price update.</li><li>lastBlockNumber: The block number of the last price update.</li><li>roundId: The round ID associated with the price update.</li></ul><p>By defining these interfaces, we are essentially creating the blueprints for our databases. Blockflow will automatically generate the necessary database collections based on these interfaces.</p><p>Once you’ve defined your database schemas in the studio.schema.ts file, save the file, and we’re ready to move on to the next step.</p><h4>Generating Types</h4><p>Now what are types, we already defined database schema in the previous step, but those databases don’t make much sense. Hence blockflow creates autogenerated types using those defined databases.</p><p>To generate types based on our schema, run the following command:</p><pre>blockflow typegen</pre><p>This command will generate TypeScript interfaces and classes in the src/types/schema.ts file, making it easier to work with the database entities in our code.</p><h4>Codegen</h4><p>Now as we are almost there to write the code, the question is in what exact format should the code be written? To generate pre-defined code handlers based on your configuration in studio.yaml run the following command.</p><pre>blockflow codegen</pre><p>The above command will generate code handlers at the code paths specified under triggers.</p><pre>import { IEventContext, IBind, Instance, ISecrets } from &#39;@blockflow-labs/utils&#39;<br><br>/**<br> * @dev Event::AnswerUpdated(int256 current, uint256 roundId, uint256 updatedAt)<br> * @param context trigger object with contains {event: {current ,roundId ,updatedAt }, transaction, block, log}<br> * @param bind init function for database wrapper methods<br> */<br>export const PriceHandler = async (<br>  { event, transaction, block, log }: IEventContext,<br>  bind: IBind,<br>  _: ISecrets,<br>) =&gt; {<br>  const { current ,roundId ,updatedAt } = event;<br>  // Implement your indexing logic here.<br>}</pre><h4>Implementing the Handler Logic</h4><p>Now it’s time to write the handler logic!</p><pre>import { IEventContext, IBind, Instance, ISecrets } from &#39;@blockflow-labs/utils&#39;<br><br>import { BigNumber } from &#39;bignumber.js&#39;<br>import { getTokenMetadata } from &#39;../../utils/tokens&#39;<br><br>import { PriceDB, IPriceDB } from &#39;../../types/schema&#39;<br>import { chainlinkPair, IchainlinkPair } from &#39;../../types/schema&#39;<br><br>/**<br> * @dev Event::AnswerUpdated(int256 current, uint256 roundId, uint256 updatedAt)<br> * @param context trigger object with contains {event: {current ,roundId ,updatedAt }, transaction, block, log}<br> * @param bind init function for database wrapper methods<br> */<br>export const PriceHandler = async (<br>  { event, transaction, block, log }: IEventContext,<br>  bind: IBind,<br>  _: ISecrets,<br>) =&gt; {<br>  const { current, roundId, updatedAt } = event<br><br>  const contractAddress = log.log_address.toLowerCase()<br><br>  // We have two databases, passing them in bind gives us connection to that databases<br>  const priceDB: Instance = bind(PriceDB)<br>  const chainlinkPairDB: Instance = bind(chainlinkPair)<br><br>  // We are storing a mapping and fetching data related to price pair<br>  const tokenMetadata = getTokenMetadata(contractAddress)<br><br>  // unique id for priceDB, this will just push this entry into the db<br>  const entryId = `${transaction.transaction_hash.toString()}-${log.log_index.toString()}`.toLowerCase()<br><br>  // as chainlink emits data in different decimal denominations, we need to divide it to get actual amount<br>  let amount = new BigNumber(current)<br>    .dividedBy(10 ** tokenMetadata.decimals)<br>    .toString()<br><br>  // First we will check whether this entry exists in our database or not<br>  let priceEntry: IPriceDB = await priceDB.findOne({<br>    id: entryId,<br>  })<br><br>  // If it doesn&#39;t exist we will create a new entry<br>  priceEntry ??= await priceDB.create({<br>    id: entryId,<br>    contractAddress,<br>    name: tokenMetadata.name,<br>    symbol: tokenMetadata.symbol,<br>    decimals: tokenMetadata.decimals,<br>    quoteCurrency: tokenMetadata.quoteCurrency,<br>    price: current,<br>    raw_price: amount,<br>  })<br><br>  const uniqueId = contractAddress<br>  const transaction_hash = transaction.transaction_hash.toString()<br><br>  let pairData: IchainlinkPair = await chainlinkPairDB.findOne({<br>    id: uniqueId.toLowerCase(),<br>  })<br><br>  pairData ??= await chainlinkPairDB.create({<br>     id: uniqueId,<br>     roundId: &quot;&quot;,<br>     transanctionHash: &quot;&quot;,<br>     updateCount: 0,<br>     lastBlockNumber: 0<br>  }) <br><br>  // Here we are fetching the last pairData entry, and updating it <br>  pairData.roundId = roundId<br>  pairData.transanctionHash = transaction.transaction_hash<br>  pairData.lastBlockNumber = block.block_number<br>  pairData.updateCount += 1<br><br>  // finally save the data again to db<br>  await chainlinkPairDB.save(pairData)<br>}</pre><p>As database connections are injected inside the handler code, it is easy to connect to the database and perform CRUD operations.</p><blockquote>It is important to note that while using .create operator always provides default values to all entries of the database schema.</blockquote><p>One more important thing to note is that database operations return a promise, so always use await it before interacting with the database.</p><p>now, that we are done with the logic part, let’s test it.</p><h4>Testing the Handler</h4><p><em>Before running the test make sure you have a local MongoDB connection running at the port </em><em>27017</em></p><p>To test our handler code, we can use the following command:</p><pre>blockflow instance-test --startBlock &lt;block number&gt; --clean --range &lt;block range&gt; --uri &lt;connection string&gt;</pre><p>Replace &lt;block number&gt; with the block number you want to start testing from, and &lt;connection string&gt; with your MongoDB connection URL (default <em>mongodb://localhost:27017/blockflow_studio</em> for local testing).</p><p>And there you have it! We’ve successfully indexed Chainlink price oracles using the Blockflow CLI. By following these steps, you can easily track and store any information available on the blockchain.</p><p>But remember, this is just the beginning of your indexing journey with Blockflow. There’s so much more you can do, like indexing function calls, storage slots, and view functions, but these are topics for another blog.</p><p>Stay tuned for more exciting guides and tutorials that will take your indexing skills to the next level. Happy indexing!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c5d2a860a1c4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Indexing ERC4337 (Account Abstraction)]]></title>
            <link>https://medium.com/@blockflowhq/indexing-erc4337-account-abstraction-52070c479672?source=rss-ab72e246dfce------2</link>
            <guid isPermaLink="false">https://medium.com/p/52070c479672</guid>
            <category><![CDATA[erc-4337]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[indexing]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[account-abstraction]]></category>
            <dc:creator><![CDATA[Blockflow]]></dc:creator>
            <pubDate>Wed, 21 Feb 2024 23:06:36 GMT</pubDate>
            <atom:updated>2024-06-27T12:56:13.450Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide will focus on indexing ERC4337 (Account abstraction) using the blockflow console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LmTxxGMCfonr_XnLLzPidA.png" /></figure><p>If you’re new to this guide do check — <a href="https://medium.com/@flow_block/a-beginner-guide-to-indexing-erc20-transfers-5b6dfc991ae3">A Beginner Guide to Indexing ERC20 transfers</a>.</p><p>Before we dive deep into the know-how for indexing ERC4337, it’s important to get an in-depth understanding of <a href="https://medium.com/infinitism/erc-4337-account-abstraction-without-ethereum-protocol-changes-d75c9d94dc4a">Account Abstraction</a>.</p><p>Now coming to the topic of indexing ERC4337 <em>userOperations</em>, first, we’ll need to understand what exactly we are trying to index.</p><p>Account Abstraction user operation is a new transaction type. UserOperations allow users to define a series of steps that should be executed as part of a single operation.</p><p>But indexing <em>userOperation</em> end to end will need data from multiple places, some data is stored in transaction functionCall and some is emitted as an event.</p><ul><li>Event: <em>UserOperationEvent(bytes32 userOpHash, address sender, address paymaster, uint256 nonce, bool success, uint256 actualGasCost, uint256 actualGasUsed)</em></li><li>Function: <em>handleOps(tuple[] ops, address beneficiary)</em></li></ul><p>Let’s start by creating a database in the blockflow console that will store <em>userOperation</em> of account abstraction.</p><pre>{<br>  // will get these from event data<br>  id: String; // userOp hash<br>  txHash: String;<br>  block: String;<br>  bundler: String;<br>  sender: String;<br>  paymaster: String;<br>  nonce: Number;<br>  success: Boolean;<br>  actualGasCost: Number;<br>  actualGasUsed: Number;<br>  createdAt: String;<br><br>  // Will get all these from function calldata<br>  initCode: string;<br>  callData: string;<br>  callGasLimit: string;<br>  verificationGasLimit: string;<br>  preVerificationGas: string;<br>  maxFeePerGas: string;<br>  maxPriorityFeePerGas: string;<br>  paymasterAndData: string;<br>  signature: string;<br>  beneficiary: string;<br>}</pre><p>Let’s name this database as <strong>UserOperation!</strong></p><p>Once we’re done with creating a database, the next step would be to write instance logic. As two triggers provide this data, we’ll need to create an instance with two trigger types:</p><ul><li>contract event trigger.</li><li>function call trigger.</li></ul><h3>Contract Event Trigger</h3><p>This type triggers whenever a particular event is emitted by a contract in inspection. In this tutorial perspective, it will be triggered whenever <em>UserOperationEvent</em> executes on the entry point contract.</p><pre>/**<br> * @dev Event::UserOperationEvent(bytes32 userOpHash, address sender, address paymaster, uint256 nonce, bool success, uint256 actualGasCost, uint256 actualGasUsed)<br> * @param context trigger object with contains {event: {userOpHash ,sender ,paymaster ,nonce ,success ,actualGasCost ,actualGasUsed }, transaction, block, log}<br> * @param bind init function for database wrapper methods<br> */<br>export const handler = async (<br>  context: IEventContext,<br>  bind: IBind,<br>  secrets: any<br>) =&gt; {<br>    const { event, transaction, block, log } = context;<br>    let {<br>      userOpHash,<br>      sender,<br>      paymaster,<br>      nonce,<br>      success,<br>      actualGasCost,<br>      actualGasUsed,<br>    } = event;<br><br>    nonce = nonce.toString();<br>    sender = sender.toString();<br>    paymaster = paymaster.toString();<br>    userOpHash = userOpHash.toString();<br>    actualGasCost = actualGasCost.toString();<br>    actualGasUsed = actualGasUsed.toString();<br>}</pre><p>Now as we are already familiar with concepts of connecting to a database (<a href="https://medium.com/@flow_block/a-beginner-guide-to-indexing-erc20-transfers-5b6dfc991ae3">check</a>). We’ll be connecting the <strong>UserOperation </strong>database<strong>.</strong></p><pre>// code continued ...<br>const userOpDB = bind(UserOperation);<br><br>// making userOpHash an index parameter i.e. id<br>let userOp = await userOpDB.findOne({ id: userOpHash.toLowerCase()});<br><br>// if this userOp doesn&#39;t exists in database we need to create its entry<br>userOp ??= await userOpDB.create({ id: userOpHash.toLowerCase() });</pre><p>Now, we are done with the connection, and loaded/created our <em>userOp</em> object.</p><p>Let’s quickly fill in the rest of the logic.</p><pre>export const handler = async (<br>  context: IEventContext,<br>  bind: IBind,<br>  secrets: any<br>) =&gt; {<br>  const { event, transaction, block, log } = context;<br>  let {<br>    userOpHash,<br>    sender,<br>    paymaster,<br>    nonce,<br>    success,<br>    actualGasCost,<br>    actualGasUsed,<br>  } = event;<br><br>  nonce = nonce.toString();<br>  sender = sender.toString();<br>  paymaster = paymaster.toString();<br>  userOpHash = userOpHash.toString();<br>  actualGasCost = actualGasCost.toString();<br>  actualGasUsed = actualGasUsed.toString();<br><br>  const userOpDB = bind(UserOperation);<br><br>  // making userOpHash an index parameter i.e. id<br>  let userOp = await userOpDB.findOne({ id: userOpHash.toLowerCase()});<br>  <br>  // if this userOp doesn&#39;t exists in database we need to create its entry<br>  userOp ??= await userOpDB.create({ id: userOpHash.toLowerCase() });<br><br>  userOp.bundler = transaction.transaction_from_address.toLowerCase();<br>  userOp.paymaster = paymaster.toLowerCase();<br>  userOp.sender = sender;<br>  userOp.nonce = Number(nonce);<br>  userOp.success = success;<br>  userOp.actualGasCost = Number(actualGasCost);<br>  userOp.actualGasUsed = Number(actualGasUsed);<br><br>  userOp.txHash = transaction.transaction_hash;<br>  userOp.createdAt = block.block_timestamp;<br><br>  // Now last things is to save this data into the database again.<br>  await userOpDB.save(userOp);<br>}</pre><p>we’re done with the first half of the indexing, now let’s move on to the next part i.e. function call indexing.</p><h3>function call trigger</h3><p>This type triggers when a transaction to contract occurs, and you want to index input parameters of that transaction calldata. In this tutorial perspective, it will be triggered whenever the <em>userOperation</em> transaction is sent to the entry point contract.</p><p>Before we go writing a handler for this one, we need to calculate the <em>userOpHash</em> off-chain in our logics. But what’s a <strong>userOpHash</strong>?</p><p>The userOpHash in ERC-4337 tx is a hash over the userOp (except signature), entryPoint, and chainId. It is used to validate the caller as a trusted EntryPoint and to ensure that the user operation is valid based on the <em>userOpHash</em>. In layman’s terms, user op is similar to transaction hash.</p><p>To calculate <em>userOpHash</em> off-chain, we will be using this function.</p><pre>import { keccak256 } from &quot;@ethersproject/keccak256&quot;;<br>import { defaultAbiCoder } from &quot;@ethersproject/abi&quot;;<br><br>function pack(userOp: any) {<br>  const sender = userOp.sender;<br>  const nonce = userOp.nonce;<br>  const hashInitCode = keccak256(userOp.initCode);<br>  const hashCallData = keccak256(userOp.callData);<br>  const callGasLimit = userOp.callGasLimit;<br>  const verificationGasLimit = userOp.verificationGasLimit;<br>  const preVerificationGas = userOp.preVerificationGas;<br>  const maxFeePerGas = userOp.maxFeePerGas;<br>  const maxPriorityFeePerGas = userOp.maxPriorityFeePerGas;<br>  const hashPaymasterAndData = keccak256(userOp.paymasterAndData);<br><br>  const types = [<br>    &quot;address&quot;,<br>    &quot;uint256&quot;,<br>    &quot;bytes32&quot;,<br>    &quot;bytes32&quot;,<br>    &quot;uint256&quot;,<br>    &quot;uint256&quot;,<br>    &quot;uint256&quot;,<br>    &quot;uint256&quot;,<br>    &quot;uint256&quot;,<br>    &quot;bytes32&quot;,<br>  ];<br>  const values = [<br>    sender,<br>    nonce,<br>    hashInitCode,<br>    hashCallData,<br>    callGasLimit,<br>    verificationGasLimit,<br>    preVerificationGas,<br>    maxFeePerGas,<br>    maxPriorityFeePerGas,<br>    hashPaymasterAndData,<br>  ];<br><br>  return defaultAbiCoder.encode(types, values);<br>}<br><br>function getUserOpHash(userOp: any, entryPointAddr: string, chainId: string) {<br>  // Hash the packed data<br>  const hashedUserOp = keccak256(pack(userOp));<br><br>  // Correct the types to match the values being encoded<br>  const types = [&quot;bytes32&quot;, &quot;address&quot;, &quot;uint256&quot;];<br>  const values = [hashedUserOp, entryPointAddr, chainId];<br><br>  // Encode and hash again<br>  const encoded = defaultAbiCoder.encode(types, values);<br>  return keccak256(encoded);<br>}</pre><p>Now, we have everything ready to index userOp final parameters. We’ll reconnect with the <strong>UserOperation </strong>database in function call handler, and update it with important values.</p><pre>const CHAIN_ID = &quot;1&quot;; // ethereum<br>/**<br> * @dev Function::handleOps(tuple[] ops, address beneficiary)<br> * @param context trigger object with contains {function: {ops ,beneficiary }, transaction, block, log}<br> * @param bind init function for database wrapper methods<br> */<br>export const handler = async (context: IFunctionContext, bind: IBind, secrets: any) =&gt; {<br>  // Implement your function handler logic for handleOps here<br><br>  const { functionParams, transaction, block } = context;<br>  let { ops, beneficiary } = functionParams;<br><br>  beneficiary = beneficiary.toString();<br><br>  const entryPoint = transaction.transaction_to_address;<br>}</pre><p>Since handleOps function takes an array of userOp tuples, we’ll need to loop over each entry, calculate its userOp hash and update entries in the database.</p><pre>const CHAIN_ID = &quot;1&quot;;<br>export const handler = async (context: IFunctionContext, bind: Function, secrets: any) =&gt; {<br>  const { functionParams, transaction, block } = context;<br>  let { ops, beneficiary } = functionParams;<br><br>  beneficiary = beneficiary.toString();<br><br>  const entryPoint = transaction.transaction_to_address;<br><br>   for (const op of ops) {<br>    const userOpHash = getUserOpHash(op, entryPoint, CHAIN_ID);<br><br>    const userOpDB = bind(UserOperation);<br>    <br>    // since userOpHash is unique id, we&#39;ll be updating the same document<br>    // that we updated in event based trigger above.<br>    let userOp = await userOpDB.findOne({ id: userOpHash.toLowerCase() });<br>    userOp ??= await userOpDB.create({ id: userOpHash.toLowerCase() });<br><br>    userOp.sender = op.sender;<br>    userOp.nonce = op.nonce;<br>    userOp.initCode = op.initCode;<br>    userOp.callData = op.callData;<br>    userOp.callGasLimit = op.callGasLimitring;<br>    userOp.verificationGasLimit = op.verificationGasLimit;<br>    userOp.preVerificationGas = op.preVerificationGas;<br>    userOp.maxFeePerGas = op.maxFeePerGas;<br>    userOp.maxPriorityFeePerGas = op.maxPriorityFeePerGas;<br>    userOp.paymasterAndData = op.paymasterAndData;<br>    userOp.signature = op.signature;<br>    userOp.beneficiary = beneficiary;<br><br>    // save each userOp entry into the database.<br>    await userOpDB.save(userOp);<br>  }<br>}</pre><p>And that’s it! In a few lines of code, we’ve indexed userOperations. But that’s just the tip of the iceberg in indexing ERC4337, there are more folks in the picture than userOp. There exist bundlers, paymasters, and especially user accounts.</p><p>But indexing those is a topic for another guide. See ya!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52070c479672" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Indexing ERC20]]></title>
            <link>https://medium.com/@blockflowhq/a-beginner-guide-to-indexing-erc20-transfers-5b6dfc991ae3?source=rss-ab72e246dfce------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b6dfc991ae3</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[erc20]]></category>
            <category><![CDATA[data]]></category>
            <category><![CDATA[blockflow]]></category>
            <category><![CDATA[indexing]]></category>
            <dc:creator><![CDATA[Blockflow]]></dc:creator>
            <pubDate>Wed, 21 Feb 2024 19:33:30 GMT</pubDate>
            <atom:updated>2024-06-22T05:38:49.478Z</atom:updated>
            <content:encoded><![CDATA[<p>This guide will focus on indexing ERC20 token transfers using the blockflow console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UcKJB20tQAvsZ7_ikNHVbA.png" /></figure><p><strong>What is Blockflow?</strong></p><p><a href="https://blockflow.network/">Blockflow</a> is a serverless backend infra provider for web3, that helps you build trigger-based backends with ease.</p><p>Now coming to the topic of indexing ERC20 transfer, first, we’ll need to understand what exactly we are trying to index. We wanted a database that stores the balance information of the user.</p><p>ERC20 standard contract emits an event named: <strong>“Transfer(address,address,uint256)” </strong>that is emitted when a transfer happens between any two addresses. We will be indexing this event.</p><p>As blockflow supports MongoDB as a managed database, firstly we need to create a <a href="https://app.blockflow.network/databases/create">database</a>. The database should have the following schema for indexing ERC20. Let&#39;s name this database <strong>Balances</strong>.</p><pre>{<br>    id: &quot;String&quot;,<br>    address: &quot;String&quot;,<br>    interactedAddresses: &quot;Array&quot;,<br>    tradeVolume: &quot;String&quot;,<br>    currentBalance: &quot;String&quot;,<br>    allTimeHigh: &quot;String&quot;,<br>    transactionHash: &quot;String&quot;,<br>  }</pre><p>Now what does each field mean?</p><ul><li><strong>id</strong>: This is an indexed parameter in the managed database and a required parameter, that should be used in a way to minimise efforts to find specific documents from mongoDB (ex. make id as user address)</li><li><strong>address</strong>: Current user address, can be from or to the address of the event.</li><li><strong>interactedAddress</strong>: It’s an array that stores all the addresses interacted with by a particular user.</li><li><strong>tradeVolume</strong>: This stores the all-time trade volume of that address.</li><li><strong>currentBalance</strong>: Current balance of the token of that address.</li><li><strong>allTimeHigh</strong>: This is the maximum holding of that token by that particular address. It can be greater or equal to <em>currentBalance</em>.</li><li><strong>transactionHash</strong>: The transaction hash of the current transfer.</li></ul><p>Now we have the database defined, let’s move on to the compute part <strong><em>Instances</em></strong>.</p><p><strong>What are Instances?</strong></p><p><a href="https://app.blockflow.network/instances/create">Instances</a> are compute or lambda functions, that trigger whenever a particular condition is met. Condition can be any blockchain trigger, let it be an event, function call, or slot change.</p><p>Instances are also the gateway to your database, based on the logic defined there your database will fill up.</p><p>An instance function looks like —</p><pre>/**<br> * @dev Event::Transfer(address from, address to, uint256 value)<br> * @param context trigger object with contains {event: {from ,to ,value }, transaction, block, log}<br> * @param bind Gateway to your database.<br> * @param secrets Key value database that stores your secrets <br> */<br>export const handler = async (context: IEventContext, bind: IBind, secrets: any) =&gt; {<br>  let { from, to, value } = context.event;<br><br>   // define your logics here. <br>}</pre><p>Now, what are these three parameters?</p><ul><li><strong>context</strong>: It is a javascript object that contains information about a particular event that triggered this lambda, as our trigger type is a contract event. It contains event, transaction, block, log.</li><li><strong>bind</strong>: This is your gateway to the managed database, this method returns a MongoDB instance of your database, and using this instance you can perform CRUD operations on your db.</li><li><strong>secrets</strong>: Well we shouldn’t tell this, but these are secrets of your project. shhh….</li></ul><p>! Do not change function names or params.</p><p>Now we have our battleground ready, we need to deploy our logic here.</p><p>So, the logic section is divided into four parts.</p><ol><li>Connecting Instance with Database.</li><li>Reading from database</li><li>Instance logics</li><li>Updating the database.</li></ol><p>Let’s get started then,</p><h3><strong>Connecting Instance with the database</strong></h3><p>As we already mentioned above the <em>bind</em> is your gateway to the database. Connecting with the database is an easy job.</p><p>We have a database ready, to connect with this database we need to pass its name into the bind function.</p><pre>export const handler = async (context: IEventContext, bind: IBind, secrets: any) =&gt; {<br>  let { from, to, value } = context.event;<br><br>   // Let&#39;s create a connection to Balances database.<br>  const balancesDB = bind(Balances);<br>}</pre><p>And done! We have successfully created a connection to the database. Remember this connection supports the following mongoose method.</p><blockquote>findOne(), updateOne(), save(), insertMany(), exists(), updateMany(), findOneAndUpdate(), replaceOne(), findOneAndReplace(), deleteOne(), deleteMany(), findOneAndDelete().</blockquote><p>Now we have our connection ready, let’s move on to the next step.</p><h3>Reading from database</h3><p>As we have our Mongoose connection ready, let’s try to read something from the <strong>Balances</strong> db.</p><pre>export const handler = async (context: IEventContext, bind: IBind, secrets: any) =&gt; {<br>  let { from, to, value } = context.event;<br><br>   // Let&#39;s create a connection to Balances database.<br>  const balancesDB = bind(Balances);<br><br>  // NOTE: Remeber all mongoose function returns a Promise, use await when interacting with database. <br><br>  // We&#39;ll check that from address entry exists in database or not<br>  let fromUser = await balancesDB.findOne({id: from.toLowerCase()});<br><br>  // if the fromUser entry is empty, means there no document matching that id<br>  // we will create a new user then.<br>  fromUser ??= await balancesDB.create({id: from.toLowerCase()});<br>}</pre><p>Isn’t it easy??</p><p>Moving onto the next part, defining logic.</p><h3>Instance logics</h3><p>As we previously mentioned we are trying to create a database that stores user balance information of that ERC20 token.</p><p>There are two users in the <strong>Transfer</strong> event, debit user (from address) and credit user (to address). So, we’ll need two documents from the <em>balancesDB.</em></p><pre>export const handler = async (context: IEventContext, bind: IBind, secrets: any) =&gt; {<br>  let { from, to, value } = context.event;<br><br>   // Let&#39;s create a connection to Balances database.<br>  const balancesDB = bind(Balances);<br><br>  // We&#39;ll check that from address entry exists in database or not<br>  let fromUser = await balancesDB.findOne({id: from.toLowerCase()});<br><br>  // if the fromUser entry is empty, means there no document matching that id<br>  // we will create a new user then.<br>  fromUser ??= await balancesDB.create({id: from.toLowerCase()});<br><br>  // We&#39;ll check that to address entry exists in database or not<br>  let toUser = await balancesDB.findOne({id: to.toLowerCase()});<br><br>  // if the toUser entry is empty, means there no document matching that id<br>  // we will create a new user then.<br>  toUser ??= await balancesDB.create({id: to.toLowerCase()});<br>}</pre><p>Now we have Mongo documents for both users ready, let’s apply some logic.</p><pre>export const handler = async (context: IEventContext, bind: IBind, secrets: any) =&gt; {<br>  let { from, to, value } = context.event;<br>  // value is a bigNumber type, convert it to string.<br>  value = value.toString();<br><br>  const zeroAddress = &quot;0x0000000000000000000000000000000000000000&quot;;<br><br>   // Let&#39;s create a connection to Balances database.<br>  const balancesDB = bind(Balances);<br><br>  // We&#39;ll check that from address entry exists in database or not<br>  let fromUser = await balancesDB.findOne({id: from.toLowerCase()});<br><br>  // if the fromUser entry is empty, means there no document matching that id<br>  // we will create a new user then.<br>  fromUser ??= await balancesDB.create({id: from.toLowerCase()});<br><br>  // We&#39;ll check that to address entry exists in database or not<br>  let toUser = await balancesDB.findOne({id: to.toLowerCase()});<br><br>  // if the toUser entry is empty, means there no document matching that id<br>  // we will create a new user then.<br>  toUser ??= await balancesDB.create({id: to.toLowerCase()});<br><br>  fromUser.address = from.toString();<br>  fromUser.transactionHash = context.transaction.transaction_hash.toString();<br>  // remeber we defined allTimeHigh type as string!<br>  fromUser.allTimeHigh = new BigNumber(fromUser.allTimeHigh || 0).toString();<br><br>  toUser.address = to.toString();<br>  toUser.transactionHash = context.transaction.transaction_hash.toString();<br>  toUser.allTimeHigh = new BigNumber(toUser.allTimeHigh || 0).toString();<br><br>  // if the interactedAddresses doesn&#39;t contains toUser address it means<br>  // it&#39;s their first time transfering tokens.<br>  if (!fromUser.interactedAddresses.includes(toUser.address))<br>    fromUser.interactedAddresses.push(toUser.address);<br><br>  // same goes with toUser interactedAddresses array<br>  if (!toUser.interactedAddresses.includes(fromUser.address))<br>    toUser.interactedAddresses.push(fromUser.address);<br><br>  // As ERC20 tokens can be minted and burned, it is better to handle that case<br>  if (from === zeroAddress) {<br>    toUser.currentBalance = new BigNumber(toUser.currentBalance || 0)<br>      .plus(value)<br>      .toString();<br>  } else if (to === zeroAddress) {<br>    fromUser.currentBalance = new BigNumber(fromUser.currentBalance || 0)<br>      .minus(value)<br>      .toString();<br>  } else {<br>    fromUser.currentBalance = new BigNumber(fromUser.currentBalance || 0)<br>      .minus(value)<br>      .toString();<br>    toUser.currentBalance = new BigNumber(toUser.currentBalance || 0)<br>      .plus(value)<br>      .toString();<br>  }<br><br>  // all time high logic<br>  if (<br>    new BigNumber(fromUser.currentBalance).gt(<br>      new BigNumber(fromUser.allTimeHigh || 0)<br>    )<br>  )<br>    fromUser.allTimeHigh = fromUser.currentBalance.toString();<br><br>  if (<br>    new BigNumber(toUser.currentBalance).gt(<br>      new BigNumber(toUser.allTimeHigh || 0)<br>    )<br>  )<br>    toUser.allTimeHigh = toUser.currentBalance.toString();<br><br>  // Trade volume logics<br>  if (fromUser.address !== zeroAddress)<br>    fromUser.tradeVolume = new BigNumber(fromUser.tradeVolume || 0)<br>      .plus(value)<br>      .toString();<br><br>  if (toUser.address !== zeroAddress)<br>    toUser.tradeVolume = new BigNumber(toUser.tradeVolume || 0)<br>      .plus(value)<br>      .toString();<br>}</pre><p>and logic is done, but wait the next step is the most crucial, yes!!! updating the database?</p><h3><strong>Updating the database</strong></h3><p>Last and the most crucial step, is to update the database. There is more than one way to update the Mongo database. (save, updateOne, updateMany).</p><p>But as we are not sure whether that particular user is either created or loaded from any previous entry. We will be using save which handles both cases.</p><pre>export const handler = async (context: IEventContext, bind: IBind, secrets: any) =&gt; {<br>  let { from, to, value } = context.event;<br>  // value is a bigNumber type, convert it to string.<br>  value = value.toString();<br><br>  const zeroAddress = &quot;0x0000000000000000000000000000000000000000&quot;;<br><br>   // Let&#39;s create a connection to Balances database.<br>  const balancesDB = bind(Balances);<br><br>  // ... code from above<br><br>  // saving the toUser, and fromUser into the database<br>  await balancesDB.save(fromUser);<br>  await balancesDB.save(toUser);<br>}</pre><p>that’s it, we’ve successfully saved it into the database. But wait what about <em>chain reorgs</em>?</p><p>You don&#39;t need to worry about it, blockflow automatically <em>resets and re-sync</em> your database in case of chain reorgs. So, it’s like Reorg never happened!</p><p>So, in this tutorial, we learnt how to index an ERC20 token transfer, but what about consuming that data stored in <em>Balances DB?</em></p><p>Well, that’s the topic for another guide! See ya!</p><p>(PS: You can use blockflow APIs to consume those data.)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b6dfc991ae3" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Managed Databases, IFTTT Instances, and Custom APIs: 
The Pillars of Blockflow]]></title>
            <link>https://medium.com/@blockflowhq/managed-databases-ifttt-instances-and-custom-apis-the-pillars-of-blockflow-9c5678599938?source=rss-ab72e246dfce------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c5678599938</guid>
            <category><![CDATA[data]]></category>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[cloud-computing]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Blockflow]]></dc:creator>
            <pubDate>Wed, 07 Feb 2024 16:55:39 GMT</pubDate>
            <atom:updated>2024-02-07T16:55:39.047Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Managed Databases, IFTTT Instances, and Custom APIs: <br>The Pillars of Blockflow</strong></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Drio7Hy_IVGDde-ojYDQLQ.png" /></figure><h3><strong>Introduction</strong></h3><p>Greetings from Team Blockflow!</p><p>Our collective journey has been fueled by a commitment to transform the intricate blockchain environment into a streamlined landscape for developers.</p><p>At the heart of Blockflow’s offerings lies an architectural masterpiece, our team has been building in stealth for the past 1.5 years.</p><p>We’ve intricately indexed, streamed, and pipelined every element of blockchain data into a comprehensive storage graph, making it possible for every builder to retrieve, filter, stream, process &amp; store data with ease. Precision, speed, and accuracy are the hallmarks of our infrastructure, ensuring every interaction and transaction is processed with unparalleled efficiency.</p><p>Today, we start introducing our developments with the world, and we’ll continue to do so over the coming months &amp; years.</p><h3><strong>Managed Databases</strong></h3><p>Data is the cornerstone of any robust blockchain application, but managing it shouldn’t detract from your core objectives. Our Managed Databases are designed to handle the nuances of blockchain data storage, scalability, rate limits, and backups, our managed databases provide a solid foundation, allowing you to focus on innovation rather than infrastructure.</p><h3><strong>IFTTT Instances</strong></h3><p>The blockchain is a database with continuous flow of logs, transactions, traces &amp; internal steps, state changes, etc. Staying responsive is key.</p><p>Instances are<strong> IFTTT </strong>(If This Then That) compute engines. They look for specific <strong>conditions/triggers</strong> on the blockchain. If the condition is met, an <strong>action</strong> is executed.</p><p>An instance can be run on historical &amp; real-time blockchain data.</p><p>Checkout this guide to build an instance: <br><a href="https://docs.blockflow.network/instances/getting-started">https://docs.blockflow.network/instances/getting-started</a></p><h4>What can be the trigger?</h4><ol><li>An event in a smart contract</li><li>A function call in a smart contract</li><li>A transaction from an address</li><li>A transaction to a smart contract</li><li>An event in any smart contract</li><li>A storage slot update in a smart contract</li></ol><p>And many more…</p><h4>What can be the action?</h4><p>Anything that can be done via code can be the action :)</p><p>Here are some examples of what most people use it for:</p><ol><li>Stream data to their database</li><li>Update user profiles</li><li>Sending notifications</li><li>Send transactions to the blockchain</li><li>Inform your team if a parameter breaks</li></ol><p>And many more…</p><h4>Key Things to note</h4><ol><li>Instances are real-time. As soon as a block with the specificied <strong>Trigger</strong> is published, the <strong>Action</strong> execution is started in &lt;20ms! The whole execution time of the action can vary based on the complexity of the logic.</li><li>Instances are re-org aware. Your database will never store corrupted data!</li><li>Instances are robust and stress-tested. 100% uptime!</li></ol><h3><strong>Custom APIs</strong></h3><p>Whether your focus is on integrating disparate data sources or ensuring global scalability, our APIs are your reliable partners, ensuring your vision for a blockchain application is not constrained by technical limitations. Using the API engine, APIs can be created on top of managed &amp; unmanaged databases.</p><p>Checkout this guide to build an instance: <br><a href="https://docs.blockflow.network/apis/getting-started">https://docs.blockflow.network/apis/getting-started</a></p><h4>Key Things to note</h4><ol><li>APIs are protocol &amp; chain agnostic. You can aggregate data from multiple protocols &amp; multiple chains!</li><li>APIs are robust and stress-tested. 100% uptime!</li><li>APIs are region-aware. No need to deploy &amp; manage your API servers in multiple regions!</li><li>Auto-scaling. APIs scale with your usage!</li></ol><h3><strong>Data Integrity and Performance: Our Commitment</strong></h3><p>In the realm of Blockflow, data integrity is paramount. Our proactive approach to maintaining data accuracy, especially in scenarios like chain-reorgs, is what sets us apart. We ensure that the data your applications rely on is not just current but also impeccably accurate. Scalability and performance are ingrained in Blockflow, with our architecture ensuring that as your user base grows, so does our support, seamlessly and efficiently.</p><h3>What’s in it for you?</h3><ol><li>Ship fast. Stay ahead of the competition. Be it getting out your MVP, alpha, or v2. Blockflow enable you to quickly spin up the backend for your web3 product!</li><li>Maximize Dev Productivity. Devs and product teams can spend more time on building the right incentives and building the product your users deserve without spending time managing RPC malfunctions, server management, and infrastructure monitoring!</li><li>Stay on top of user behavior. Set up monitoring for user events, and actions, and optimize your strategy.</li><li>Focus on your product. No need to manage servers, databases, or deal with RPCs!</li></ol><h3><strong>Conclusion</strong></h3><p>Team Blockflow is more than a group of individuals; we’re innovators, problem-solvers, and, most importantly, enablers. Managed Databases, On-Chain Triggers, and Custom APIs are not just our products; they’re our pledges to the blockchain community. As you embark on your blockchain journey, remember that Blockflow is with you, lending expertise, technology, and a vision that’s shared and supported by a team that’s as invested in your success as you are.</p><p><strong>Stay Connected:<br></strong>To keep up-to-date with the latest from Blockflow, follow us on our social channels: <a href="https://blockflow.network/">Website</a>, <a href="https://twitter.com/flow_block">Twitter</a>, <a href="http://discord.gg/Sa2MjMNkm3">Discord</a>, <a href="https://www.youtube.com/@flow_block">Youtube</a>, and <a href="https://linktr.ee/blockflow">Linktree</a></p><p><strong>Schedule a Demo:<br></strong>Dive deeper into the capabilities of Blockflow by scheduling a demo with us. <a href="https://calendly.com/vaibhav_khanna/">CLICK HERE</a></p><p><strong>Join Our Discord Community:<br></strong>Engage with like-minded innovators and our team by joining our Discord community. <a href="http://discord.gg/Sa2MjMNkm3">CLICK HERE</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c5678599938" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Introducing Blockflow: Revolutionize Your Web3 Development]]></title>
            <link>https://medium.com/@blockflowhq/introducing-blockflow-revolutionize-your-web3-development-405b9d25cf14?source=rss-ab72e246dfce------2</link>
            <guid isPermaLink="false">https://medium.com/p/405b9d25cf14</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[backend]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Blockflow]]></dc:creator>
            <pubDate>Mon, 29 Jan 2024 05:17:03 GMT</pubDate>
            <atom:updated>2024-01-29T05:17:03.135Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jWl4zu6ydZoQPi1fHr9Szg.jpeg" /></figure><p>In a realm where innovation is relentless, and the pace of development is brisk, the need for robust, efficient, and agile products has never been more critical.</p><p>Enter Blockflow — a visionary solution crafted from the intricate tapestry of Web3 development challenges and breakthroughs. Our journey at Blockflow is not just about developing a product; it’s about fostering a revolution.</p><p><strong>The Genesis of Blockflow</strong></p><p>Our foray into the world of decentralized applications (dApps) was driven by a revolutionary vision — to democratize the financial landscape by enabling on-chain undercollateralized lending. We envisioned a future where digital assets like Google or Amazon stocks could serve as collateral, mirroring the financial leverage enjoyed by industry magnates. However, this vision was not without its trials. We grappled with the immense challenge of sourcing extensive data within DeFi protocols and calculating intricate credit scores. The journey was arduous, laden with hurdles of data retrieval, the unpredictability of RPCs, and rate limits.</p><p><strong>The Emergence of a Solution</strong></p><p>It was through these challenges that Blockflow was born. A solution that transcended the typical confines of Web3 development tools. Blockflow is not merely a product; it’s a testament to the ingenuity of overcoming the complexities of on-chain data indexing. Our platform is an amalgamation of Managed Databases, On-chain Triggers, and Custom APIs — a triad of features that synergize to streamline the backend development for crypto teams.</p><p><strong>Blockflow’s Distinctive Edge</strong></p><p>Blockflow is designed to empower. With our platform, the development time is significantly reduced — tasks that once took months now take mere days. We understand the pulse of the market, and our features are tailored to ensure a substantial reduction in time to market. February is a landmark month for us, as we gear up to achieve impressive benchmarks:</p><ul><li>A latency benchmark of approximately 500ms</li><li>Data accuracy benchmark of nearly 99%</li><li>Integration of 5 EVM Chains</li><li>Ensuring 99% Uptime</li><li>36 Community Templates</li></ul><p><strong>A Platform for Visionaries</strong></p><p>Blockflow is more than a product; it’s a partner in your Web3 development journey. Whether you’re a CTO, a developer, or a product manager, Blockflow is your ally. Our platform simplifies the intricacies of building database backends for decentralized applications. We provide the ability to create dynamic database instances that react to blockchain events, stream data to databases, update user profiles, send notifications, and inform your team if a parameter breaks — all in real-time.</p><p><strong>Join the Revolution</strong></p><p>As we stand on the brink of our public launch on February 15, we extend an invitation to you. Join us in this revolution. Experience firsthand how Blockflow can transform your Web3 projects.</p><p><strong>Schedule a Demo:<br></strong>Dive deeper into the capabilities of Blockflow by scheduling a demo with us. <a href="https://calendly.com/vaibhav_khanna/">CLICK HERE</a></p><p><strong>Join Our Discord Community:<br></strong>Engage with like-minded innovators and our team by joining our Discord community. <a href="http://discord.gg/Sa2MjMNkm3">CLICK HERE</a></p><p><strong>Stay Connected:<br></strong>To keep up-to-date with the latest from Blockflow, follow us on our social channels: <a href="https://blockflow.network/">Website</a>, <a href="https://twitter.com/flow_block">Twitter</a>, <a href="http://discord.gg/Sa2MjMNkm3">Discord</a>, <a href="https://www.youtube.com/@flow_block">Youtube</a>, and <a href="https://linktr.ee/blockflow">Linktree</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=405b9d25cf14" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Build Web3 Notifications for your users: Blockflow Partners with Push Protocol]]></title>
            <link>https://medium.com/@blockflowhq/build-web3-notifications-for-your-users-blockflow-partners-with-push-protocol-de367eb578dd?source=rss-ab72e246dfce------2</link>
            <guid isPermaLink="false">https://medium.com/p/de367eb578dd</guid>
            <category><![CDATA[ethereum]]></category>
            <category><![CDATA[blockchain]]></category>
            <category><![CDATA[web3]]></category>
            <category><![CDATA[notifications]]></category>
            <category><![CDATA[backend]]></category>
            <dc:creator><![CDATA[Blockflow]]></dc:creator>
            <pubDate>Thu, 04 Jan 2024 20:54:47 GMT</pubDate>
            <atom:updated>2024-01-04T20:54:47.262Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kZcYF7soY-3D9PpsfRw3Tw.png" /></figure><p>Today, we at Blockflow are thrilled to announce our landmark partnership with Push Protocol — a collaboration set to redefine how notifications are managed and deployed in the Web3 space.</p><h3>Introducing a Seamless Integration</h3><p>Crypto moves fast, staying on top of notifications is critical. Immense dollars at stake, changing prices, drops in health factor, a little delay and you lose lots of money. <br>Blockflow is a blockchain backend data tool and Push is a communication layer, protocol teams can serve their users better, help them stay aware, and on-top of the fast moving crypto world.<br>Our effort is on empowering developers to seamlessly integrate a robust notification system into their decentralized applications (dApps). <br>With Blockflow’s backend tools and Push Protocol’s advanced notification infrastructure, setting up and managing alerts is now more intuitive and efficient than ever.</p><h3>A Use-Case to Showcase Our Synergy</h3><p>Imagine a scenario where a DeFi app needs to keep its users informed about critical updates like liquidations, parameter updates, transactions, or events. With our integrated solution, developers can effortlessly set up this notification logic in their backend using Blockflow and deliver these notifications through Push Protocol’s versatile channels. This synergy not only enhances user experience but also significantly cuts down development time.</p><h3>Getting Started with Blockflow and Push Protocol</h3><p>For developers eager to integrate this functionality, we’ve prepared comprehensive guides and resources:</p><p>Here’s a “How To” guide:</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FO2ryOeyX07U&amp;display_name=YouTube&amp;url=https%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DO2ryOeyX07U&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=google" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/e45af761542ebd66ea5e25f3c8ec7a29/href">https://medium.com/media/e45af761542ebd66ea5e25f3c8ec7a29/href</a></iframe><h3>Embracing the Future of Web3 Communications</h3><p>Our vision is to streamline the way Web3 applications interact with their users.</p><p>This partnership is a step forward in making this vision a reality — enhancing user engagement while providing developers with powerful tools to build and innovate.</p><h3>Your Feedback Matters</h3><p>As we embark on this exciting journey, we invite you to join us. Try out our integrated solutions, provide your valuable feedback, and be part of shaping the future of Web3 communications.</p><p>Have questions or need assistance? Our teams are ready to help. Reach out to us on our discord at <br><a href="https://t.co/UcqSk89UJ4">discord.gg/Sa2MjMNkm3</a></p><h3>Stay Connected</h3><p>To keep up-to-date with the latest from Blockflow and Push Protocol, follow us on our social channels:</p><p>Blockflow: <a href="https://blockflow.network/">Website</a>, <a href="https://twitter.com/flow_block">Twitter</a>, <a href="http://discord.gg/Sa2MjMNkm3">Discord</a>, <a href="https://www.youtube.com/@flow_block">Youtube</a>, and <a href="https://linktr.ee/blockflow">Linktree</a></p><p>Push Protocol: <a href="https://push.org/">Website</a>, <a href="https://twitter.com/pushprotocol">Twitter</a>, <a href="https://t.me/epnsproject">Telegram</a>, <a href="https://discord.gg/pushprotocol">Discord</a>, <a href="https://www.youtube.com/c/EthereumPushNotificationService">YouTube</a>, and <a href="https://linktr.ee/pushprotocol">Linktree</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de367eb578dd" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>