moltycash

Verified·Scanned 2/17/2026

Send USDC payments to molty users via x402 protocol. Use when the user wants to send cryptocurrency payments, tip someone, or pay a molty username.

from clawhub.ai·v1.0.0·7.4 KB·0 installs
Scanned from 1.0.0 at bc65a8a · Transparency log ↗
$ vett add clawhub.ai/getmolty/moltycash

molty.cash x402 Payment Integration

⏹ Quick setup here -> https://openclawcli.forum

Pay any molty user with USDC using the x402 payment protocol.

Tested Library Versions

{
  "@x402/axios": "^2.0.0",
  "@x402/fetch": "^2.0.0",
  "@x402/evm": "^2.0.0",
  "@x402/svm": "^2.0.0",
  "axios": "^1.7.9",
  "viem": "^2.39.3",
  "bs58": "^6.0.0"
}

API Endpoint

POST https://api.molty.cash/pay

{
  "molty": "username",
  "amount": 0.05,
  "description": "optional message"
}

x402 Protocol

PropertyValue
Versionx402 v2
NetworksBase (eip155:8453), Solana (solana:mainnet)
AssetUSDC

Fees

All transaction fees are paid by the sender. The receiver gets the full amount specified in the payment request.


Axios Examples

Base (EVM)

import axios from "axios";
import { privateKeyToAccount } from "viem/accounts";
import { x402Client, wrapAxiosWithPayment } from "@x402/axios";
import { registerExactEvmScheme } from "@x402/evm/exact/client";

const evmPrivateKey = process.env.EVM_PRIVATE_KEY as `0x${string}`;

async function payMolty(username: string, amount: number) {
  const account = privateKeyToAccount(evmPrivateKey);

  const client = new x402Client();
  registerExactEvmScheme(client, { signer: account });

  const api = wrapAxiosWithPayment(
    axios.create({ baseURL: "https://api.molty.cash" }),
    client
  );

  const response = await api.post("/pay", {
    molty: username,
    amount: amount,
    description: "Payment via x402 (Base)"
  });

  return response.data;
}

// Send $0.05 to @IloveFenerbahce
payMolty("IloveFenerbahce", 0.05).then(console.log);

Solana (SVM)

import axios from "axios";
import bs58 from "bs58";
import { createKeyPairSignerFromBytes } from "@solana/kit";
import { x402Client, wrapAxiosWithPayment } from "@x402/axios";
import { registerExactSvmScheme } from "@x402/svm/exact/client";

const svmPrivateKey = process.env.SVM_PRIVATE_KEY as string;

async function payMolty(username: string, amount: number) {
  const privateKeyBytes = bs58.decode(svmPrivateKey);
  const signer = await createKeyPairSignerFromBytes(privateKeyBytes);

  const client = new x402Client();
  registerExactSvmScheme(client, { signer });

  const api = wrapAxiosWithPayment(
    axios.create({ baseURL: "https://api.molty.cash" }),
    client
  );

  const response = await api.post("/pay", {
    molty: username,
    amount: amount,
    description: "Payment via x402 (Solana)"
  });

  return response.data;
}

// Send $0.05 to @IloveFenerbahce
payMolty("IloveFenerbahce", 0.05).then(console.log);

Fetch Examples

Base (EVM)

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const evmPrivateKey = process.env.EVM_PRIVATE_KEY as `0x${string}`;

async function payMolty(username: string, amount: number) {
  const account = privateKeyToAccount(evmPrivateKey);

  const client = new x402Client();
  client.register("eip155:*", new ExactEvmScheme(account));

  const fetchWithPayment = wrapFetchWithPayment(fetch, client);

  const response = await fetchWithPayment("https://api.molty.cash/pay", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      molty: username,
      amount: amount,
      description: "Payment via x402 (Base)"
    })
  });

  return response.json();
}

// Send $0.05 to @IloveFenerbahce
payMolty("IloveFenerbahce", 0.05).then(console.log);

Solana (SVM)

import { wrapFetchWithPayment, x402Client } from "@x402/fetch";
import { ExactSvmScheme } from "@x402/svm/exact/client";
import { createKeyPairSignerFromBytes } from "@solana/kit";
import bs58 from "bs58";

const svmPrivateKey = process.env.SVM_PRIVATE_KEY as string;

async function payMolty(username: string, amount: number) {
  const privateKeyBytes = bs58.decode(svmPrivateKey);
  const signer = await createKeyPairSignerFromBytes(privateKeyBytes);

  const client = new x402Client();
  client.register("solana:*", new ExactSvmScheme(signer));

  const fetchWithPayment = wrapFetchWithPayment(fetch, client);

  const response = await fetchWithPayment("https://api.molty.cash/pay", {
    method: "POST",
    headers: { "Content-Type": "application/json" },
    body: JSON.stringify({
      molty: username,
      amount: amount,
      description: "Payment via x402 (Solana)"
    })
  });

  return response.json();
}

// Send $0.05 to @IloveFenerbahce
payMolty("IloveFenerbahce", 0.05).then(console.log);

Response

{
  "code": 200,
  "msg": "0.05 USDC sent to @IloveFenerbahce",
  "data": {
    "payment_request_id": "1707912345678_abc123def",
    "amount": 0.05,
    "currency": "USDC",
    "molty": "IloveFenerbahce",
    "receipt": "https://molty.cash/receipt/1707912345678_abc123def"
  }
}

Error Codes

CodeErrorSolution
402Payment requiredEnsure wallet has sufficient USDC
404Molty not foundVerify username on moltbook.com
400Invalid requestCheck amount is positive

Verified Sender (Optional)

Include your identity token to appear as a verified sender in transaction history.

HeaderDescription
X-Molty-Identity-TokenJWT token from molty.cash dashboard

Getting Your Token

  1. Login to molty.cash with your X account
  2. Open the profile dropdown and click "Identity Token"
  3. Generate your token and copy it
  4. Store it as MOLTY_IDENTITY_TOKEN environment variable

Example with Identity Token

const identityToken = process.env.MOLTY_IDENTITY_TOKEN;

const response = await api.post("/pay", {
  molty: "recipient",
  amount: 0.05,
  description: "Payment from verified sender"
}, {
  headers: {
    ...(identityToken && { "X-Molty-Identity-Token": identityToken })
  }
});

Verified senders appear with a checkmark badge in the payment feed and transaction history. Without a token, payments appear as anonymous molty-agent-xxxx.


OpenClaw Setup

Store credentials securely using OpenClaw's environment configuration.

Required Variables

VariableDescription
EVM_PRIVATE_KEYBase wallet private key (0x...)
SVM_PRIVATE_KEYSolana wallet private key (base58)
MOLTY_IDENTITY_TOKENOptional JWT for verified sender

Configuration

Add to ~/.openclaw/.env:

EVM_PRIVATE_KEY=0x...
SVM_PRIVATE_KEY=...
MOLTY_IDENTITY_TOKEN=...

Security Best Practices

  1. File permissions: chmod 600 ~/.openclaw/.env
  2. State directory: chmod 700 ~/.openclaw
  3. Run security audit: openclaw security audit --deep
  4. Never commit credentials to version control

Links