1:HL["/_next/static/media/2d141e1a38819612-s.p.woff2","font",{"crossOrigin":"","type":"font/woff2"}] 2:HL["/_next/static/css/b5cc68180eb3d7c9.css","style"] 0:["pCsDN6MV-QYfgzIcQCx8m",[[["",{"children":["blog",{"children":[["slug","introducing-zephyr","c"],{"children":["__PAGE__?{\"slug\":[\"introducing-zephyr\"]}",{}]}]}]},"$undefined","$undefined",true],"$L3",[[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/b5cc68180eb3d7c9.css","precedence":"next"}]],"$L4"]]]] 5:HL["/_next/static/css/dfa98ec29d4bb4d3.css","style"] 6:I{"id":7516,"chunks":["724:static/chunks/724-ae4ae561ef8e5138.js","998:static/chunks/998-271f973ed8f19b4a.js","185:static/chunks/app/layout-0d5bd8edaec8d1ef.js"],"name":"ThemeProviders","async":false} 7:I{"id":4244,"chunks":["724:static/chunks/724-ae4ae561ef8e5138.js","998:static/chunks/998-271f973ed8f19b4a.js","185:static/chunks/app/layout-0d5bd8edaec8d1ef.js"],"name":"","async":false} 8:I{"id":8251,"chunks":["724:static/chunks/724-ae4ae561ef8e5138.js","998:static/chunks/998-271f973ed8f19b4a.js","185:static/chunks/app/layout-0d5bd8edaec8d1ef.js"],"name":"KBarSearchProvider","async":false} 9:I{"id":4724,"chunks":["724:static/chunks/724-ae4ae561ef8e5138.js","964:static/chunks/964-256e2702ddb0b4bf.js","797:static/chunks/app/blog/[...slug]/page-6aeac4f36de46831.js"],"name":"","async":false} a:I{"id":7005,"chunks":["724:static/chunks/724-ae4ae561ef8e5138.js","998:static/chunks/998-271f973ed8f19b4a.js","185:static/chunks/app/layout-0d5bd8edaec8d1ef.js"],"name":"KBarButton","async":false} b:I{"id":7074,"chunks":["724:static/chunks/724-ae4ae561ef8e5138.js","998:static/chunks/998-271f973ed8f19b4a.js","185:static/chunks/app/layout-0d5bd8edaec8d1ef.js"],"name":"","async":false} c:I{"id":7365,"chunks":["724:static/chunks/724-ae4ae561ef8e5138.js","998:static/chunks/998-271f973ed8f19b4a.js","185:static/chunks/app/layout-0d5bd8edaec8d1ef.js"],"name":"","async":false} d:I{"id":1443,"chunks":["272:static/chunks/webpack-099e1b11ae967685.js","971:static/chunks/fd9d1056-80ea045f608d9add.js","864:static/chunks/864-65256e9be0d5c062.js"],"name":"","async":false} e:I{"id":8639,"chunks":["272:static/chunks/webpack-099e1b11ae967685.js","971:static/chunks/fd9d1056-80ea045f608d9add.js","864:static/chunks/864-65256e9be0d5c062.js"],"name":"","async":false} 4:[["$","meta","0",{"charSet":"utf-8"}],["$","title","1",{"children":"The Zephyr VM: core of the Mercury code execution environment. | xyclooLabs Blog"}],["$","meta","2",{"name":"description","content":"Zephyr is a WebAssembly host environment for providing to arbitrary code metered and sandboxed access to the Stellar Network data."}],["$","meta","3",{"name":"viewport","content":"width=device-width, initial-scale=1"}],["$","meta","4",{"name":"robots","content":"index, follow"}],["$","meta","5",{"name":"googlebot","content":"index, follow, max-video-preview:-1, max-image-preview:large, max-snippet:-1"}],["$","link","6",{"rel":"canonical","href":"https://blog.xycloo.com/blog/introducing-zephyr"}],["$","link","7",{"rel":"alternate","type":"application/rss+xml","href":"https://blog.xycloo.com/feed.xml"}],["$","meta","8",{"property":"og:title","content":"The Zephyr VM: core of the Mercury code execution environment."}],["$","meta","9",{"property":"og:description","content":"Zephyr is a WebAssembly host environment for providing to arbitrary code metered and sandboxed access to the Stellar Network data."}],["$","meta","10",{"property":"og:url","content":"https://blog.xycloo.com/blog/introducing-zephyr"}],["$","meta","11",{"property":"og:site_name","content":"xyclooLabs Blog"}],["$","meta","12",{"property":"og:locale","content":"en_US"}],["$","meta","13",{"property":"og:image","content":"https://blog.xycloo.com/static/images/twitter-card.png"}],["$","meta","14",{"property":"og:type","content":"article"}],["$","meta","15",{"property":"article:published_time","content":"2023-10-02T00:00:00.000Z"}],["$","meta","16",{"property":"article:modified_time","content":"2023-10-02T00:00:00.000Z"}],["$","meta","17",{"property":"article:author","content":"Tommaso"}],["$","meta","18",{"name":"twitter:card","content":"summary_large_image"}],["$","meta","19",{"name":"twitter:title","content":"The Zephyr VM: core of the Mercury code execution environment."}],["$","meta","20",{"name":"twitter:description","content":"Zephyr is a WebAssembly host environment for providing to arbitrary code metered and sandboxed access to the Stellar Network data."}],["$","meta","21",{"name":"twitter:image","content":"https://blog.xycloo.com/static/images/twitter-card.png"}],["$","meta","22",{"name":"next-size-adjust"}]] 3:[null,["$","html",null,{"lang":"en-us","className":"__variable_587f35 scroll-smooth","suppressHydrationWarning":true,"children":[["$","link",null,{"rel":"apple-touch-icon","sizes":"76x76","href":"/static/favicons/apple-touch-icon.png"}],["$","link",null,{"rel":"icon","type":"image/png","sizes":"32x32","href":"/static/images/logo.png"}],["$","link",null,{"rel":"icon","type":"image/png","sizes":"16x16","href":"/static/favicons/logo.png"}],["$","link",null,{"rel":"manifest","href":"/static/favicons/site.webmanifest"}],["$","link",null,{"rel":"mask-icon","href":"/static/favicons/safari-pinned-tab.svg","color":"#5bbad5"}],["$","meta",null,{"name":"msapplication-TileColor","content":"#000000"}],["$","meta",null,{"name":"theme-color","media":"(prefers-color-scheme: light)","content":"#fff"}],["$","meta",null,{"name":"theme-color","media":"(prefers-color-scheme: dark)","content":"#000"}],["$","link",null,{"rel":"alternate","type":"application/rss+xml","href":"/feed.xml"}],["$","body",null,{"className":"bg-white text-black antialiased dark:bg-gray-950 dark:text-white","children":["$","$L6",null,{"children":[["$undefined","$undefined","$undefined",["$","$L7",null,{"async":true,"defer":true,"data-website-id":"$undefined","src":"https://analytics.umami.is/script.js"}],"$undefined"],["$","section",null,{"className":"mx-auto max-w-3xl px-4 sm:px-6 xl:max-w-5xl xl:px-0","children":["$","div",null,{"className":"flex h-screen flex-col justify-between font-sans","children":[["$","$L8",null,{"kbarConfig":{"searchDocumentsPath":"search.json"},"children":[["$","header",null,{"className":"flex items-center justify-between py-10","children":[["$","div",null,{"children":["$","$L9",null,{"href":"/","aria-label":"xyclooLabs Blog","children":["$","div",null,{"className":"flex items-center justify-between","children":[["$","div",null,{"className":"mr-3","children":["$","img",null,{"className":"w-10","src":"../../static/images/logo.png"}]}],["$","div",null,{"className":"hidden h-6 text-2xl font-semibold sm:block","children":"xyclooLabs Blog"}]]}]}]}],["$","div",null,{"className":"flex items-center leading-5 space-x-4 sm:space-x-6","children":[[["$","$L9",null,{"href":"/blog","className":"hidden sm:block font-medium text-gray-900 dark:text-gray-100","children":"All Posts"}],["$","a",null,{"target":"_blank","rel":"noopener noreferrer","href":"https://xycloo.com","className":"hidden sm:block font-medium text-gray-900 dark:text-gray-100","children":"About"}]],["$","$La",null,{"aria-label":"Search","children":["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","fill":"none","viewBox":"0 0 24 24","strokeWidth":1.5,"stroke":"currentColor","className":"text-gray-900 dark:text-gray-100 h-6 w-6","children":["$","path",null,{"strokeLinecap":"round","strokeLinejoin":"round","d":"M21 21l-5.197-5.197m0 0A7.5 7.5 0 105.196 5.196a7.5 7.5 0 0010.607 10.607z"}]}]}],["$","$Lb",null,{}],["$","$Lc",null,{}]]}]]}],["$","main",null,{"className":"mb-auto","children":["$","$Ld",null,{"parallelRouterKey":"children","segmentPath":["children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$Le",null,{}],"templateStyles":"$undefined","notFound":["$","div",null,{"className":"flex flex-col items-start justify-start md:mt-24 md:flex-row md:items-center md:justify-center md:space-x-6","children":[["$","div",null,{"className":"space-x-2 pb-8 pt-6 md:space-y-5","children":["$","h1",null,{"className":"text-6xl font-extrabold leading-9 tracking-tight text-gray-900 dark:text-gray-100 md:border-r-2 md:px-6 md:text-8xl md:leading-14","children":"404"}]}],["$","div",null,{"className":"max-w-md","children":[["$","p",null,{"className":"mb-4 text-xl font-bold leading-normal md:text-2xl","children":"Sorry we couldn't find this page."}],["$","p",null,{"className":"mb-8","children":"But dont worry, you can find plenty of other things on our homepage."}],["$","$L9",null,{"href":"/","className":"focus:shadow-outline-blue inline rounded-lg border border-transparent bg-blue-600 px-4 py-2 text-sm font-medium leading-5 text-white shadow transition-colors duration-150 hover:bg-blue-700 focus:outline-none dark:hover:bg-blue-500","children":"Back to homepage"}]]}]]}],"notFoundStyles":[],"childProp":{"current":["$","$Ld",null,{"parallelRouterKey":"children","segmentPath":["children","blog","children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$Le",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$","$Ld",null,{"parallelRouterKey":"children","segmentPath":["children","blog","children",["slug","introducing-zephyr","c"],"children"],"loading":"$undefined","loadingStyles":"$undefined","hasLoading":false,"error":"$undefined","errorStyles":"$undefined","template":["$","$Le",null,{}],"templateStyles":"$undefined","notFound":"$undefined","notFoundStyles":"$undefined","childProp":{"current":["$Lf","$L10",null],"segment":"__PAGE__?{\"slug\":[\"introducing-zephyr\"]}"},"styles":[["$","link","0",{"rel":"stylesheet","href":"/_next/static/css/dfa98ec29d4bb4d3.css","precedence":"next"}]]}],"segment":["slug","introducing-zephyr","c"]},"styles":[]}],"segment":"blog"},"styles":[]}]}]]}],["$","footer",null,{"children":["$","div",null,{"className":"mt-16 flex flex-col items-center","children":[["$","div",null,{"className":"mb-3 flex space-x-4","children":[["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"mailto:hello@xycloo.com","children":[["$","span",null,{"className":"sr-only","children":"mail"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 20 20","className":"fill-current text-gray-700 hover:text-primary-500 dark:text-gray-200 dark:hover:text-primary-400 h-6 w-6","children":[["$","path",null,{"d":"M2.003 5.884L10 9.882l7.997-3.998A2 2 0 0016 4H4a2 2 0 00-1.997 1.884z"}],["$","path",null,{"d":"M18 8.118l-8 4-8-4V14a2 2 0 002 2h12a2 2 0 002-2V8.118z"}]]}]]}],["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"https://github.com/xycloo","children":[["$","span",null,{"className":"sr-only","children":"github"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 24 24","className":"fill-current text-gray-700 hover:text-primary-500 dark:text-gray-200 dark:hover:text-primary-400 h-6 w-6","children":["$","path",null,{"d":"M12 .297c-6.63 0-12 5.373-12 12 0 5.303 3.438 9.8 8.205 11.385.6.113.82-.258.82-.577 0-.285-.01-1.04-.015-2.04-3.338.724-4.042-1.61-4.042-1.61C4.422 18.07 3.633 17.7 3.633 17.7c-1.087-.744.084-.729.084-.729 1.205.084 1.838 1.236 1.838 1.236 1.07 1.835 2.809 1.305 3.495.998.108-.776.417-1.305.76-1.605-2.665-.3-5.466-1.332-5.466-5.93 0-1.31.465-2.38 1.235-3.22-.135-.303-.54-1.523.105-3.176 0 0 1.005-.322 3.3 1.23.96-.267 1.98-.399 3-.405 1.02.006 2.04.138 3 .405 2.28-1.552 3.285-1.23 3.285-1.23.645 1.653.24 2.873.12 3.176.765.84 1.23 1.91 1.23 3.22 0 4.61-2.805 5.625-5.475 5.92.42.36.81 1.096.81 2.22 0 1.606-.015 2.896-.015 3.286 0 .315.21.69.825.57C20.565 22.092 24 17.592 24 12.297c0-6.627-5.373-12-12-12"}]}]]}],null,null,null,["$","a",null,{"className":"text-sm text-gray-500 transition hover:text-gray-600","target":"_blank","rel":"noopener noreferrer","href":"https://twitter.com/xycloolabs","children":[["$","span",null,{"className":"sr-only","children":"twitter"}],["$","svg",null,{"xmlns":"http://www.w3.org/2000/svg","viewBox":"0 0 24 24","className":"fill-current text-gray-700 hover:text-primary-500 dark:text-gray-200 dark:hover:text-primary-400 h-6 w-6","children":["$","path",null,{"d":"M23.953 4.57a10 10 0 01-2.825.775 4.958 4.958 0 002.163-2.723c-.951.555-2.005.959-3.127 1.184a4.92 4.92 0 00-8.384 4.482C7.69 8.095 4.067 6.13 1.64 3.162a4.822 4.822 0 00-.666 2.475c0 1.71.87 3.213 2.188 4.096a4.904 4.904 0 01-2.228-.616v.06a4.923 4.923 0 003.946 4.827 4.996 4.996 0 01-2.212.085 4.936 4.936 0 004.604 3.417 9.867 9.867 0 01-6.102 2.105c-.39 0-.779-.023-1.17-.067a13.995 13.995 0 007.557 2.209c9.053 0 13.998-7.496 13.998-13.985 0-.21 0-.42-.015-.63A9.935 9.935 0 0024 4.59z"}]}]]}]]}],["$","div",null,{"className":"mb-2 flex space-x-2 text-sm text-gray-500 dark:text-gray-400","children":[["$","div",null,{"children":"xyclooLabs team"}],["$","div",null,{"children":" • "}],["$","div",null,{"children":"© 2024"}],["$","div",null,{"children":" • "}],["$","$L9",null,{"href":"/","children":"xyclooLabs Blog"}]]}]]}]}]]}]}]]}]}]]}],null] 11:I{"id":9315,"chunks":["724:static/chunks/724-ae4ae561ef8e5138.js","964:static/chunks/964-256e2702ddb0b4bf.js","797:static/chunks/app/blog/[...slug]/page-6aeac4f36de46831.js"],"name":"","async":false} 12:I{"id":2529,"chunks":["724:static/chunks/724-ae4ae561ef8e5138.js","964:static/chunks/964-256e2702ddb0b4bf.js","797:static/chunks/app/blog/[...slug]/page-6aeac4f36de46831.js"],"name":"","async":false} 13:I{"id":5397,"chunks":["724:static/chunks/724-ae4ae561ef8e5138.js","964:static/chunks/964-256e2702ddb0b4bf.js","797:static/chunks/app/blog/[...slug]/page-6aeac4f36de46831.js"],"name":"","async":false} 10:[["$","script",null,{"type":"application/ld+json","dangerouslySetInnerHTML":{"__html":"{\"@context\":\"https://schema.org\",\"@type\":\"BlogPosting\",\"headline\":\"The Zephyr VM: core of the Mercury code execution environment.\",\"datePublished\":\"2023-10-02T00:00:00.000Z\",\"dateModified\":\"2023-10-02T00:00:00.000Z\",\"description\":\"Zephyr is a WebAssembly host environment for providing to arbitrary code metered and sandboxed access to the Stellar Network data.\",\"image\":\"/static/images/twitter-card.png\",\"url\":\"https://blog.xycloo.com/blog/introducing-zephyr\",\"author\":[{\"@type\":\"Person\",\"name\":\"Tommaso\"}]}"}}],["$","section",null,{"className":"mx-auto max-w-3xl px-4 sm:px-6 xl:max-w-5xl xl:px-0","children":[["$","$L11",null,{}],["$","article",null,{"children":["$","div",null,{"className":"xl:divide-y xl:divide-gray-200 xl:dark:divide-gray-700","children":[["$","header",null,{"className":"pt-6 xl:pb-6","children":["$","div",null,{"className":"space-y-1 text-center","children":[["$","dl",null,{"className":"space-y-10","children":["$","div",null,{"children":[["$","dt",null,{"className":"sr-only","children":"Published on"}],["$","dd",null,{"className":"text-base font-medium leading-6 text-gray-500 dark:text-gray-400","children":["$","time",null,{"dateTime":"2023-10-02T00:00:00.000Z","children":"Monday, October 2, 2023"}]}]]}]}],["$","div",null,{"children":["$","h1",null,{"className":"text-3xl font-extrabold leading-9 tracking-tight text-gray-900 dark:text-gray-100 sm:text-4xl sm:leading-10 md:text-5xl md:leading-14","children":"The Zephyr VM: core of the Mercury code execution environment."}]}]]}]}],["$","div",null,{"className":"grid-rows-[auto_1fr] divide-y divide-gray-200 pb-8 dark:divide-gray-700 xl:grid xl:grid-cols-4 xl:gap-x-6 xl:divide-y-0","children":[["$","dl",null,{"className":"pb-10 pt-6 xl:border-b xl:border-gray-200 xl:pt-11 xl:dark:border-gray-700","children":[["$","dt",null,{"className":"sr-only","children":"Authors"}],["$","dd",null,{"children":["$","ul",null,{"className":"flex flex-wrap justify-center gap-4 sm:space-x-12 xl:block xl:space-x-0 xl:space-y-8","children":[["$","li","Tommaso",{"className":"flex items-center space-x-2","children":["$undefined",["$","dl",null,{"className":"whitespace-nowrap text-sm font-medium leading-5","children":[["$","dt",null,{"className":"sr-only","children":"Name"}],["$","dd",null,{"className":"text-gray-900 dark:text-gray-100","children":"Tommaso"}],["$","dt",null,{"className":"sr-only","children":"Twitter"}],["$","dd",null,{"children":["$","a",null,{"target":"_blank","rel":"noopener noreferrer","href":"https://twitter.com/heytdep","className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","children":"@heytdep"}]}]]}]]}]]}]}]]}],["$","div",null,{"className":"divide-y divide-gray-200 dark:divide-gray-700 xl:col-span-3 xl:row-span-2 xl:pb-0","children":[["$","div",null,{"className":"prose max-w-none pb-8 pt-10 dark:prose-invert","children":[["$","img",null,{"src":"../static/images/zephyr_vm.png"}],["$","h1",null,{"id":"introduction","children":[["$","a",null,{"href":"#introduction","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Introduction"]}],["$","p",null,{"children":["If you've taken a deep look at ",["$","a",null,{"target":"_blank","rel":"noopener noreferrer","href":"https://mercurydata.app/","children":"Mercury"}]," and its proposal document, or followed our Stellar Stage pitch, you'll already know that we plan on Mercury having a so-called \"code execution environment\"."]}],["$","p",null,{"children":"But let's take it a small step back for those who are new here."}],["$","p",null,{"children":"Mercury is the data indexer we're actively building thanks to the Stellar Community Fund. Without going off-topic and getting into a more detailed explanation, Mercury is a centralized service that allows users to subscribe to and index Stellar/Soroban data cheaply and efficiently."}],["$","p",null,{"children":"One of the pillars of Mercury is simplicity and as little setup as possible/no setup. In fact, as of now our ingestor only writes to our database and Mercury can't run on anywhere that is not our server. Don't get us wrong, we love open source (in fact, crates we are writing on which Mercury relies are open source and implementation-agnostic) but it's also essential to have alternatives that don't require setting up an infrastructure. Also, indexed data is verifiable through Stellar Archives and thus one can easily conduct audits on the integrity of our data."}],["$","h2",null,{"id":"a-code-execution-environment--on-an-indexer","children":[["$","a",null,{"href":"#a-code-execution-environment--on-an-indexer","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"A code execution environment ... on an indexer?"]}],["$","blockquote",null,{"children":["$","p",null,{"children":"So, why are we talking about a code execution environment for Mercury?"}]}],["$","p",null,{"children":["The answer is that ",["$","strong",null,{"children":"we aim to empower users with cloud execution that operates in symbiosis with the Stellar network and can interact with the Mercury database locally"}],"."]}],["$","p",null,{"children":"This means that when Mercury's code execution environment goes live you'll be able to deploy to cloud small applications that run for every new ledger close with access to the whole ledger metadata. These programs are also able to read and write Mercury's database safely."}],["$","p",null,{"children":"Now that you have a bit more context, let's dive a bit deeper into this concept, how it works, and what use cases it has."}],["$","hr",null,{}],["$","h1",null,{"id":"the-zephyr-vm","children":[["$","a",null,{"href":"#the-zephyr-vm","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"The Zephyr VM"]}],["$","p",null,{"children":["At ",["$","a",null,{"target":"_blank","rel":"noopener noreferrer","href":"https://xycloo.com/","children":"xyclooLabs"}]," we just recently started developing Zephyr, hence the choice of writing and publishing this post now instead of a month ago: we now have a clear direction to go towards and development is going pretty fast."]}],["$","p",null,{"children":"Anyways, the Zephyr VM is being built on top of WebAssembly (WASM)."}],["$","p",null,{"children":"The Zephyr Virtual Machine executes WASM modules and provides them with bindings for accessing the Network's data held in Mercury's database and the ledgers meta. The choice of using WebAssembly is due to several factors:"}],["$","ul",null,{"children":[["$","li",null,{"children":[["$","strong",null,{"children":"Development"}],". Building on WebAssembly allows us to rely on a thriving ecosystem with a proven efficient and safe execution."]}],["$","li",null,{"children":[["$","strong",null,{"children":"Safety"}],". Developing on Rust, and executing programs in a WebAssembly Virtual Machine allows us to run the programs in a safe environment for both users and our infrastructure."]}],["$","li",null,{"children":[["$","strong",null,{"children":"Efficiency and Metering"}],". Programs running on Zephyr will be very simple, even simpler than a smart contract. WebAssembly's design and its ergonomic host environment integration with the guest environment seem like a perfect match. Additionally, a WebAssembly environment offers extensive possibilities in terms of metering each execution, which fits perfectly a use case like Zephyr, or more broadly speaking Mercury, where users pay exactly for what they consume."]}]]}],["$","p",null,{"children":"Now, why would someone want to run programs on Zephyr? What possibilities does it introduce in Mercury?"}],["$","h2",null,{"id":"why-mercury--zephyr","children":[["$","a",null,{"href":"#why-mercury--zephyr","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Why Mercury + Zephyr"]}],["$","p",null,{"children":"We believe that Zephyr's integration in Mercury can create lots of value for the ecosystem. Mercury allows anyone to build specialized services that rely on the network's data without needing any form of setup or infrastructure. It will also generally be cheaper for the implementors to run their programs on Mercury rather than running their own instance!"}],["$","p",null,{"children":"These programs can be anything ranging from protocol-centered services (for example a team monitoring their DeFi protocol) to user-centered services (like advanced alerts for traders)."}],["$","p",null,{"children":"We came up with some example applications for the Mercury + Zephyr integration:"}],["$","ul",null,{"children":[["$","li",null,{"children":["$","p",null,{"children":[["$","strong",null,{"children":"Advanced alert systems"}],". Traders and arbitrageurs often need to be synced with the Network's activity and keep track of many assets at the same time, their liquidity, frequency of certain actions in a ",["$","span",null,{"className":"math math-inline","children":["$","span",null,{"className":"katex","children":[["$","span",null,{"className":"katex-mathml","children":["$","math",null,{"xmlns":"http://www.w3.org/1998/Math/MathML","children":["$","semantics",null,{"children":[["$","mrow",null,{"children":[["$","mi",null,{"mathvariant":"normal","children":"Δ"}],["$","mi",null,{"children":"t"}]]}],["$","annotation",null,{"encoding":"application/x-tex","children":"\\Delta t"}]]}]}]}],["$","span",null,{"className":"katex-html","aria-hidden":"true","children":["$","span",null,{"className":"base","children":[["$","span",null,{"className":"strut","style":{"height":".6833em"}}],["$","span",null,{"className":"mord","children":"Δ"}],["$","span",null,{"className":"mord mathnormal","children":"t"}]]}]}]]}]}]," interval, and so on. Zephyr allows to communicate with the external world through particular host functions, empowering traders and arbitrageurs to build highly customized alert and trading strategies on top of Mercury + Zephyr without having to step into the challenges of managing a database and running an instance."]}]}],["$","li",null,{"children":["$","p",null,{"children":[["$","strong",null,{"children":"Trackers"}],". Sometimes, we need to be able to track exactly where some funds are being held and where they're being moved (and track the funds on the other ). Zephyr makes this kind of watcher services easy to create and efficient to run."]}]}],["$","li",null,{"children":["$","p",null,{"children":[["$","strong",null,{"children":"Multi-step workflows"}],". This also in some way encompasses most applications of Zephyr, but it's worth mentioning as its own utility category. Zephyr enables users to create workflows where each step depends on the result of the previous one, facilitating complex processes."]}]}],["$","li",null,{"children":["$","p",null,{"children":[["$","strong",null,{"children":"Highly customized indexing"}],". Some users might require very specific querying capabilities/database structures that wouldn't make sense to have in the default database structure. In such cases, Zephyr allows them to write their own ingestion mechanisms. We are also evaluating how feasible the implementation of custom queries is."]}]}],["$","li",null,{"children":["$","p",null,{"children":[["$","strong",null,{"children":"User-defined data aggregations"}],". Through Zephyr, users can define personalized aggregation functions and calculations for their unique requirements. For example, a Zephyr program could track on a per-ledger basis which are the best swap paths across various pools and protocols (both Soroban and Stellar Classic!)."]}]}],["$","li",null,{"children":["$","p",null,{"children":[["$","strong",null,{"children":"On-the-fly subscriptions"}],". We plan to also support a mechanism where Zephyr can dynamically create subscriptions for the user for certain data. For example, this might be critical in cases where the implementor wants to track all contracts with a specific code, and then monitor for deployments of those contracts and dynamically create/modify their Mercury subscriptions to also store and index data for these contracts."]}]}],["$","li",null,{"children":["$","p",null,{"children":[["$","strong",null,{"children":"Custom data retention policies"}],". In Mercury, users pay for the amount of data they use, Zephyr empowers users to discard stored and indexed data following custom policies to cut costs in the long run."]}]}],["$","li",null,{"children":["$","p",null,{"children":[["$","strong",null,{"children":"Protocol health checks"}],". Part of maintaining a protocol (and sometimes even auditing one) is to monitor that the protocol is working exactly as expected. Even if blockchain is built on determinism and Soroban has some pretty sick testing capabilities, monitoring that contracts are working as expected is important, especially for complex protocols that might also have actions that are bound but happen in different ledgers. Mercury + Zephyr stands as an easy-to-spin-up way to deploy this kind of watcher program."]}]}]]}],["$","p",null,{"children":["$","em",null,{"children":[["$","strong",null,{"children":"Note"}],": Depending on the implementor's logic, some of these applications may also require a very simple callback backend."]}]}],["$","p",null,{"children":"These are the major use cases we've thought of for now, but the possibilities are endless given the very nature of the host environment."}],["$","p",null,{"children":"Also, to tackle the scalability and costs of running the programs for every ledger, we're exploring implementations of conditional triggering. For instance, say your Zephyr program is only pertinent when a specific contract is invoked, or when a certain operation is performed, you can specify such conditions to Mercury, which will execute the program if these are met."}],["$","p",null,{"children":"This will prevent your code from being run for every ledger close, scaling better on our end, and saving costs on the user's end."}],["$","hr",null,{}],["$","h1",null,{"id":"implementation","children":[["$","a",null,{"href":"#implementation","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Implementation"]}],["$","p",null,{"children":"In the following weeks, we aim to release more content around the implementation itself. The implementation itself is nontrivial but neither too complex, the challenges arise when dealing with execution metering, constraints, and efficient memory management and sharing. But as this is targeted to be a post that introduces the ecosystem to Mercury + Zephyr, we want to focus more on how we imagine the implementation would work client-side, i.e. how we are imagining users writing programs for Zephyr."}],["$","h2",null,{"id":"sdks","children":[["$","a",null,{"href":"#sdks","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"SDKs"]}],["$","p",null,{"children":"To write Zephyr-compatible programs in an ergonomic way we're committed to building SDKs that facilitate communicating with the host environment. The first SDK will surely be for Rust, but we would like to build SDKs also for other languages (our second favorite choice is Zig, but it would likely mean having to spend resources to work with XDR efficiently in a language that doesn't have a stellar XDR library yet)."}],["$","p",null,{"children":"Anyways, this is how we envision the first SDK release candidate might look like:"}],["$","p",null,{"children":[["$","em",null,{"children":[["$","strong",null,{"children":"Note"}],": Please note that our SDK implementation is currently almost non-existent, for the stage we are in development we're mostly writing WAT code. Thus, the actual SDK implementation will likely be very different from the example we're showing here"]}],"."]}],["$","$L12",null,{"className":"language-rust","children":["$","code",null,{"className":"language-rust code-highlight","children":[["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"use"}]," ",["$","span",null,{"className":"token namespace","children":["zephyr_sdk",["$","span",null,{"className":"token punctuation","children":"::"}]]}],["$","span",null,{"className":"token punctuation","children":"{"}],["$","span",null,{"className":"token class-name","children":"Database"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token class-name","children":"EnvClient"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token class-name","children":"FilterInstrs"}],["$","span",null,{"className":"token punctuation","children":","}]," xdr",["$","span",null,{"className":"token punctuation","children":"}"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token keyword","children":"pub"}]," ",["$","span",null,{"className":"token keyword","children":"fn"}]," ",["$","span",null,{"className":"token function function-definition","children":"on_close"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token punctuation","children":")"}]," ",["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"let"}]," env ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token class-name","children":"EnvClient"}],["$","span",null,{"className":"token punctuation","children":"::"}],["$","span",null,{"className":"token function","children":"new"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"let"}]," db ",["$","span",null,{"className":"token operator","children":"="}]," ",["$","span",null,{"className":"token class-name","children":"Database"}],["$","span",null,{"className":"token punctuation","children":"::"}],["$","span",null,{"className":"token function","children":"new"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token operator","children":"&"}],"env",["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"let"}]," tx_processing ",["$","span",null,{"className":"token operator","children":"="}]," env",["$","span",null,{"className":"token punctuation","children":"."}],["$","span",null,{"className":"token function","children":"get_close"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":"."}],["$","span",null,{"className":"token function","children":"tx_processing"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"for"}]," tx_meta ",["$","span",null,{"className":"token keyword","children":"in"}]," tx_processing ",["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"// ... do some stuff"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"if"}]," certain_condition ",["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":" \n"}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"// read from Mercury's database by structuring a query:"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"// - read point (in Mercury, so SQL, the table name)."}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"// - what to read (in Mercury, so SQL, the columns to read)."}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"// - filtering."}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"let"}]," rows ",["$","span",null,{"className":"token operator","children":"="}]," db",["$","span",null,{"className":"token punctuation","children":"."}],["$","span",null,{"className":"token function","children":"read"}],["$","span",null,{"className":"token punctuation","children":"("}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token string","children":"\"table_name\""}],["$","span",null,{"className":"token punctuation","children":","}]," \n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token operator","children":"&"}],["$","span",null,{"className":"token punctuation","children":"["}],["$","span",null,{"className":"token string","children":"\"column1\""}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token string","children":"\"column2\""}],["$","span",null,{"className":"token punctuation","children":"]"}],["$","span",null,{"className":"token punctuation","children":","}]," \n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token class-name","children":"Some"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token operator","children":"&"}],["$","span",null,{"className":"token punctuation","children":"["}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token class-name","children":"FilterInstrs"}],["$","span",null,{"className":"token punctuation","children":"::"}],["$","span",null,{"className":"token class-name","children":"Symbol"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token string","children":"\"column1\""}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":","}]," \n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token class-name","children":"FilterInstrs"}],["$","span",null,{"className":"token punctuation","children":"::"}],["$","span",null,{"className":"token class-name","children":"Gt"}],["$","span",null,{"className":"token punctuation","children":","}]," \n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token class-name","children":"FilterInstrs"}],["$","span",null,{"className":"token punctuation","children":"::"}],["$","span",null,{"className":"token class-name","children":"Int"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token number","children":"5000"}],["$","span",null,{"className":"token punctuation","children":")"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"]"}],["$","span",null,{"className":"token punctuation","children":")"}]," ",["$","span",null,{"className":"token comment","children":"// The following option adds a filter so that values in"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"// `column1` > 5000. "}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"// the above query in Mercury's Zephyr implementation effectively resolves"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"// to [`SELECT column1, column2 FROM table_name WHERE column1 > 5000`]"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token keyword","children":"if"}]," other_condition ",["$","span",null,{"className":"token punctuation","children":"{"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token comment","children":"// write to user's private table hash(table_name + user id)."}],"\n"]}],["$","span",null,{"className":"code-line","children":[" db",["$","span",null,{"className":"token punctuation","children":"."}],["$","span",null,{"className":"token function","children":"write_priv"}],["$","span",null,{"className":"token punctuation","children":"("}],["$","span",null,{"className":"token string","children":"\"table_name\""}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token operator","children":"&"}],["$","span",null,{"className":"token punctuation","children":"["}],["$","span",null,{"className":"token string","children":"\"column1\""}],["$","span",null,{"className":"token punctuation","children":"]"}],["$","span",null,{"className":"token punctuation","children":","}]," ",["$","span",null,{"className":"token operator","children":"&"}],["$","span",null,{"className":"token punctuation","children":"["}],["$","span",null,{"className":"token number","children":"200"}],["$","span",null,{"className":"token punctuation","children":"]"}],["$","span",null,{"className":"token punctuation","children":")"}],["$","span",null,{"className":"token punctuation","children":";"}],"\n"]}],["$","span",null,{"className":"code-line","children":[" ",["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":[["$","span",null,{"className":"token punctuation","children":"}"}],"\n"]}],["$","span",null,{"className":"code-line","children":"\n"}]]}]}],["$","h2",null,{"id":"is-zephyr-open-source-implementation-agnostic","children":[["$","a",null,{"href":"#is-zephyr-open-source-implementation-agnostic","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Is Zephyr Open Source? Implementation agnostic?"]}],["$","p",null,{"children":"Some of you might be wondering whether Zephyr will be open-source or not. On this point, there are a couple of considerations."}],["$","p",null,{"children":"First of all, Zephyr is being built implementation-agnostic. This means that while built for being integrated into Mercury, it doesn't care if it's Mercury implementing the host: as long as the implementation-specific traits are implemented, Zephyr can run anywhere."}],["$","p",null,{"children":"We can't make any promises since there are still some considerations to be done on this topic, but Zephyr will likely be open source. However, for now, given the stage we are in development, the codebase remains private."}],["$","hr",null,{}],["$","h1",null,{"id":"conclusion","children":[["$","a",null,{"href":"#conclusion","aria-hidden":"true","tabIndex":"-1","children":["$","span",null,{"className":"icon icon-link"}]}],"Conclusion"]}],["$","p",null,{"children":"We're quite excited to see what Zephyr is capable of when integrated on Mercury. We plan for the second beta release candidate to implement the first (maybe not feature-complete yet) version of Mercury + Zephyr, so stay tuned!."}],["$","p",null,{"children":["Also, this is our first blog post, so welcome to the ",["$","a",null,{"target":"_blank","rel":"noopener noreferrer","href":"https://xycloo.com/","children":"xyclooLabs"}]," blog, and thanks for reading!"]}]]}],["$","div",null,{"className":"pb-6 pt-6 text-center text-gray-700 dark:text-gray-300","id":"comment","children":["$","$L13",null,{"slug":"introducing-zephyr"}]}]]}],["$","footer",null,{"children":[["$","div",null,{"className":"divide-gray-200 text-sm font-medium leading-5 dark:divide-gray-700 xl:col-start-1 xl:row-start-2 xl:divide-y","children":[["$","div",null,{"className":"py-4 xl:py-8","children":[["$","h2",null,{"className":"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400","children":"Tags"}],["$","div",null,{"className":"flex flex-wrap","children":[["$","$L9",null,{"href":"/tags/mercury","className":"mr-3 text-sm font-medium uppercase text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","children":"Mercury"}],["$","$L9",null,{"href":"/tags/zephyr","className":"mr-3 text-sm font-medium uppercase text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","children":"Zephyr"}],["$","$L9",null,{"href":"/tags/webassembly","className":"mr-3 text-sm font-medium uppercase text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","children":"WebAssembly"}],["$","$L9",null,{"href":"/tags/stellar","className":"mr-3 text-sm font-medium uppercase text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","children":"Stellar"}],["$","$L9",null,{"href":"/tags/soroban","className":"mr-3 text-sm font-medium uppercase text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","children":"Soroban"}]]}]]}],["$","div",null,{"className":"flex justify-between py-4 xl:block xl:space-y-8 xl:py-8","children":["$undefined",["$","div",null,{"children":[["$","h2",null,{"className":"text-xs uppercase tracking-wide text-gray-500 dark:text-gray-400","children":"Next Article"}],["$","div",null,{"className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","children":["$","$L9",null,{"href":"/blog/zephyr-pre-alpha-preview","children":"Writing the First Zephyr Program: Zephyr VM + Mercury Integration Preview."}]}]]}]]}]]}],["$","div",null,{"className":"pt-4 xl:pt-8","children":["$","$L9",null,{"href":"/blog","className":"text-primary-500 hover:text-primary-600 dark:hover:text-primary-400","aria-label":"Back to the blog","children":"← Back to the blog"}]}]]}]]}]]}]}]]}]] f:null