What is Facet?

Introducing an Ethereum Paradigm Shift

Tom Lehman (middlemarch.eth)
12 min readDec 8, 2023

The Facet Protocol is LIVE on mainnet! Try it at Facet Swap, Facet Scan, and Facet Cards. Read on to learn how it works!

What is Facet?

Facet is a secure, decentralized, and affordable computation protocol.

Facet is not a blockchain. Instead it is a different way of thinking about and using blockchains. Think of Facet as a new lens through which you can view and interact with Ethereum.

And just by changing our perspective, it turns out that we can reduce Ethereum transaction costs by up to 99% without changing the Ethereum protocol itself.

Just as viewing the same gemstone from different angles reveals its stunning “facets,” changing how you look at Ethereum will reveal its untapped potential.

Facet Makes Ethereum (A LOT) Cheaper

Let’s look at the savings in two example transactions comparing Facet Swap, a DEX built on Facet, with a traditional Ethereum UniswapV2 DEX.

Swapping tokens on a DEX, with and without Facet

Swapping Tokens: Compare this token swap from Sushi Swap with this one on Facet Swap. The Facet version accomplishes the same thing, but costs $3.41 in gas instead of $24.61. That’s a savings of over 85%!

Creating a DEX liquidity pool, with and without Facet

Creating a UniswapV2 Pair: When it comes to a complicated operation like creating a new pair, the difference is even more pronounced. What costs you $316.55 the traditional way, Facet trims down to a mere $3.09. That’s a reduction of more than 99%!

What’s the Catch?

Facet can reduce gas costs by 99%? What’s the catch?! There’s no such thing as “free money”!

You’re right—Facet can’t create free money. But it can create “free stop wasting money.”

Specifically, Facet enables you to stop wasting money on an unnecessary and costly feature of Ethereum: smart contracts.

Reevaluating Ethereum’s Core Feature: Smart Contracts

Facet’s thesis is simple: everything that can be accomplished with smart contracts on Ethereum can be done more efficiently without them. Smart contracts are traditionally celebrated as Ethereum’s key innovation, but in reality they hold Ethereum back.

The idea that smart contracts are a design flaw in Ethereum is at first glance so unbelievable you might think it’s a joke. But imagine if it were true—if you didn’t need smart contracts to use Ethereum.

It would mean billions of dollars in gas fees over the years have been wasted. It would mean that Ethereum’s overall capacity (enforced by the 30M gas limit) has been artificially constrained. But most importantly, it would mean there is still time to adjust and use Ethereum in a better way.

Though Facet’s thesis seems counter-intuitive, if approached with an open mind, its truth is quite easy to see.

A Thought Experiment: What if Smart Contract Storage Got Deleted?

To understand whether smart contracts are an essential feature of Ethereum or whether we can do without them, let’s use the It’s a Wonderful Life strategy and imagine what life would be like if all smart contracts suddenly disappeared.

Consider this scenario: the Ethereum community wakes up tomorrow to learn that smart contract storage has been erased but the history of Ethereum transactions and Ethereum’s consensus layer remained.

How bad would this be?

If smart contracts are essential, this must be a disaster. The Ethereum community spent billions of dollars in gas paying for smart contracts to perform calculations and store the results. Surely losing all of this data would be a loss of billions of dollars as well, right? Otherwise, why did we spend so much money populating it in the first place?

Recovering Smart Contract State

At the same time, losing the data can only be as bad as it costs to recover it. If populating the data cost billions of dollars, and those dollars were well-spent, then recovering this deleted data must also cost billions of dollars. Why?

Right: because if you could recover the lost data for substantially less than you spent generating it, you wouldn’t generate it in the first place! You would just skip straight to “recovering” it.

How much then would it cost to recover all lost smart contract data? A billion dollars? Ten billion dollars? The surprising answer is: almost nothing.

Why? Because all data within smart contracts can be reconstructed with perfect fidelity from the immutable history of Ethereum transactions. Every piece of information within these contracts originated from this transaction history, and to recreate this information we just need to “replay” the history.

