Soy is the Secret Sauce for the Unstoppable Web

And it’s how ConsenSys Web3Studio is hosting its new site

Photo by Agto Nugroho on Unsplash

Hosting a static website is easy. There are tons of ways to do it — plenty of tools, scripts, api’s. Serving web pages isn’t new.

Late last year, we were sitting around contemplating what the holidays would bring when we said, “Hey, wait a minute! The world needs a new way to serve static web pages!”

That’s exactly what we said. No…not really.

What we really said is that it would be cool to try building a service that uses Ethereum smart contracts and ENS to translate human-readable stuff you type into a browser into IPFS locations (hashes), go pull the data at those locations, and serve it back up — hey, Presto — into the user’s browser.

And we also said it would be especially cool if we did this in a way that could help our sad and lonely devops guru, Michael, with stuff like A-B testing by using the service to apply rules via smart contract to that translation. For example:

if (random() > 0.75) {
return experiment1Hash;
} else {
return experiment2Hash;
}

Who Cares?

Really? Who cares? You’re asking who cares? Outrageous. :)

Ok…we asked the same thing. And at first, the answer was, “We should do it because…reasons.”

But then we realized we had stumbled onto something. Notably, that these pages we are serving — like our own Web3Studio site — have been rendered “unstoppable.

Why Unstoppable? Okay, Okay, Okay…you could probably stop it right now…early days and all…but the following should be very powerful in the fullness of time:

  1. None of the following things can easily bring the site down: DOS attack, Meteor-strike, Aliens.
  2. Because IPFS can act like a CDN, the data sits closer and closer to you the more it’s hit — which can mean better performance. [caveat…this assumes a mature IPFS world…but we live in the future, so we’re all good.]
  3. The page is more secure, because the content location is a hash of the content itself (IPFS is magic) — meaning nobody tampered with it at rest. So as long as the person who wrote the page wasn’t Dr. Evil, you’re good. [caveat…You still need TLS, duh, but as you know, that doesn’t cover tampering on server.]

Cache invalidation is one of the hard problems in CS. With Soy, you can deploy new versions all the time, and keeping every version available and reference-able makes caches easier to manage.

The pattern also makes it straightforward to do things like time traveling: what did the site look like at a specific date or what will it look like in the future?

Community Call

It’s not like we’re the only ones to ever make an IPFS/ENS “webserver”. Eth.show, Metamask, and a bunch of other chrome extensions do it just fine. What we provide on the Web3Studio Github Repo is one way — albeit a super awesomely nice, totally open source way that works for IPFS rather than Swarm — of not having to use an extension for the purpose.

The whole reason for our team is to provide open source (Apache2) code, designs, and stories to help more people make more things. So, we set up the Github repository as a way to say, “Fork Me!” [Um…that doesn’t sound right…maybe something more welcoming? How about: “Join our merry band of contributors and maintainers! #meritocracy.”]

What’s in the Box?

Soy consists of 3 parts:

  • An ENS resolver. Think of this like DNS, but it’s Turing complete because it’s a smart contract. The record resolves to a contenthash (an IPFS location) given a set of inputs, the name (obviously) as well as any other variables programmed into the contract or any other input provided by Ethereum like the date, block-height, or "randomness". This gives us the ability to do things like blue/green deploys, a/b testing, slow rollouts, time-traveling, and dark launches.
  • A node library to interact with the contract. Web3js is still a pain, unit conversion is a pain, writing scripts that you copy everywhere is a drag. Common actions are put here and are easily run in CI/CD environments.
  • A gateway. This is a shim until browsers support distributed file systems natively. The gateway rewrites requests from the browser to a specific content hash.

What Soy Isn’t Good At

At least for now, the Soy pattern is a choice against some essential features needed by many sites:

  1. Can’t handle dynamically rendered pages. Soy can let you create routing logic via a custom smart contract, but if you need to do more than route between different static pages, Soy won’t work for that. (Until you chip in and help us figure out to do it!)
  2. Can’t handle private content. Because the pages Soy serves up are on IPFS, it’s all out there for anyone in the public to query.
  3. Can’t really handle forms, though you are probably using an api server for that anyway.

The Near Future

Whether it’s Soy or some other variant of the pattern, sooner or later the unstoppable web is going to be a thing. Edge computing is coming. Cloud, mobile and broadband companies are getting into the act.

Your content is coming to a device near you.

Or we should say, to many devices near you…the more you and people near you call up the same content.

Distribution allows devs to focus on the content and the user rather than their infrastructure. Setting up a global cache, CDN, and web server in today’s world is a pain. It can take a while, and it can fail in complex ways. Using the Ethereum world computer for what it’s good for keeps you focused on more important things.

In the world of the near future, there are IPFS nodes everywhere. They’re in everyone’s browser, they’re run by ISPs next to large population centers, and they’re run in every home router. As content gets accessed it stays and moves closer and closer to users. When content is requested, it moves from peer to peer, always keeping users next to their content. Distribution is easy because everything is hash addressable. Updating it is as easy as updating a contract. After that, the world computer handles propagation.

We now have a world where we don’t copy the same jquery file on thousands of origin servers. The content lives where people are using it.

Big Things Start Small

The more of us that use and contribute to patterns like Soy, the faster and smarter our friends building browsers and managing internet standards will be in supporting it and making it easy for users to find and access content on the unstoppable web.

So, hop on the GitHub Repo. Fork, pull, commit, help and lead: https://github.com/ConsenSys/web3studio-soy


This story is not fiction…we built it. But you can help make it even more real by getting involved in the development community on GitHub.

Web3Studio is a ConsenSys team that conceives and builds novel, innovative uses of blockchain and related technologies, so that the Ethereum and Web3 ecosystem can expand its horizons and build valuable ventures faster.