Putting Rust in Production with Inline Base64 WASM

2024-10-14 · Ryan X. Charles

From the beginning, EarthBucks has been co-implemented in both TypeScript and Rust. The TypeScript code has been in production since almost the beginning, and I’m happy to say that after more than six months of development, I have finally put the first Rust code into production as well.

I have created two new Rust libraries: earthbucks_blake3 and earthbucks_secp256k1. These libraries are used in the EarthBucks codebase to compute BLAKE3 hashes and to perform ECDSA signatures and verifications.

Originally, I assumed there would be a totally separate Rust process serving as the “node,” exactly like Bitcoin. But as I built the project, I gradually figured out how to put all the functionality into a single, architecturally simple, horizontally scalable web app. The web app simply services requests and has a cron job with a locking feature for some background processing. There was no reason to have a separate “node” at all, so the Rust code simply sat around unused.

However, I had some issues with the BLAKE3 library for Node.js I was using, as it was unmaintained. So I figured out how to build some of my Rust code into WASM so that it could be included inside the TypeScript code, both for Node.js and browsers.

After some thought and effort, I found that by using inline, Base64-encoded WASM for the Rust code, it works both in Node.js and all modern browsers with no special configuration.

Thus, corresponding to the new Rust libraries are new Node.js libraries (written in TypeScript, with Rust WASM inside): @earthbucks/blake3 and @earthbucks/secp256k1.

Along the way, I have made updates to both the TypeScript code and the other (as-yet unused) Rust code. The full list of libraries is as follows:


TypeScript


Rust


You can find the code for all of these libraries in the main EarthBucks repo: github.com/earthbucks/earthbucks.

Most of the code I’m writing right now is not open-source. The next major undertaking is to build the wallet, which is essentially the ability for users to send and receive EarthBucks. The test mode blockchain continues to function well. The real genesis block is close, but I have learned not to try to estimate a launch date. Stay tuned to the app and also the Telegram, Discord, and X channels to learn when the launch happens.


Earlier Blog Posts


Back to Blog

Home · About · Blog · Privacy · Terms
X · Telegram · Discord · reddit · GitHub
Copyright © 2024 Ryan X. Charles LLC