Skill: koba42corp/chia-splitxch (version 1.0.0)

--- name: splitxch description: Create SplitXCH royalty split addresses from plain language descriptions. Use when the user wants to split XCH payments, royalties, or revenue between multiple recipients. Triggers on "split royalties", "royalty split", "splitxch", "split XCH between", "revenue share", "payment split", "basis points split", or any request to divide Chia payments among wallets. Supports nested/cascading splits for complex hierarchies and 128+ recipients. --- # SplitXCH Royalty Split Builder Create complex XCH royalty distribution addresses from natural language descriptions. ## How It Works SplitXCH creates special Chia blockchain addresses that automatically split incoming payments to multiple recipients based on configured percentages. The API computes a puzzle address; any XCH sent to that address gets distributed automatically on-chain. ## Workflow 1. Parse the user's plain-language split description into recipients with percentages 2. Convert percentages to basis points (scale to 9850 total, API adds 150 bps / 1.5% fee) 3. For nested splits (splits-of-splits), build bottom-up: create leaf splits first, then use their addresses as recipients in parent splits 4. Call the SplitXCH API via `scripts/splitxch.sh` or direct curl 5. Return the generated split address and a summary ## Basis Points Conversion - 10,000 bps = 100%. API fee = 150 bps (1.5%). Recipients get 9,850 bps total. - Formula: `points = round(percentage / 100 * 9850)` - Adjust last recipient so points sum to exactly 9850. Example: "Split 60/40 between Alice and Bob" - Alice: round(0.60 * 9850) = 5910 - Bob: 9850 - 5910 = 3940 ## Building the API Payload ```json { "recipients": [ {"name": "Alice", "address": "xch1...", "points": 5910, "id": 1}, {"name": "Bob", "address": "xch1...", "points": 3940, "id": 2} ] } ``` Save to a temp file and run: ```bash bash <skill_dir>/scripts/splitxch.sh /tmp/split-payload.json ``` ## Nested Splits (>128 recipients or hierarchies) When the user describes groups within groups: 1. Create each leaf-level split first via the API 2. Use the returned `address` as a recipient in the parent split 3. Each split level incurs its own 150 bps fee Example: "Team A (Alice 50%, Bob 50%) gets 70%, Charlie gets 30%" 1. Create Team A split: Alice 4925 + Bob 4925 = 9850 → returns `xch1teamA...` 2. Create parent split: TeamA address 6895 + Charlie 2955 = 9850 ## Validation Rules - All addresses must start with `xch1` and be valid bech32m - Max 128 recipients per split - All addresses unique within a split - Each recipient's points > 0 - Points must sum to exactly 9850 ## Output Format After creating a split, present: 1. **Split Address**: The generated `xch1...` address 2. **Summary Table**: Each recipient's name, address (truncated), and percentage 3. **Fee Note**: "SplitXCH takes a 1.5% platform fee per split level" 4. **Usage**: "Send XCH to this address and it will automatically distribute to all recipients" If nested, show the full tree structure. ## API Reference For detailed API docs, validation rules, and error handling, see [references/api.md](references/api.md). ## Important Notes - The user MUST provide valid XCH wallet addresses for all recipients. If addresses are missing, ask for them before calling the API. - If the user only provides names and percentages without addresses, list what's needed and ask. - For dry runs / previews, show the calculated basis points without calling the API.

path: references/api.md
content: # SplitXCH API Reference

## POST https://splitxch.com/api/compute/fast

Create a split address from recipients. Returns the computed XCH address.

### Request
```json
{
  "recipients": [
    {
      "name": "Artist",
      "address": "xch1...",
      "points": 4925,
      "id": 1
    },
    {
      "name": "Manager",
      "address": "xch1...",
      "points": 4925,
      "id": 2
    }
  ]
}
```

### Key Rules
- **Basis points**: 10,000 = 100%. Platform fee is 150 bps (1.5%).
- Recipient points must sum to **9,850** (10,000 minus 150 fee).
- Up to **128 recipients** per split. For more, use cascading splits.
- All addresses must be valid XCH addresses (start with `xch1`).
- All addresses must be unique within a single split.
- Each recipient's points must be > 0.

### Response
```json
{
  "id": "66f21c17eb854b8fab7327280ac5eb21",
  "message": "Saved",
  "pctProgress": 100,
  "address": "xch1q3ge2z5g5fsk4ckkunmszwlhpcmgns7c5y5gwku86tdsa4wfhg6qszeuzg"
}
```

### Errors
HTTP 400 with `message` field describing the validation failure.

## GET https://splitxch.com/api/compute/{id}

Check status of a previously created split.

### Response
```json
{
  "address": "xch1...",
  "error": false,
  "id": "...",
  "message": "Complete",
  "pctProgress": 100
}
```

## Cascading Splits (Nested)

For >128 recipients or complex hierarchies, create splits-of-splits:
1. Create leaf splits first (bottom-up)
2. Use the returned split addresses as recipients in parent splits
3. Each level has its own 150 bps fee

## Basis Points Math

| Percentage | Basis Points (of 9850) |
|-----------|----------------------|
| 50%       | 4925                 |
| 25%       | 2462 or 2463         |
| 10%       | 985                  |
| 5%        | 492 or 493           |
| 1%        | 98 or 99             |

Formula: `points = round(percentage / 100 * 9850)`

When rounding causes the sum to not equal 9850, adjust the last recipient.


path: scripts/splitxch.sh
content: #!/bin/bash
# SplitXCH API wrapper - creates a split address from a JSON payload
# Usage: splitxch.sh <json-file-or-stdin>
# Input: JSON with "recipients" array [{name, address, points, id}]
# Points must sum to 9850 (API adds 150 bps fee)

set -euo pipefail

API_URL="https://splitxch.com/api/compute/fast"

if [ -n "${1:-}" ] && [ -f "$1" ]; then
  PAYLOAD=$(cat "$1")
else
  PAYLOAD=$(cat -)
fi

# Validate JSON has recipients
if ! echo "$PAYLOAD" | jq -e '.recipients' >/dev/null 2>&1; then
  echo "Error: JSON must contain 'recipients' array" >&2
  exit 1
fi

# Validate points sum to 9850
TOTAL=$(echo "$PAYLOAD" | jq '[.recipients[].points] | add')
if [ "$TOTAL" != "9850" ]; then
  echo "Error: Recipient points sum to $TOTAL, must be 9850 (10000 - 150 fee)" >&2
  exit 1
fi

# Call API
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST "$API_URL" \
  -H "Content-Type: application/json" \
  -d "$PAYLOAD")

HTTP_CODE=$(echo "$RESPONSE" | tail -1)
BODY=$(echo "$RESPONSE" | sed '$d')

if [ "$HTTP_CODE" != "200" ]; then
  echo "API Error (HTTP $HTTP_CODE): $BODY" >&2
  exit 1
fi

echo "$BODY" | jq .


Security scan verdicts — ClawScan: clean | static analysis: clean | VirusTotal: suspicious | SkillSpector: suspicious (HIGH)