But wouldn’t replaying this history mean re-running the various expensive smart contract interactions that happened the first time? No, because we don’t need smart contracts to execute smart contract logic. This is because smart contract logic is entirely deterministic—a smart contract will always produce the same output for a given input.

And smart contract logic itself is contained in the same history of Ethereum transactions in the calldata of contract deployments.

Given we have the history of Ethereum transactions as inputs and we have all smart contract logic as well, we can exactly reproduce smart contract outputs by executing smart contract logic on the same inputs. By repeated application of this procedure, we can restore all data lost in this thought experiment.

The Paradox of Smart Contracts

Looked at from this perspective, smart contracts are bizarre entities. We pay billions for them to perform calculations, and at the same time if the results of these calculations were erased we could regenerate them for a fraction of the cost.

It sounds almost like a riddle: “You pay me billions to tell you things you already know. What am I?”

An Ethereum smart contract!

Facet’s view is that this is not a challenging philosophical conundrum, but rather a simple opportunity to switch to a cheaper option and save money.

What is Ethereum’s “Essence”?

If we have collectively spent billions maintaining a store of data that contains no unique information, how has Ethereum achieved so many amazing things?

If smart contracts aren’t the “essence of Ethereum,” then what is? As we have seen above, everything in Ethereum stems from the ordered sequence of Ethereum transactions produced by the Ethereum validators.

If you have this sequence, you can calculate any deterministic results you need without a blockchain. Conversely, if you do not have this sequence, you will never be able to recreate it without a blockchain.

Unlike smart contract behavior, the sequence of Ethereum transactions is non-deterministic. When it comes to determining which transactions are in a given block and in what order, there’s no way to use initial conditions and shared logic to agree on the “right answer.” In fact there is no “right answer”—the same initial conditions can result in multiple equally-valid outcomes.

This is the magic of the Proof of Stake consensus mechanism. It enables everyone to agree on the outcome of a non-deterministic process without centralizing decision-making power.

That Proof of Stake works at all is almost unbelievable. We shouldn’t further burden Ethereum Validators with the responsibility of performing simple math problems—for example by determining that if you own 2 tokens and you mint 2 more, your balance is now 4. We don’t need a blockchain to tell us 2 + 2 = 4!

Facet’s savings are achieved by asking the Ethereum validators to do the one thing only they can do: sequence Ethereum transactions. Everything else can be computed off-chain.

How Facet Works

Facet isn’t just a theoretical concept; it’s a fully functional system currently operating on Ethereum’s mainnet.

The Facet Protocol is implemented by the open-source Facet Virtual Machine (FVM):

Here’s how it works.

The Basic Idea

Recall our earlier discussion on reconstructing smart contract storage using Ethereum’s transaction history. The Facet Virutal Machine operates on this principle, but with a twist: instead of reconstructing deleted smart contract state, it assembles a state that was never stored in smart contracts to begin with!

An Example

Let’s look at a simple example: minting an ERC20 token using Facet. Consider this transaction. First, notice the transaction’s “To” address is 0x00000000000000000000000000000000000FacE7, a vanity burn address (not a smart contract).

Next, take a look at the input data:

data:application/vnd.facet.tx+json;rule=esip6,{
"op": "call",
"data": {
"to": "0x0fa4d1eea940b2c82019f4d048e887715f5eb703",
"function": "mint",
"args": {
"amount": "100000000000000000000000000000000000000000000000000000"
}
}
}

If you aren’t using Facet, this transaction payload is meaningless. However, if you adjust your perspective, you can see it’s quite meaningful: this person is expressing their intent to mint some amount of tokens from a specific “contract address” (in the “to” field).

Next, the Facet Protocol combines the input of the user’s intention with the logic in that “contract address” and the history of previous Facet transactions to determine whether the user succeeded or failed. Here is the logic:

