> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xenarch.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Smart Contract

> XenarchSplitter smart contract — non-custodial USDC payment splitter on Base L2 for x402 micropayments. Verifiable on Basescan, 0% fee.

The XenarchSplitter is a minimal Solidity contract that splits incoming USDC payments between content publishers and the Xenarch treasury. It is the single settlement mechanism for all Xenarch payments.

## Deployments

| Network          | Address                                                                                                                         | USDC                                                |
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------- |
| **Base Mainnet** | [`0xC6D3a6B6fcCD6319432CDB72819cf317E88662ae`](https://basescan.org/address/0xC6D3a6B6fcCD6319432CDB72819cf317E88662ae)         | `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`        |
| **Base Sepolia** | [`0x7ecfe8f83eab6ba170063d1f1fe7c33695a9ce1d`](https://sepolia.basescan.org/address/0x7ecfe8f83eab6ba170063d1f1fe7c33695a9ce1d) | `0xc5aDdd66Da733101A5468857Aa3C6689Af9d1DDc` (mock) |

Both contracts are verified on Basescan.

## How it works

1. Agent approves USDC on the splitter contract
2. Agent calls `split(collector, amount)` where `collector` is the publisher's wallet
3. Contract calculates fee: `fee = (amount * feeBps) / 10_000`
4. Contract transfers `amount - fee` to publisher, `fee` to treasury
5. Contract emits a `Split` event with payer, collector, amount, and fee

## Key properties

| Property        | Value                                                      |
| --------------- | ---------------------------------------------------------- |
| **Fee**         | 0% (currently), capped at 0.99% forever                    |
| **Max payment** | \$1.00 (1,000,000 USDC satoshis)                           |
| **Min payment** | \$0.000001 (1 USDC satoshi)                                |
| **Fee cap**     | `MAX_FEE_BPS = 99` — immutable constant, cannot be changed |
| **Pausable**    | Owner can pause splits for emergencies                     |
| **USDC only**   | Hardcoded to USDC on Base                                  |

## Security

* **Immutable fee cap**: The `MAX_FEE_BPS` constant cannot be changed after deployment. Publishers are guaranteed fees will never exceed 0.99%.
* **SafeERC20**: Uses OpenZeppelin's SafeERC20 for all USDC transfers.
* **No reentrancy risk**: No external calls before state changes.
* **Verified source**: Bytecode published and verified on Basescan.
* **Minimal surface**: 57 lines of Solidity. Single responsibility.

## Building from source

```bash theme={null}
# Install Foundry
curl -L https://foundry.paradigm.xyz | bash
foundryup

# Clone and build
git clone https://github.com/xenarch-ai/xenarch-contract
cd xenarch-contract
forge build

# Run tests
forge test -vvv
```
