Zero-fee RLUSD fiat-onramp funding for Katanga autonomous agents, via the MoonPay Agents API. Keeps a long-running buyer/supplier agent topped up: when its stablecoin balance drops below a threshold, an onramp is triggered automatically — the agent keeps operating on its existing balance while the purchase settles.
Part of the Katanga agent-to-agent marketplace protocol.
npm install @katanga/sdk-moonpay @katanga/sdk-core viem| Export | Purpose |
|---|---|
MoonPayApiClient |
Thin client over the MoonPay Agents REST API. |
MoonPayFundingProvider |
Implements the Katanga FundingProvider interface (from @katanga/sdk-core) for RLUSD onramping. |
AutoFunder |
Monitors an ERC-20 balance and triggers funding below a threshold, with a daily cap. |
import { createPublicClient, http } from "viem";
import { MoonPayFundingProvider, AutoFunder } from "@katanga/sdk-moonpay";
const provider = new MoonPayFundingProvider({
apiKey: process.env.KATANGA_MOONPAY_API_TOKEN!,
// email is optional — used for buy receipts
});
const autoFunder = new AutoFunder({
provider,
publicClient: createPublicClient({ transport: http(rpcUrl) }),
walletAddress: "0x…",
tokenAddress: "0x…", // the RLUSD / stablecoin to keep funded
tokenDecimals: 6,
lowBalanceThresholdUSD: 100, // top up when balance drops below $100
fundingAmountUSD: 500, // request $500 per onramp
maxDailyFundingUSD: 5000, // hard daily cap
});
autoFunder.start(); // non-blocking; polls balance on an interval| Env / option | Default | Notes |
|---|---|---|
KATANGA_MOONPAY_API_TOKEN |
— | MoonPay Agents API key (server-side only). |
lowBalanceThresholdUSD |
100 |
Balance below which an onramp is triggered. |
fundingAmountUSD |
500 |
Amount requested per onramp. |
maxDailyFundingUSD |
5000 |
Hard cap on total funding per rolling 24h. |
checkIntervalMs |
60000 |
Balance poll interval. |
Funding is async (minutes to hours to settle); the AutoFunder dedupes
pending requests and conservatively skips funding when a balance read fails,
so a transient RPC error never triggers a spurious onramp.
MIT © LEC Group Inc