function :mint, { amount: :uint256 }, :public do
require(amount > 0, 'Amount must be positive')
require(amount <= s.perMintLimit, 'Exceeded mint limit')

require(s.totalSupply + amount <= s.maxSupply, 'Exceeded max supply')

_mint(to: msg.sender, amount: amount)
end

Ignore the details and the phrase “contract address” for the moment and try to get the basic gist. From the require statements it’s clear that to mint successfully:

  1. You must mint at least 1 token.
  2. You cannot mint more than the per-mint limit.
  3. Your mint can’t exceed the max supply.

(1) can easily be verified by looking the user’s transaction payload. For (2) and (3) you need to examine Facet’s transaction history.

The s. prefix on s.perMintLimit means it’s a storage variable. To determine its current value, you must look at the history of transactions and determine which last successfully updated the value. The same is true for validations against s.totalSupply and s.maxSupply.

Theoretically, these questions can be answered statelessly by querying historical Ethereum transactions. In practice, such queries are complicated and not performant. Plus, state is easier for developers. If you’re programming this token, you want to be able to say “give me the total supply,” not “sum the mint amounts from all previous valid mint transactions where ‘valid’ is defined by this other complicated query.”

The Facet VM enables developers to efficiently answer these kinds of questions using a familiar paradigm they know and love: the smart contract.

Introducing Dumb Contracts

“Smart contracts?! I thought we were abandoning smart contracts!” Facet doesn’t use smart contracts, but we have borrowed the smart contract paradigm for how to structure Facet applications.

To distinguish our contracts from the EVM’s, and to be cheeky, Facet contracts are called “Dumb Contracts.” But from a developer standpoint they work just like smart contracts—they are self-contained “containers” for logic and storage you can use to build apps and talk to other contracts.

Dumb Contracts are assigned unique Ethereum-style addresses when they are created. A contract’s address is computed deterministically and serves as the contract’s id. When users or other Dumb Contracts want to interact with a Dumb Contract they identify the contract by address and specify the function they want to call and the arguments they want to use.

Dumb Contracts are written in Rubidity, a Ruby-Solidity hybrid language we created. You can see all of this in the Facet VM repo:

Here is the full code of the Dumb Contract from the mint request we discussed earlier:

pragma :rubidity, "1.0.0"

import './ERC20.rubidity'

contract :PublicMintERC20, is: :ERC20 do
uint256 :public, :maxSupply
uint256 :public, :perMintLimit

constructor(
name: :string,
symbol: :string,
maxSupply: :uint256,
perMintLimit: :uint256,
decimals: :uint8
) {
ERC20.constructor(name: name, symbol: symbol, decimals: decimals)
s.maxSupply = maxSupply
s.perMintLimit = perMintLimit
}

function :mint, { amount: :uint256 }, :public do
require(amount > 0, 'Amount must be positive')
require(amount <= s.perMintLimit, 'Exceeded mint limit')

require(s.totalSupply + amount <= s.maxSupply, 'Exceeded max supply')

_mint(to: msg.sender, amount: amount)
end

function :airdrop, { to: :address, amount: :uint256 }, :public do
require(amount > 0, 'Amount must be positive')
require(amount <= s.perMintLimit, 'Exceeded mint limit')

require(s.totalSupply + amount <= s.maxSupply, 'Exceeded max supply')

_mint(to: to, amount: amount)
end
end

As with the EVM, we know this is the correct code by looking at the Ethereum transaction where the contract was deployed. All Dumb Contract code is also available on Facet Scan, though in its transpiled form.

Back to our example: our user wants to mint from this contract. What does the Facet VM do? Roughly speaking, it:

  1. Finds the correct Dumb Contract implementation logic.
  2. Instantiates a new Dumb Contract “object.”
  3. Loads the Dumb Contract’s latest state into the object.
  4. Executes the function the user called.
  5. Stores the resulting new contract state.

Are Dumb Contracts Decentralized?

I mention saving Dumb Contract state. Where does this state live? In the Facet VM, the state lives in a local Postgresql database. How can Dumb Contracts be decentralized if their state lives off-chain?

