Serverless functions with Molecular Execution Machine
While it may be a solved problem in web2, web3 applications still need scalable and composable solutions to avoid taking a hit to UX and user retention. Often this leads to a Frankenstein combination of “smart contracts + custom middleware”.
This middleware is often deployed as serverless functions on centralized platforms like AWS Lambda. The serverless paradigm arose from the need for applications to be able to run functions in the cloud at any scale. Once deployed, serverless functions execute logic on-demand in a sandboxed environment, without burdening developers with DevOps, infra management or questions of scale. Sounds a bit smart contract-y? There are plenty of parallels. In this article, We take a look at MEM – a web3-ready serverless functions platform – and weigh up the tradeoffs.
Although serverless functions have revolutionized the way we build, deploy, and manage web2 software applications, MEM introduces a novel paradigm that enables dApp developers to achieve web2 scale and flexibility, without killing what makes web3 so valuable.
Let's explore serverless functions, web2 and blockchain applications and why MEM is the perfect bridge for it all.
What Are Serverless Functions?
Serverless functions are compact pieces of code that are designed to respond to events in a cloud-native environment. They are particularly advantageous for handling specialized tasks within applications, freeing developers from the burdens of traditional server maintenance, not to mention being far more cost-effective. These functions allow developers to streamline development processes, improve resource utilization, and rapidly respond to changing application requirements.
The Strengths
Using serverless functions offers a wide variety of advantages to not only the application, and its developers, but also the end user.
One of these advantages is that there is no need for server management, abstracting away the underlying infrastructure, meaning developers don't have to concern themselves with provisioning, maintaining or scaling servers. This can provide developers with the ability to focus primarily on writing code for specific functions or tasks.
Owners and developers also only pay for the server space that is actually used, which helps cut down on expenses.
When you deploy updates or new versions of your functions, the platform can switch traffic from an old version to a new version without causing downtime for the application's users, ensuring minimal effects on latency and the user experience, even during updates.
Serverless functions are well suited to CI/CD pipelines. Developers can automate the procedures of testing, constructing, and deploying serverless functions, guaranteeing the swift and dependable delivery of changes to production environments.
The Constraints
There are a few important things to consider when implementing serverless function architecture in your applications.
Replicating a serverless environment for testing and debugging can be difficult and cumbersome as developers lack insight into backend operations as the application is divided into distinct and smaller functions.
When it comes to tasks or processes that need to run continuously, or for a very long time, serverless architectures may not be the most appropriate choice. Serverless functions that rely on cloud providers are usually billed by execution time and have certain time limits imposed by the platform.
Security can become worrisome because when using cloud providers, they take care of everything behind the scenes, which can make it difficult to check how secure everything is. This becomes a concern, especially if your application deals with personal or sensitive info.
Add to all of that the potential risk of vendor lock-in. The service host might offer unique features or workflows, meaning your application is tightly integrated into that provider's ecosystem. One change, be it data formats, APIs or pricing, in the provider ecosystem can heavily affect the outcomes of your system.
Serverless Functions vs Smart Contracts
The web2 world of serverless functions is analogous to smart contracts in web3.
When building blockchain applications, smart contracts are usually one or more pieces of the architecture that power interactions and transactions. Smart contracts are used for their transparent, immutable and trustless design. They introduce a way of ensuring that agreements and transactions are automatically executed and enforced without the need for intermediaries or centralized entities.
In a perfect world, a smart contract is deployed to the chosen blockchain to execute exactly as programmed, providing security and predictability. However, there have been many instances where challenges and errors in development have led to an increase in exploits, gas prices and other vulnerabilities. This can heavily impact the end user, resulting in spending or losing large amounts of funds and other onchain assets.
MEM: Bridging the Gap
MEM is a web3-ready serverless functions platform that provides the freedom to build applications for any blockchain, using any programming language, while delivering a user experience similar to web2. MEM can be used in existing web2/web3 stack or used to develop and/or deploy a new application entirely. It is designed for building highly scalable applications using serverless functions and the use of blockchain technology for transparency. While being chain agnostic by design, it also removes the need for an in-depth understanding of smart contracts, transactions, wallets, or blocks.
The MEM protocol leverages the 3EM execution layer. MEM inherits various features from 3EM, including the broad language support for creating smart contracts. 3EM works by the implementation of a highly secure and modern runtime environment for assessing smart contracts - the V8 engine emulates a web browser, but on highly scalable hardware, playing into MEM’s SmartWeave roots and shifting the burden of computation from the end user to the MEM node.
Solving Limitations with MEM
Conventional serverless function platforms often operate as opaque systems, lacking mechanisms for external verification of the code's execution and the resulting state. In contrast, MEM introduces a paradigm shift where contracts and states are permanently recorded on the Arweave blockchain, ensuring transparency and facilitating trustless evaluation.
At the core of this transformation is the MEM orchestrator, a centrally hosted node that offers scalability similar to established serverless platforms like AWS Lambda. However, what sets it apart is the level of transparency it brings to the ecosystem. Unlike traditional serverless platforms, the MEM orchestrator operates with the transparency of a smart contract. This means that the execution of functions and their corresponding states is open and verifiable on the Arweave blockchain. This transparency not only enhances security but also reinforces the principle of trustlessness, where users can independently validate the outcomes of smart contracts, fostering a more reliable and accountable ecosystem.
For web2
Serverless functions are typically stateless, whereas MEM functions are stateful, to which read operations offer near-instant finality and instant finality for state changes in the execution's response.
Molecule, the foundational framework for MEM, shares the principle of Lazy Evaluation with the SmartWeave protocol. In MEM, every interaction with smart contracts gets transmitted to the Arweave network, which functions as the data availability (DA) layer for MEM. This architectural choice grants every user the ability to defer the evaluation of a MEM smart contract's state. This approach involves independently confirming the legitimacy of the state provided by MEM servers (cache). Through the use of lazy evaluation, users can autonomously validate the completeness and correctness of the contract state. This mechanism reinforces trust and transparency throughout the MEM ecosystem, also increasing the overall cost-efficiency of the architecture.
Using MEM can not only save developers time with its compatibility with any programming language but it also offers an API-like experience through its use of RESTful requests via deterministicFetch
. This capability expands MEM's functionality, enabling straightforward integration with external data sources and dynamic interactions within dApps. MEM prioritizes deterministic behavior in smart contract execution, enhancing reliability and consistency. MEM achieves this by employing techniques like random seeding and polling.
Add to this the ability to inherit blockchain features such as security through cryptography, immutability and permissionless transactions and interactions, all while eliminating the need for wallets and expensive cloud providers, MEM is a powerful and suitable addition to any applications stack.
For web3
As mentioned previously, MEM introduces stateful smart contracts. This responsiveness resolves common latency challenges faced by web3 applications. Additionally, users can independently verify the legitimacy of contract states, fostering transparency, trust, and cost-efficiency in web3 environments.
Traditionally, web3 applications often struggle with managing assets across diverse blockchain networks. MEM's cross-chain support enables asset transfers and management, ensuring efficient utilization of blockchain resources
Cost-efficient architecture is a necessity when building dApps as it reduces reliance on expensive cloud providers while upholding the security and functionality required for web3 applications. It substitutes the storage cost of Arweave with contract interactions, enabling gasless transactions, in turn removing any financial implications for users and encouraging wider adoption of applications built using MEM. This makes MEM well-suited for resource-conscious web3 projects. It also enhances user accessibility in the web3 ecosystem by introducing wallet-free functionality eliminating barriers for users who may not have wallets, fostering broader participation in dApps.
Combine this with the ability to write smart contracts in familiar languages and MEM's interoperability, scalability and simplified development environment and you can now begin to understand how MEM solves multiple issues we currently have with building useable functioning dApps.
Unlocking the Potential of MEM
MEM's ability to create a harmonious bridge between web2 and web3 technologies positions it as a powerful tool for crafting user-friendly hybrid applications.
Imagine a content-sharing platform. MEM ensures data ownership via blockchain transparency and the permanence of Arweave, while preserving the web2-style user experience we're familiar with. MEM gives you the ability to create censorship resistance, immutable and flexible applications that scale as you onboard more users.
Or picture an existing use case in Arweave Name Service (ANS), which aims to establish the Human Readable Address (HRA) protocol, enabling users to assign and access user-friendly names for addresses within the Arweave network. The beauty in this is that you are not at liberty of the service provider. You pay once and you own your ANS forever, incurring no additional fees should the protocol choose to increase the costs.
Conclusion
In our ever-evolving technological landscape, MEM serves as an innovation bridge, uniting the strengths of web2 and web3 technologies. It empowers developers to shape the future where user-friendly hybrid applications flourish, delivering a seamless and secure experience for both creators and users. With MEM, the possibilities are limitless, making it an essential tool for unlocking new horizons.
Sign up now for access to private beta at mem.tech.
Find our more about MEM via their docs.
To get a quick start with MEM smart contracts, be sure to check out this article which provides a basic introduction to using the MEM IDE, a playground for creating, testing and debugging smart contracts in a replicated MEM production environment.