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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@three-em/js

v0.3.0

Published

In order for use `3EM` for Node, please install the following package:

Downloads

120

Readme

NodeJS

In order for use 3EM for Node, please install the following package:

$ yarn add @three-em/node
# OR
# $ npm install --save @three-em/node
import { executeContract } from "@three-em/node";

Browser

<script type="module">
    import { executeContract } from "https://unpkg.com/@three-em/[email protected]/index.js";
</script>

Deno

import { executeContract } from "https://deno.land/x/[email protected]/index.js";

executeContract

Read the current state of all kinds of contracts.

export function executeContract<T extends unknown>(
  contractTx: string,
  blockHeight?: number,
  gatewayConfig?: ExecuteConfig
): Promise<{
  state: T;
  validity: Record<string, bool>;
}>;
import { executeContract } from "./index.js";

const { state, validity } = await executeContract(
  "t9T7DIOGxx4VWXoCEeYYarFYeERTpWIC1V3y",
);
import { executeContract } from "./index.js";

const { state, validity } = await executeContract(
  "t9T7DIOGxx4VWXoCEeYYarFYeERTpWIC1V3y",
  undefined, 
  {
     host: "www.arweave.run",
     port: 443,
     protocol: "https" 
  }  
);

Global Variables (Deno & Browser)

globalThis.ARWEAVE_HOST = "www.arweave.run";
globalThis.ARWEAVE_PROTOCOL = "https";
globalThis.ARWEAVE_PORT = 443;

Runtimes

Three seperate libraries are available for low level use only. The API is subject to breaking changes.

JavaScript

import { Runtime } from "./sw.js";
const rt = new Runtime(source, state, {});

// Faster. At 100 interactions in about 3.68ms.
await rt.executeInteractions(interactions);

// OR

// Slower than `rt.executeInteractions` but more readable
// 100 interactions in ~30.06ms.
for (const interaction of interactions) {
  const input = interaction.node.tags.find((data) => data.name === "Input");
  await rt.execute({ input, caller: interaction.node.owner.address });
}

console.log(rt.state); // Read the state.

rt.destroy();

WASM

// usage_01.js
import { WasmRuntime } from "./wasm.js";

const contractBytes = new Uint8Array([/* ... */]);
const rt = new WasmRuntime();
await rt.compile(contractBytes, {});

// `call` only accepts encoded bytes of
// the JSON state to provide better performance and reduce
// conversion overhead on recursive runs.
const initialState = encode({ counter: 0 });
const input = encode({});

const result = rt.call(initialState, input);

const state = decode(result);
assertEqual(state.counter, 1);

EVM

// usage_01.js
import { hex, Machine } from "./evm/index.js";

// Solidity code for 1 + 2 = 3
// :-)
const machine = new Machine(module, hex("4f2be91f"));
machine.execute(
  hex(
    "6080604052348015600f57600080fd5b506004361060285760003560e01c80634f2be91f14602d575b600080fd5b60336047565b604051603e91906067565b60405180910390f35b60006003905090565b6000819050919050565b6061816050565b82525050565b6000602082019050607a6000830184605a565b9291505056fea26469706673582212200047574855cc88b41f29d7879f8126fe8da6f03c5f30c66c8e1290510af5253964736f6c634300080a0033",
  ),
);

assertEquals(
  machine.result,
  hex("0000000000000000000000000000000000000000000000000000000000000003"),
);