While Dumb Contracts feel “real” when you write and use them, in reality they are just a protocol for interpreting Ethereum calldata. They are merely a “way of seeing.”

As with smart contracts, Dumb Contract storage has no informational content. If all Dumb Contract storage was erased tomorrow, nothing of value would be lost. The Facet Protocol doesn’t rely on the independent existence of Dumb Contracts.

Facet relies only on transaction data stored on Ethereum. All Dumb Contract state is inferred from this transaction data using open source software.

And results computed from shared initial conditions using shared rules are decentralized. This is because you do not need to rely on anyone to compute these results for you, as you have the exact same knowledge and capabilities as anyone you’d want to ask.

And if you did happen to get results from a third party, you could verify that they were correct by simply repeating the calculations yourself.

Is Facet a Layer 2?

As Facet is merely a different way of using Ethereum, it is certainly not an L2, as L2s are separate chains.

On a deeper level, you can think of Facet as the antithesis of a Layer 2. L2s preserve smart contract functionality and achieve gas savings by not using a decentralized consensus mechanism.

For us, this is precisely the worst scaling strategy, as it doubles down on asking the blockchain to do things we don’t need it to do (perform computations and store data), and relieves the blockchain of the one task we cannot do without it (sequence transactions in a fair way).

One consequence of this is that using an L2 comes with a significant risk: will the L2 owner decide that operating the L2 no longer serves their interests and shuts it down?

Facet, by contrast, cannot be shut down by anyone.

What are Facet’s Limitations?

The first version of the Facet VM is not a full realization of the Facet vision. We launched it not because we feel that we have found the “right answer,” but because we feel we have found the right path and we want to build a community around getting to the destination.

One of the key limitations in the initial release of Facet is the restriction on deploying arbitrary Dumb Contract code. Currently, users must select from a community-approved list of supported and tested contracts. This limitation stems from a current gap in Rubidity — the absence of a gas-like mechanism for preventing infinite loops in contract execution.

Now before you say “A ha! The hidden catch is finally revealed! Facet can’t do everything smart contracts can do!” let me assure you: computing the gas cost of a function is just another deterministic calculation smart contracts perform using Ethereum’s transaction history as their input. An off-chain VM can do just as well as the EVM.

It’s still a challenging problem, however, which is why we didn’t want to hold up the V1 release until we solved it!

What’s Next?

In addition to improvements to the core protocol, we are aggressively building out Dumb Contracts for new use-cases. Our goal is to transition all popular Ethereum applications — from NFT marketplaces to lending protocols — onto the more efficient Facet Protocol.

The Facet VM and all Dumb Contracts are open source and we are accepting pull requests if you want to get involved!

The best way to learn about what we’re working on next is the Facet Discord, so consider joining that as well.

You can also find Facet on X at @0xFacet, as well as the Facet co-founders, Tom Lehman (@dumbnamenumbers) and Michael Hirsch (@0xHirsch).

The Facet Movement

If Facet’s thesis is correct, then Vitalik Buterin and other Ethereum pioneers missed an alternative, superior path for Ethereum’s development.

That Vitalik must be wrong for Facet to be right, is, for any rational person, strong evidence that Facet must fail. After all, what are the odds that Vitalik missed something this big about the system he created? And if Vitalik did miss something, wouldn’t he be the one to discover it?

However, when we zoom out and look at the history of scientific and technological breakthroughs, we see that revolutions often overthrow the establishment’s worldview and they are frequently led by outsiders. From this standpoint, Facet’s chances look better.

In the end, will Facet be the catalyst for a new era in blockchain technology? Much like the story of Ethereum itself, the answer may depend on how you choose to look at it.

--

--

Tom Lehman (middlemarch.eth)

Facet co-founder | Facet Discord: https://discord.gg/facet | Ethscriptions co-founder | @_capsule21 co-founder | http://Genius.com co-founder & former CEO