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

@smartweaver/slick-transaction

v0.0.13

Published

Slick builder APIs for creating Arweave transactions

Downloads

30

Readme

Slick Transaction

Slick builder APIs for creating Arweave transactions

Installation

npm install @smartweaver/slick-transaction

# or yarn add @smartweaver/slick-transaction
# or pnpm install @smartweaver/slick-transaction

Modules

The modules below extend Slick Transaction's lower level APIs. These modules are intended to provide you with clean and simple building blocks to create your Arweave applications. All modules contain zero third-party dependencies.

| Name | Description | Docs | | - | - | - | | ao | A clean, idiomatic client for the ao APIs. Methods are written to closely match the ao APIs they target. | Docs | | aoconnect | A decorator for the @permaweb/aoconnect aoconnect object. | Docs | aoprocess | An implementation of the aoconnect module, but strictly made for interacting with processes. | Docs

Why Use This?

Interoperable

Slick Transaction ships with zero dependencies and can be used in different JavaScript runtimes (e.g., Deno, Bun, Node, Cloudflare).

Class-Based

All of Slick Transaction's modules use classes to cater to object-oriented programming (OOP). That said, Slick Transaction is for those who prefer OOP, but those who prefer functional programming can use Slick Transaction as the foundation to build functional programming style software.

Examples

aoconnect

The example below shows a working copy of the aoconnect module. This code can be found in the examples/aoconnect directory.

To see a comparison of this module and @permaweb/aoconnect, view this module's Syntax Comparison documentation.

import * as aoconnect from "@permaweb/aoconnect";
import { Client } from "@smartweaver/slick-transaction/modules/aoconnect/Client.js";

const wallet = {}                                      // Replace with your wallet JWK object here
const signer = aoconnect.createDataItemSigner(wallet); // Create the `DataItem` signer that aoconnect will use
const client = new Client(aoconnect);                  // Create Slick Transaction's aoconnect decorator

(async () => {
  const msgId = "wSbmo3kkzDGWNEziIAiIybob1VsiIsVqp0i0siX8QfQ";
  const procId = "G3vHz_3XOUAzzVciJCnDf0NLRjbL6bjwRT5mAclrLrk";

  // Get a message result
  const messageResult = await client
    .cu()                   // Access the Compute Unit methods
    .result()               // Access the Compute Unit's "message result" methods
    .message(msgId)         // Provide the ID of the message you want to get the result of
    .process(procId)        // Provide the process ID where the message was sent to
    .get();                 // Get the message result (calls HTTP GET under the hood -- hence the method name)
  console.log({ messageResult })

  // Get message results
  const results = await client
    .cu()                   // Access the Compute Unit methods
    .results()              // Access the Compute Unit's results methods to get results from a process
    .process(procId)        // Provide the process ID you want to get messages from
    .limit(25)              // Optionally, provide a number of messages to return
    .sort("DESC")           // Optionally, provide a sort order of the returned results (DESC|ASC)
    .get();                 // Get the results (calls HTTP GET under the hood -- hence the method name)
  console.log({ results })

  // Send a DryRun message
  const dryRunResult = await client
    .cu()                   // Access the Compute Unit methods
    .dryRun()               // Access the Compute Uni's  DryRun methods to send a DryRun message to a process
    .process(procId)        // Provide the process ID you want to send this message to
    .tags({                 // Optionally, send tags with the message
      "Action": "Mint",
      "Quantity": "100",
      "Recipient": ""
    })
    .data("some data")      // Optionally, send data with the message
    .post();                // Send the message (calls HTTP POST under the hood -- hence the method name)
  console.log({ dryRunResult: dryRunResult.Messages[0] })

  // Send a message
  const messageId = await client
    .mu()                   // Access the Compute Unit methods
    .message()              // Access the Compute Uni's  DryRun methods to send a DryRun message to a process
    .process(procId)        // Provide the process ID you want to send this message to
    .tags({                 // Optionally, send tags with the message
      "Action": "Mint",
      "Quantity": "100",
      "Recipient": ""
    })
    .dataItemSigner(signer) // Ensure this message can be signed when it is sent to ao
    .data("some data")      // Optionally, send data with the message
    .post();                // Send the message (calls HTTP POST under the hood -- hence the method name)
  console.log({ messageId });

  // Get the result of the message that was sent above
  const lastMessageResult = await client
    .cu()                   // Access the Compute Unit methods
    .result()               // Access the Compute Unit's "message result" methods
    .message(messageId)     // Provide the ID of the message you want to get the result of
    .process(procId)        // Provide the process ID where the message was sent to
    .get();                 // Get the message result (calls HTTP GET under the hood -- hence the method name)
  console.log({ lastMessageResult });

  const moduleId = "1SafZGlZT4TLI8xoc0QEQ4MylHhuyQUblxD8xLKvEKI";
  const schedulerId = "_GQ33BkPtZrqxA84vM8Zk-N2aO0toNNu_C-l-rawrBA";

  // Spawn a new process
  const newProcessId = await client
    .mu()                   // Access the Messenger Unit methods
    .spawn()                // Access the Messgener Unit's spawn methods to spawn a new process
    .dataItemSigner(signer) // Ensure this message can be signed when it is sent to ao
    .module(moduleId)       // Provide the ID of the module this process should use
    .scheduler(schedulerId) // Provide the ID of the Scheduler Unit that will handle this process
    .data("some data")      // Optionally, send data with this message
    .post();                // Send the request (calls HTTP POST under the hood)

  console.log({ newProcess: `https://www.ao.link/#/entity/${newProcessId}` });
})();