# @polkadot-api/wasm-executor

> This package has been strongly influenced by [Chopsticks](https://github.com/AcalaNetwork/chopsticks). It can be used in both web and NodeJS environments.

Latest version **0.2.3** (published 2025-12-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install @polkadot-api/wasm-executor
pnpm add @polkadot-api/wasm-executor
yarn add @polkadot-api/wasm-executor
bun add @polkadot-api/wasm-executor
```

## Health

**Score 55/100 (C)** — status: stable.

Positive: esm support; no vulnerabilities; has provenance.

Warnings: low downloads; no types; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2025-12-02 |
| First published | 2024-05-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.2 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Provenance | attested (GitHub Actions) |
| GitHub stars | 2 |
| Author | Carlo Sala |
| Maintainers | voliva, josepot |

## Links

- npm: https://www.npmjs.com/package/@polkadot-api/wasm-executor
- Repository: https://github.com/polkadot-api/wasm-executor
- Homepage: https://github.com/polkadot-api/wasm-executor#readme
- Issues: https://github.com/polkadot-api/wasm-executor/issues
- npm.io page: https://npm.io/package/@polkadot-api/wasm-executor

## Recent versions

- 0.2.3 (latest) — 2025-12-02
- 0.2.2 — 2025-10-03
- 0.2.1 — 2025-06-02
- 0.2.0 — 2025-06-02
- 0.1.2 — 2024-11-10
- 0.1.1 — 2024-07-11
- 0.1.0 — 2024-05-16

## README

# @polkadot-api/wasm-executor

This package has been strongly influenced by [Chopsticks](https://github.com/AcalaNetwork/chopsticks).
It can be used in both web and NodeJS environments.

At this point, it just exports a `getMetadataFromRuntime` function that runs WASM under the hood, and returns its metadata in `string`.

## Examples

### Web

```ts
// IMPORTANT to prefix it with `0x`!
const runtime = "0x" + fs.readFileSync("runtime.wasm").toString("hex");

// returns a `0x` prefixed OpaqueMetadata. It's as well prefixed by a compactInt of its length
const metadata = await import("@polkadot-api/wasm-executor/web").then(
  async ({ default: init, getMetadataFromRuntime }) => {
    await init();
    return getMetadataFromRuntime(runtime);
  },
);
```

### Node

```ts
import { getMetadataFromRuntime } from "@polkadot-api/wasm-executor/node";

// IMPORTANT to prefix it with `0x`!
const runtime = "0x" + fs.readFileSync("runtime.wasm").toString("hex");

// returns a `0x` prefixed OpaqueMetadata. It's as well prefixed by a compactInt of its length
const metadata = getMetadataFromRuntime(runtime);
```

---
_Source: https://npm.io/package/@polkadot-api/wasm-executor · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
