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

@moonchain/agents

v0.1.0

Published

_description_

Downloads

3

Readme

Moonchain Transaction Agents

The Moonchain Transaction Agents libraries are designed for proxying transactions on Moonchain or other chains, allowing users to send contract transactions without paying gas fees.

It consists of the following components:

  • Next Api Agents: Servers that proxy the sending of transactions, reading the RPC address and private key from the .env file and broadcasting transaction requests to the network.
  • Contracts Utils: Contracts used for proxying transactions, ensuring and verifying that transactions are sent only by the proxy or the user themselves.

Install

pnpm install @moonchain/agents

Add API route

Create a .env file with the following two parameters:

  • NETWORK_RPC: Your Network RPC url
  • PRIVATE_KEY: The private key address of the proxy

Configure routing in the pages/api/agents directory of your Next.js project. The API route will be used to send transactions to the proxy server.

// pages/api/agents/[...path].ts
import { TransactionAgents } from '@moonchain/agents'

export default TransactionAgents({
  NETWORK_RPC: process.env.NETWORK_RPC!,
  PRIVATE_KEY: process.env.PRIVATE_KEY!
})
// or
export default TransactionAgents({
  NETWORK_RPC: req => '...',
  PRIVATE_KEY: req => '...'
})

Please ensure that the proxy's private key address has sufficient balance to cover transaction fees, and keep the private key secure to prevent theft.

Contracts

The contracts are located in the contracts directory of this repository. You can reference them in your contract project using npm.

  • ProxyForward.sol: A contract for proxying transactions, ensuring and verifying that transactions are sent only by the proxy or the user themselves.
  • ProxyForwardUpgradeable.sol: A contract for proxying transactions that supports upgradeable contracts.
import "@moonchain/agents/contracts/ProxyForward.sol";

contract Counter is ProxyForward {
  constructor(address _agent) ProxyForward(_agent) {}

  uint256 public count;

  function add(address sender, uint256 num) public proxy(sender) {
    count += num;
  }

  function sub(address sender, uint256 num) public proxy(sender) {
    count -= num;
  }
}

Usage

This example uses the Counter.sol contract written above and utilizes the Agents Servers to proxy the sending of transactions.

import { agent, proof } from '@moonchain/agents'
import { Contract, JsonRpcProvider, Transaction, Wallet } from 'ethers'
import abi from './Counter.json'

const provider = new JsonRpcProvider('URL_ADDRESS')
const user = new Wallet('264a...3492', provider)
const counter = new Contract('COUNTER_ADDRESS', abi, user)

// 1. Assemble the transaction
const populateTransaction = await counter.add.populateTransaction(user.address, 10)

// 2. Get the signed message generated by the proxy server
const message = await proof(counter.add.fragment, populateTransaction)

/**
 * message
 *
 *
 * from: ...
 * contract: ...
 * method: 0xa9059cbb | add(uint256)
 * params:
 *   to: ...
 *   value: 400
 * nonce: 4673
 */

// 3. Sign the message with the user's private key
const signedMessage = await user.signMessage(message)

// 4. Send the transaction to the proxy server and get the transaction information
const transaction = await agent(counter.add.fragment, {
  ...populateTransaction,
  signature: signedMessage,
})

// 5. Wait for the transaction broadcast to complete
const receipt = await provider.waitForTransaction(transaction.hash)

Limitations

Moonchain Transaction Agents do not support the direct sending of native tokens and are only applicable to contract-related transactions.

If you need to support the sending of ERC20 tokens, please modify the ERC20 contract to allow the proxy contract to perform user approvals.

import "@moonchain/agents/contracts/ProxyForward.sol";

contract ERC20 is ProxyForward {
  constructor(address _agent) ProxyForward(_agent) {}

  function approveProxy(address sender, address spender, uint256 amount) public proxy(sender) {
    _approve(sender, spender, amount);
  }
}