A Solana-based Web3 workflow automation system supporting price monitoring, token swapping, DeFi operations, and more.
- Price Triggers - Monitor token prices and auto-trigger when targets are met
- Jupiter Swap - Automated token swapping
- Kamino Integration - Auto deposit/withdraw from Kamino vaults
- Visual Workflows - JSON configuration for easy operation chaining
- Telegram Notifications - Real-time workflow execution updates
- Type Safety - Full TypeScript support
- Modular Design - Easy to extend with new node types
npm installCreate a keypair.json file (or use an existing wallet file)
See TELEGRAM_SETUP.md for detailed Telegram notification setup.
Quick setup:
# Copy configuration file
cp .env.example .env
# Edit .env and fill in your Telegram Bot Token and Chat ID
# TELEGRAM_BOT_TOKEN=your_bot_token
# TELEGRAM_CHAT_ID=your_chat_id
# TELEGRAM_NOTIFY_ENABLED=trueEdit workflows/price-trigger-swap.json:
{
"nodes": [
{
"id": "priceFeed1",
"name": "Monitor SOL Price",
"type": "pythPriceFeed",
"parameters": {
"priceId": "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
"targetPrice": "100",
"condition": "above"
}
},
{
"id": "swap1",
"name": "Execute Swap",
"type": "jupiterSwap",
"parameters": {
"inputMint": "USDC_ADDRESS",
"outputMint": "SOL_ADDRESS",
"amount": "10"
}
}
],
"connections": {
"priceFeed1": {
"main": [[{ "node": "swap1", "type": "main", "index": 0 }]]
}
}
}npm run workflowOr specify a workflow file:
npm run workflow ./workflows/your-workflow.jsonMonitors token prices and triggers subsequent nodes when target price is reached.
Parameters:
priceId: Pyth price feed IDtargetPrice: Target price to triggercondition:above|below|equaltimeout: Timeout in seconds
Telegram Notifications: Enabled
Executes token swaps using Jupiter aggregator.
Parameters:
inputMint: Input token addressoutputMint: Output token addressamount: Amount to swap (human-readable)slippageBps: Slippage tolerance in basis points
Telegram Notifications: Enabled
Deposits or withdraws tokens from Kamino vaults.
Parameters:
operation:deposit|withdrawvaultAddress: Vault addressamount: AmountshareAmount: Share amount (for withdrawals)
Telegram Notifications: Enabled
Featured Node - Enables micropayment-based API access using the x402 protocol with Solana USDC payments.
X402 is a payment protocol that enables pay-per-use access to APIs and content. Instead of monthly subscriptions, you pay tiny amounts (like $0.0001) for each request. This is perfect for:
- AI/LLM APIs - Pay per query instead of monthly fees
- Premium Data APIs - Access expensive data feeds only when needed
- Gated Content - Unlock specific content with micropayments
- Machine-to-Machine Payments - Automated payments between services
Client Request → 402 Payment Required → Create Signed Transaction
↓ ↓
Content Delivered ← Transaction Confirmed ← Retry with Payment
- Initial Request: Node requests content from target URL
- 402 Response: Server returns payment requirements (amount, recipient, token)
- Create Transaction: Node creates Solana SPL Token transfer transaction
- Sign & Encode: Transaction is signed with your keypair and base64-encoded
- Retry with Proof: Request retried with
X-Paymentheader containing transaction - Server Validates: Server validates transaction, submits to blockchain
- Content Delivered: After confirmation, server returns the protected content
| Parameter | Type | Default | Description |
|---|---|---|---|
targetUrl |
string | http://localhost:3001/api/x402/premium |
URL of the x402-protected endpoint |
network |
options | devnet |
Solana network: devnet or mainnet |
keypairPath |
string | ./pay-in-usdc/client.json |
Path to wallet keypair JSON file for payment |
maxPaymentAmount |
string | 1.0 |
Maximum USDC willing to pay (safety limit) |
tokenMint |
string | (auto) | Token mint address (defaults to USDC for network) |
rpcEndpoint |
string | (auto) | Custom RPC endpoint (uses public if empty) |
method |
options | GET |
HTTP method: GET or POST |
requestBody |
string | "" |
JSON request body for POST requests |
Scenario 1: AI Query with Payment
{
"nodes": [
{
"id": "aiQuery",
"name": "Ask AI Question",
"type": "x402Payment",
"parameters": {
"targetUrl": "http://localhost:3001/api/x402/query",
"network": "devnet",
"keypairPath": "./keypair.json",
"maxPaymentAmount": "0.001",
"method": "POST",
"requestBody": "{\"query\": \"What is the current price of SOL?\"}"
}
}
]
}Scenario 2: Conditional Premium Data Access
{
"nodes": [
{
"id": "priceTrigger",
"type": "pythPriceFeed",
"parameters": {
"priceId": "0xef0d8b6fda2ceba41da15d4095d1da392a0d2f8ed0c6c7bc0f4cfac8c280b56d",
"targetPrice": "150",
"condition": "above"
}
},
{
"id": "premiumData",
"type": "x402Payment",
"parameters": {
"targetUrl": "https://api.example.com/premium/analysis",
"network": "mainnet",
"keypairPath": "./keypair.json",
"maxPaymentAmount": "0.1"
}
}
],
"connections": {
"priceTrigger": {
"main": [[{ "node": "premiumData", "type": "main", "index": 0 }]]
}
}
}The repository includes a complete x402 server implementation:
- Service:
backend/src/x402/x402.service.ts- Payment validation and blockchain interaction - Controller:
backend/src/x402/x402.controller.ts- Example endpoints - Demo Endpoints:
GET /api/x402/premium- Premium content (0.0001 USDC)POST /api/x402/query- AI query service (0.00005 USDC)GET /api/x402/info- Public endpoint info
- Amount Validation: Server validates exact payment amount
- Transaction Simulation: Tests transaction before submission
- Recipient Verification: Ensures payment goes to correct account
- Safety Limits: Client-side maximum payment protection
- Balance Checks: Verifies sufficient funds before payment
- Blockchain Confirmation: Waits for transaction confirmation
Successful execution returns:
{
"success": true,
"operation": "x402-payment",
"paymentRequired": true,
"data": { /* API response data */ },
"paymentDetails": {
"signature": "5j7s...",
"amountUSDC": 0.0001,
"explorerUrl": "https://explorer.solana.com/tx/...",
"network": "solana-devnet",
"confirmed": true
}
}Telegram Notifications: Enabled - Notifies payment amount, status, and explorer link
The system sends Telegram notifications at the following times:
- Workflow Start - When workflow begins
- Node Execution - When nodes complete (only nodes with
telegramNotify: true) - Execution Failure - When errors occur
- Workflow Complete - When workflow finishes
See TELEGRAM_SETUP.md for detailed setup instructions.
[Price Monitor] → [Swap USDC → SOL] → [Swap SOL → USDC] → [Calculate Profit]
[Price Monitor] → [Buy Token] → [Deposit to Kamino for Yield]
[Price Monitor (below 90)] → [Sell Token] → [Convert to Stablecoin]
[Price Monitor] → [X402: AI Market Analysis] → [Decision Node] → [Execute Trade]
Use X402 to access premium AI analysis APIs only when needed. Pay $0.0001 per query instead of monthly subscriptions. Perfect for strategies that don't need constant AI input.
[Event Trigger] → [X402: Premium Data API] → [Validate Data] → [Execute Strategy]
Access expensive data feeds (options data, whale alerts, sentiment analysis) only when specific conditions are met, minimizing API costs while maintaining strategy effectiveness.
See WORKFLOW_GUIDE.md for the complete usage guide.
src/
├── nodes/ # All node implementations
│ ├── PriceFeedNode.ts
│ ├── SwapNode.ts
│ └── KaminoNode.ts
├── utils/ # Reusable utility functions
│ ├── price-monitor.ts
│ ├── jupiter-swap.ts
│ └── token.ts
├── workflow-executor.ts # Workflow execution engine
├── run-workflow.ts # Run script
└── web3-workflow-types.ts # Type definitions
workflows/ # Workflow configuration files
└── price-trigger-swap.json
- Create a new file
src/nodes/YourNode.ts - Implement the
INodeTypeinterface - Register it in
src/run-workflow.ts
import { YourNode } from './nodes/YourNode';
executor.registerNodeType('yourNode', YourNode);# Development mode (auto-restart)
npm run dev
# Type checking
npm run type-check
# Build
npm run build- Testing: Always test on devnet first
- Security: Never commit
keypair.jsonto Git - RPC Limits: Consider using paid RPC endpoints
- Amounts: All amounts use human-readable format (not smallest units)
MIT