Today we’re excited to announce three major updates for WeaveVM Bundles:
- a JS/TS client that makes it easier for JavaScript and TypeScript developers to integrate the WeaveVM bundles protocol (especially in frontend applications)
- the ability to add custom tags to your envelopes
- the first stable release of 0xbabe1 bundles.
Bundles are a simple and cost-effective way to push data to WeaveVM, making WeaveVM usable as a general data storage layer from any server or UI environment. Tags make data protocols possible — for example, being able to retrieve all data generated by a given application without the need for it be mapped in a smart contract.
Let’s look at how you get started with these new features.
Tagged Envelopes
With the v0.1.3 Bundler protocol release, you can now add up to 2048 bytes of tags to your envelope. This tagging feature is a crucial component for data-centric transactions. For example, developers can add MIME types to their envelopes, enabling easy, out-of-the-box data rendering from reading clients.
Additional use cases include custom data protocols for lazy-evaluating smart contracts, enabling developers to build hyperscalable L3s on top of the WeaveVM data bundling protocol, atomic assets, and much more! The tagging feature is supported in both the Rust library and TypeScript package.
use bundler::utils::core::envelope::Envelope;
use bundler::utils::core::bundle::Bundle;
use bundler::utils::core::tags::Tag;
async fn send_envelope_with_tags() -> eyre::Result<String> {
// will fail until a tWVM funded EOA (pk) is provided
let private_key = String::from("");
let mut envelopes: Vec<Envelope> = vec![];
// add your tags to a vector
let tags = vec![Tag::new(
"Content-Type".to_string(),
"text/plain".to_string(),
)];
for _ in 0..1 {
let random_calldata: String = generate_random_calldata(128_000); // 128 KB of random calldata
let envelope_data = serde_json::to_vec(&random_calldata).unwrap();
let envelope = Envelope::new()
.data(Some(envelope_data))
.target(None)
.tags(Some(tags.clone())) // register your tags
.build()
.unwrap();
envelopes.push(envelope);
}
let bundle_tx = Bundle::new()
.private_key(private_key)
.envelopes(envelopes)
.build()
.expect("REASON")
.propagate()
.await
.unwrap();
Ok(bundle_tx)
}
Browser Support
At the current stage, bundles are identified on WeaveVM Explorer with the “bundle 0.1.0” label (corresponding to 0xbabe1 versioning). We’ll soon roll out an explorer update that indexes envelopes and displays them individually.
JS/TS Client
npm i weavevm-bundles
The Bundler data protocol was initially released with a Rust library for bundle interactions. To drive broader adoption, we’ve now released a TypeScript client that makes it even easier to use bundles in your frontend and JavaScript-based applications.
The package is a port of the Bundler Rust library and uses it as a reference for features. It’s fully compatible with the v0.1.3 bundles stable release.
For installation, integration, and usage instructions, check out the package repository on GitHub.
import { Envelope, Bundle } from "weavevm-bundles";
import { ethers } from "ethers";
(async () => {
// Create a wallet (for demonstration; you'd normally have an existing private key or mnemonic)
const wallet = ethers.Wallet.createRandom();
// Create an Envelope with some data (nonce, gasPrice, gasLimit, etc. are all zero by default)
const envelope = new Envelope(
new Uint8Array(Buffer.from("test-data", "utf8")),
"0x0000000000000000000000000000000000000000"
);
// Extract an unsigned ethers.js transaction
const unsignedTx = envelope.extractUnsigned();
// Sign the transaction
// (Though 0 gas price/limit is invalid in a real EVM sense, this demonstrates the mechanics)
const signedTxHex = await wallet.signTransaction(unsignedTx);
const signedTx = ethers.Transaction.from(signedTxHex);
// Attach signature & hash to the envelope
envelope.setSignedAttributes(signedTx);
console.log("Envelope is valid?", envelope.isValid());
// Create a Bundle and add the Envelope
const bundle = new Bundle();
bundle.addEnvelope(envelope);
// Prepare the final transaction data
const txData = bundle.extractTransaction();
console.log("Final bundle transaction data:", txData);
// Send this transaction via ethers.js
const provider = new ethers.JsonRpcProvider("https://testnet-rpc.wvm.dev", {
chainId: 9496,
name: "wvm-testnet",
});
const walletWithProvider = wallet.connect(provider);
try {
const response = await walletWithProvider.sendTransaction(txData);
console.log("Transaction sent! Hash:", response.hash);
await response.wait();
console.log("Transaction confirmed!");
} catch (err) {
console.error("Transaction failed:", err);
}
})();
0xbabe1 stable release
The 0xbabe1 release launched with Bundler protocol v0.1.3, introducing several key features: Envelope Tagging, a finalized data protocol specification for bundles, Rust and TypeScript clients, and bundle retrieval HTTP APIs.
Useful Links
- WeaveVM docs
- WeaveVM faucet: https://wvm.dev/faucet
- Bundler Rust Library: https://github.com/weaveVM/bundler
- Bundler TS Client: https://github.com/weavevm/weavevm-bundles-js