Building Mini dApps on the Steem Blockchain with Live Twists ⚡

in Steem Dev3 days ago

5% of the rewards of this post are for @steem.amal

1000121601.jpg

1000121602.jpg

One of the ideas I've been exploring while developing SteemTwist is whether a blockchain social post can become more than just text.

Most social blockchains treat posts as documents. They contain markdown, images, and metadata, but ultimately they remain static content.

I wanted to explore a different direction:

What if every post could also become a miniature decentralized application?

That idea became Live Twists, one of the core features of SteemTwist.

You can try it here:

Live Demo:

https://puncakbukit.github.io/steemtwist/

Source Code:

https://github.com/puncakbukit/steemtwist

A Different Way to Think About dApps

When we hear the term dApp, we often imagine an entire website with dozens of pages, smart contracts, APIs, and backend infrastructure.

Live Twists take a much smaller approach.

Instead of building an entire application, a developer creates a single interactive component that is stored inside a Steem post.

Think of it as a self-contained mini dApp.

Each Live Twist can include JavaScript that executes only when the reader explicitly clicks Run. The code is stored in the post's json_metadata, while the post body remains compatible with every existing Steem frontend.

Instead of linking users to another website, the application comes to them as part of the post itself.

What Can a Mini dApp Do?

The current API intentionally keeps the programming model small and straightforward.

A Live Twist can:

  • Render dynamic HTML
  • Respond to user interaction
  • Query Steem blockchain data
  • Request blockchain actions through Steem Keychain
  • Update itself without reloading the page

This makes surprisingly rich applications possible.

For example, developers could build:

  • Voting dashboards
  • Witness explorers
  • Account analyzers
  • Reputation calculators
  • Reward estimators
  • SP delegation helpers
  • Community polls
  • Educational tutorials
  • Interactive quizzes
  • Blockchain games
  • Event countdowns
  • Donation widgets
  • Market dashboards
  • Governance tools

Each of these exists as a blockchain post rather than a separate website.

No Backend Required

One aspect I particularly enjoy about this architecture is its simplicity.

SteemTwist itself is entirely static.

There is no backend server, no database, no build pipeline, and no application server.

The frontend communicates directly with Steem RPC nodes and Steem Keychain.

Because Live Twists execute inside the user's browser, developers don't need to deploy infrastructure for small interactive applications.

Publishing a mini dApp is essentially the same as publishing a post.

The blockchain becomes the distribution layer.

Read-Only Queries

Many useful tools only need blockchain data.

Live Twists expose read-only API methods through functions such as:

const ticker = await app.ask("getTicker", {});
const account = await app.ask("getAccounts", {
  accounts: ["alice"]
});

Developers can combine multiple asynchronous queries using Promise.all(), making it possible to build responsive dashboards without writing callback-heavy code.

Because the communication happens through the parent application, the sandbox remains isolated from the underlying RPC implementation.

Safe Blockchain Actions

Interactivity becomes even more interesting when users can perform blockchain operations.

Live Twists support actions such as:

  • Vote
  • Reply
  • Follow
  • Unfollow
  • Retwist
  • Transfer
  • Power Up
  • Delegate SP
  • Vote for Witness

However, these operations never execute directly from sandboxed JavaScript.

Instead, the request flows through the parent application, where parameters are validated and sanitized before the user is presented with a confirmation dialog. Only after explicit approval does the request reach Steem Keychain for signing.

The sandbox itself has no direct access to Keychain or browser credentials.

Security First

Running user-generated JavaScript naturally raises security concerns, so Live Twists were designed with multiple layers of isolation.

The execution environment uses a sandboxed iframe with only allow-scripts enabled.

Network APIs such as fetch(), XMLHttpRequest, WebSocket, and window.open() are disabled inside the sandbox.

Every call to render HTML is sanitized with DOMPurify before being inserted into the document, while communication between the sandbox and the parent page is restricted to a carefully validated postMessage bridge.

Execution is also user initiated. Nothing runs automatically when a page loads. A visitor must explicitly choose to run the mini dApp.

These restrictions intentionally limit what a Live Twist can do while still leaving enough capability to build genuinely useful applications.

A New Distribution Model

Perhaps the most interesting part of Live Twists isn't the JavaScript itself.

It's the distribution model.

Instead of publishing a project to a hosting service and then sharing a URL on social media, developers publish the application as the social post.

The application travels with the conversation.

People discover it through their feeds, interact with it directly inside the post, reply to it, retwist it, and share it with others without leaving the platform.

That creates opportunities for lightweight community tools that are easier to discover than standalone websites.

Looking for Ideas

Live Twists are still evolving, and I believe there is plenty of room to expand the ecosystem.

I'd love to hear what kinds of mini dApps other Steem developers would build using this model.

Would you create developer utilities? Educational tools? Governance dashboards? Games? Wallet helpers? Something completely different?

If you'd like to explore the project or contribute ideas, feel free to check out the live demo and the source code.

Live Demo:

https://puncakbukit.github.io/steemtwist/

GitHub Repository:

https://github.com/puncakbukit/steemtwist

I'm looking forward to hearing your thoughts and seeing what kinds of blockchain-native mini dApps the Steem community can create together.

Assisted by https://ChatGPT.com/.

See also:

Sort:  

Upvoted! Thank you for supporting witness @jswit.