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 🙏

© 2025 – Pkg Stats / Ryan Hefner

mochimo-mesh-api-client

v1.1.0

Published

A TypeScript client library for interacting with the Mochimo blockchain API

Readme

Mochimo Mesh API Client

A TypeScript client library for interacting with the Mochimo blockchain API. This library provides a simple interface for building and signing transactions, managing wallets, and interacting with the Mochimo blockchain.

Installation

npm install mochimo-mesh-api-client crypto-js mochimo-wots

Features

  • Build and sign transactions
  • Manage WOTS wallets
  • Handle transaction memos
  • Full TypeScript support
  • Comprehensive blockchain API interaction

Quick Start

import { TransactionBuilder, MochimoApiClient } from 'mochimo-mesh-api-client';
import { WOTSWallet } from 'mochimo-wots';
import CryptoJS from 'crypto-js';

async function sendTransaction() {
    // Initialize the builder with your node's API URL
    const builder = new TransactionBuilder('http://node.example.com:8081');

    // For direct API access
    const client = new MochimoApiClient('http://node.example.com:8081');

    // Create parent wallet (optional)
    const firstWotsSeed = CryptoJS.SHA256('mysourceseeddds' + 2).toString();
    const firstWotsWallet = WOTSWallet.create('first', Buffer.from(firstWotsSeed, 'hex'), undefined);

    // Create source and change wallets
    const sourceWotsSeed = CryptoJS.SHA256('mysourceseeddds' + 6).toString();
    const changeWotsSeed = CryptoJS.SHA256('mysourceseeddds' + 7).toString();
    
    const sourceWallet = WOTSWallet.create(
        'source',
        Buffer.from(sourceWotsSeed, 'hex'),
        firstWotsWallet.getAddrHash()
    );

    const changeWallet = WOTSWallet.create(
        'change',
        Buffer.from(changeWotsSeed, 'hex'),
        firstWotsWallet.getAddrHash()
    );

    // Build and sign a transaction
    const result = await builder.buildAndSignTransaction(
        sourceWallet,
        changeWallet,
        "0x" + Buffer.from(destWallet.getAddrTag()!).toString('hex'),
        BigInt(10000), // amount
        BigInt(500),   // fee
        'AB-00-EF'     // optional memo
    );

    console.log('Transaction submitted:', result.signedTransaction);
}

API Reference

TransactionBuilder

The main class for building and signing transactions.

class TransactionBuilder {
    constructor(baseUrl: string);

    // Build and sign a complete transaction
    buildAndSignTransaction(
        sourceWallet: WOTSWallet,
        changeWallet: WOTSWallet,
        destinationTag: string,
        amount: bigint,
        fee: bigint,
        memo?: string,
        blockToLive?: number
    ): Promise<{
        buildResult: any;
        submitResult: any;
        signedTransaction: string;
    }>;
}

MochimoApiClient

Low-level API client for direct interaction with the Mochimo blockchain.

class MochimoApiClient {
    constructor(baseUrl: string);

    // Get account balance
    getAccountBalance(address: string): Promise<BalanceResponse>;

    // Resolve tag to address
    resolveTag(tag: string): Promise<ResolveTagResponse>;

    // Get mempool transactions
    getMempoolTransactions(): Promise<MempoolResponse>;

    // Get specific mempool transaction
    getMempoolTransaction(txHash: string): Promise<MempoolTransactionResponse>;

    // Wait for transaction to appear in mempool
    waitForTransaction(
        transactionHash: string,
        timeout?: number,
        interval?: number
    ): Promise<MempoolTransactionResponse>;
}

Memo Format Rules

Memos must follow these rules:

  • Contains only uppercase [A-Z], digits [0-9], dash [-]
  • Groups can be multiple uppercase OR digits (not both)
  • Dashes must separate different group types
  • Cannot have consecutive groups of the same type
  • Cannot start or end with a dash

Valid examples:

  • "AB-00-EF"
  • "123-CDE-789"
  • "ABC"
  • "123"

Invalid examples:

  • "AB-CD-EF" (consecutive letter groups)
  • "123-456-789" (consecutive number groups)
  • "ABC-" (ends with dash)
  • "-123" (starts with dash)

Development

Building

npm run build

Testing

The tests in this library are integration tests that require a running Mochimo node.

# Run integration tests (requires running node)
npm run test:integration

Error Handling

The library throws errors in these cases:

  • Invalid API responses
  • Network errors
  • Invalid memo format
  • Invalid transaction parameters
  • Timeout waiting for mempool transaction

Example error handling:

try {
    const result = await builder.buildAndSignTransaction(...);
} catch (error) {
    if (error instanceof Error) {
        console.error('Transaction failed:', error.message);
    }
}

Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

License

MIT

Support

For support, please open an issue in the GitHub repository.