shazow / shazow.net

https://shazow.net
27 stars 0 forks source link

procedural-smart-contract-dapps #46

Open shazow opened 1 year ago

shazow commented 1 year ago

Procedural Smart Contract Frontends: Future of Ethereum DApps

Imagine a procedural smart contract explorer good enough that most smart contracts don't need a custom frontend to use them.

No, I don't mean writing another Medium post with step-by-step screenshot instructions of how to use Etherscan's contract explorer.

Imagine something that is good enough to pass for a native interface, producing specialized widgets for common contract interfaces: Tokens, NFTs, Swap routers, DAOs, and even administrative like Roles/Ownable, and upgradeable Proxies.

Imagine a world where 80% of smart contracts don't bother building their own bespoke frontend, but rather encourage consumers to use procedural frontends.

What are some benefits of this world?

Local commodity frontends

Today, we regularly rely on app.uniswap.org to swap some tokens, or opensea.io to move some NFTs, or trustme.notscam.xyz to approve some permits.

What if we had an open source local frontend we could run that was more than good enough to do these common usecases?

It could be an IPFS-pinned immutable hash. It could be accessible through ENS or Tor. It could be packaged up as a simple webview container with WalletConnect. Even wallets could include an embedded version of it.

If we do a great job on it, the attack surface area could be made small and we could avoid updating it too often.

Safer against phishing attacks

Today, building a bespoke frontend for a contract means that we're training our consumers to trust some third-party website as an interface for the contract.

Anyone can make a website that claims to be a legitimate frontend for our contract, and trick our consumers to use a malicious frontend.

If we had a procedural frontend that we used for our contract interactions, then we reduce N (number of contracts we ever interact) interfaces and opportunities to get phished into just one instance.

Safer against censorship

Frontends are the main point of censorship that smart contracts experience, because almost all frontends today are provided as a SaaS (Software as a Service) where some corporation is responsible of how their consumers use their service.

Whether it's corporate pressure, or regulatory pressure, or totalitarian control of information through Internet filtering -- frontends are vastly more vulnerable to censorship than The Blockchain.

Enabling consumers to rely on their own locally hosted frontends removes an unnecessary intermediary.

... and more?

What are some shortcomings?

Every contract experience looks the same?

Is it boring that contract experiences look too similar? Should we be able to white-label procedural contracts?

One approach is to have additional theme annotations in contract source code (as comments), which procedural frontends can use to generate appropriate look and feel to match the rest of the apps.

Impossible to cover 100% of use cases?

Contracts come with varying degree of complexity. It's easy to imagine covering typical token-like contracts, but what about more complicated things like multi-step state machines, or things that require custom client-side logic like Tornado Cash?

Similar to the themeing approach, we can imagine including some declarative association between fields in the contract source code that the frontend could derive a state machine from. But at some point, we just need to accept that some contracts will require a bespoke frontend. The bet here is that most should not.

Tricky contracts are still tricky

We can get rid of tricky frontends lying about what they're doing, but we're still left with contracts that have functions claiming to do one thing (via function signature, NatSpec, etc) and in reality does something different.

This can be tackled with a combination of better local transaction simulation and better static analysis of EVM bytecode.

How do we get there?

A rough roadmap towards a procedural future:

The future is procedural.