snacktesting
v0.0.1
Published
A CLI tool for sending USDC payments on Twitter and Farcaster using x402.
Maintainers
Readme
🍪 Snack Money API – x402 Example
This repository contains example scripts that demonstrate how to use the Snack Money API to send USDC to any Farcaster or Twitter user — no wallet address required, thanks to the x402 protocol.
Prerequisites
- Node.js v20+ (Install via nvm)
- Yarn v1
- An Ethereum private key to sign and send transactions
Setup
Clone the repository:
git clone https://github.com/snack-money/x402-axios-example.git cd x402-axios-exampleInstall dependencies:
yarn installConfigure environment variables:
cp .env-local .env- Edit
.envand add your Ethereum private key.
- Edit
Single Account Payment
Usage
Send USDC to a single user via Twitter or Farcaster:
yarn pay --receiver_identity <identity_type> --receiver_username <receiver_username> --amount <amount><identity_type>: Eitherfarcasterortwitter<receiver_username>: Receiver’s username (e.g.,0xmesuthere,mesut)<amount>: Amount of USDC to send (e.g.,0.01)
Examples
yarn pay --receiver_identity twitter --receiver_username 0xmesuthere --amount 0.01
yarn pay --receiver_identity farcaster--receiver_username mesut --amount 0.01Batch Payments
Usage
Send USDC to multiple recipients in a single batch:
yarn batch-pay --receiver_identity <identity_type> --receivers '<receivers_json>'<identity_type>:farcasterortwitter<receivers_json>: A JSON array of recipients containingusernameandamount
Examples
yarn batch-pay --receiver_identity farcaster --receivers '[{"username":"lincoln","amount":0.5},{"username":"mesut","amount":0.25}]'
yarn batch-pay --receiver_identity twitter --receivers '[{"username":"MurrLincoln","amount":0.5},{"username":"0xmesuthere","amount":0.25}]'Reward Distribution Creation
Usage
Create a reward distribution order with reward budget:
yarn create-reward-distribution --budget <budget> --platform <platform> --content_id <content_id><budget>: Amount of USDC to send (e.g.,10)<platform>:farcasterortwitter<content_id>: The platform-provided Content ID associated with the content eligible for reward distribution.
Examples
yarn create-reward-distribution --budget 10 --platform farcaster --content_id 0xb87cf233790dd2d8a3ed9549f9e15069c02b1da0Reward Distribution Confirmation
Usage
Confirms and distributes reward budget among participants:
yarn confirm-reward-distribution --order_id <order_id><order_id>: An Order Id obtained from reward distribution creation
Examples
yarn confirm-reward-distribution --order_id x987ASCbjHkNotes
- The identity type must match the platform the user is on.
- Ensure your private key is secure and funded with sufficient USDC.
