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

@attocash/commons-wallet

v9.1.0

Published

Wallet utilities for deriving accounts, opening accounts, sending funds, and receiving funds.

Downloads

460

Readme

commons-wallet

Manage seed-derived accounts, sign and publish transfers, and receive incoming funds through an Atto node and a proof-of-work worker. Use this module when you want account state and transaction construction managed for you; use commons-node directly for queries and streams.

Install

implementation("cash.atto:commons-wallet:<version>")

For JavaScript and TypeScript:

npm install @attocash/commons-core @attocash/commons-node @attocash/commons-node-remote @attocash/commons-worker @attocash/commons-worker-remote @attocash/commons-wallet

Use the same release for all Commons packages. The JavaScript guide covers ESM and runtime setup; the Java example uses the CompletableFuture API.

Open a wallet account

Start a node API and a Work Server before running this example. Replace the localhost URLs with your service endpoints. A generated seed has no funds: the example registers an address locally and queries its state; it does not create an on-chain account or a balance.

import cash.atto.commons.AttoMnemonic
import cash.atto.commons.node.AttoNodeClient
import cash.atto.commons.node.remote
import cash.atto.commons.toAttoIndex
import cash.atto.commons.wallet.AttoWallet
import cash.atto.commons.worker.AttoWorker
import cash.atto.commons.worker.remote
import kotlinx.coroutines.runBlocking

fun main() = runBlocking {
    val seed = AttoMnemonic.generate().toSeed()
    val client = AttoNodeClient.remote("http://localhost:8080")
    AttoWorker.remote("http://localhost:8085").use { worker ->
        val wallet = AttoWallet.create(client, worker, seed)
        val index = 0U.toAttoIndex()
        wallet.openAccount(index)
        println(wallet.getAddress(index))
        println(wallet.getAccount(index)?.balance) // null until opened on-chain
    }
}

Keep the mnemonic securely if the account will hold funds. openAccount must precede getAddress, getAccount, sending, or receiving for that index. Opening the same index twice fails; closeAccount removes it from the wallet's local membership. A wallet created from one signer supports only index zero.

Send and receive

Within a suspending context, send from an already funded, open wallet account:

import cash.atto.commons.AttoAmount
import cash.atto.commons.AttoUnit

// wallet, senderIndex, and destinationAddress are supplied by your application.
val transaction = wallet.send(
    senderIndex,
    destinationAddress,
    AttoAmount.from(AttoUnit.ATTO, "1"),
)

Sending publishes a send block. The destination must publish a receive block to add the funds to its balance. Use wallet.receive(receivable, representativeAddress) explicitly, or enable the auto-receiver. Receiving the first payment opens the on-chain account and requires a representative address.

Sending, receiving, and changing a representative serialize updates for each wallet account. The cached account advances after publication succeeds; operations on different accounts can proceed independently.

The auto-receiver uses the wallet's address membership and a node account monitor. In an application coroutine scope:

import cash.atto.commons.node.monitor.createAccountMonitor
import cash.atto.commons.wallet.startAutoReceiver
import kotlinx.coroutines.cancelAndJoin

val monitor = client.createAccountMonitor()
val receiverJob = wallet.startAutoReceiver(scope, monitor) { representativeAddress }
try {
    // Keep the application scope alive while handling incoming payments.
} finally {
    receiverJob.cancelAndJoin()
}

Use a representative appropriate for your network. Cancel and join wallet jobs before closing workers or other closeable dependencies. The auto-receiver manages incoming receivables; the wallet's cached account state is not a general replacement for live node queries when other processes also publish for the same keys.

JavaScript uses AttoWalletAsyncBuilder, .signerProviderSeed(seed), and awaited methods such as openAccount, getAddress, getAccountByIndex, and sendByIndex. See the runnable JavaScript example for setup, auto-receive, and teardown.

Closing an async wallet cancels its auto-receiver and monitor binding. The supplied node client, worker, and monitor remain owned by the caller.

In-memory history

AttoTransactionRepository.inMemory() and AttoAccountEntryRepository.inMemory() keep an append-only history for each address. Each collection of stream(address) replays saved values in append order, then follows new saves without a gap. Duplicate saves remain in the history. Slow collectors do not hold the storage lock or prevent saves; the repositories retain their full history in memory.

Further reading