npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@riverith/soroban-decompiler-wasm

v0.2.4

Published

Browser WASM build of the Soroban decompiler — runs entirely client-side

Downloads

303

Readme

@riverith/soroban-decompiler-wasm

Browser WASM build of the Soroban smart contract decompiler. Decompiles compiled Soroban .wasm files into readable Rust source code entirely client-side — no server required.

Install

npm install @riverith/soroban-decompiler-wasm

Quick Start

import init, { decompile } from '@riverith/soroban-decompiler-wasm';

await init();

const response = await fetch('contract.wasm');
const bytes = new Uint8Array(await response.arrayBuffer());
const rustSource = decompile(bytes);
console.log(rustSource);

API

decompile(wasm_bytes, signatures_only?)

Decompile a Soroban WASM binary into Rust source code.

const source = decompile(wasmBytes);           // full decompilation
const sigs = decompile(wasmBytes, true);        // types + signatures only (fast)
  • wasm_bytes Uint8Array — raw WASM binary
  • signatures_only boolean? — skip bytecode analysis, emit only type definitions and function stubs
  • Returns string — formatted Rust source code

inspect(wasm_bytes)

Extract the contract specification (types, functions, events, errors) as a string.

const spec = inspect(wasmBytes);

imports(wasm_bytes)

Resolve all WASM host function imports with their semantic Soroban names.

const resolved = imports(wasmBytes);

score(original, decompiled)

Score decompiled output accuracy against original source code. Returns JSON with type, signature, and body scores.

const result = JSON.parse(score(originalRust, decompiledRust));
console.log(`accuracy: ${(result.overall * 100).toFixed(1)}%`);

benchmark(name, original, decompiled)

Full benchmark report with per-function scores, statement alignments, and type comparisons.

const report = JSON.parse(benchmark('my_contract', originalRust, decompiledRust));

Usage with Stellar SDK

Fetch a deployed contract's WASM directly from the network and decompile it:

import init, { decompile } from '@riverith/soroban-decompiler-wasm';
import { rpc } from '@stellar/stellar-sdk';

await init();

const server = new rpc.Server('https://soroban-testnet.stellar.org');
const contractId = 'CABC...XYZ';
const instance = await server.getContractData(contractId, 'instance');
// ... fetch WASM from ledger entry
const source = decompile(wasmBytes);

Framework Examples

React

import { useState } from 'react';
import init, { decompile } from '@riverith/soroban-decompiler-wasm';

function Decompiler() {
  const [source, setSource] = useState('');

  async function handleFile(e) {
    await init();
    const buf = await e.target.files[0].arrayBuffer();
    setSource(decompile(new Uint8Array(buf)));
  }

  return (
    <div>
      <input type="file" accept=".wasm" onChange={handleFile} />
      <pre>{source}</pre>
    </div>
  );
}

Vanilla JS

<script type="module">
import init, { decompile } from '@riverith/soroban-decompiler-wasm';
await init();
window.decompile = decompile;
// Now use decompile(uint8Array) in the console
</script>

Build from Source

# Requires wasm-pack
cargo install wasm-pack

# Build the package
wasm-pack build crates/soroban-decompiler-wasm --target web --release --scope riverith

# Output in crates/soroban-decompiler-wasm/pkg/

Package Contents

| File | Description | |------|-------------| | soroban_decompiler_wasm.js | JS glue code with ESM exports | | soroban_decompiler_wasm.d.ts | TypeScript type definitions | | soroban_decompiler_wasm_bg.wasm | Compiled WASM binary (~2.5MB) |

License

Apache-2.0