# Contract ABI

Full ABI for the Shaka smart contract.

---

## ABI

```json
[
  {
    "inputs": [],
    "name": "ReentrancyGuardReentrantCall",
    "type": "error"
  },
  {
    "inputs": [
      { "internalType": "bytes32", "name": "slot", "type": "bytes32" },
      { "internalType": "address", "name": "recipient", "type": "address" },
      { "internalType": "uint256", "name": "amount", "type": "uint256" }
    ],
    "name": "TransferFailed",
    "type": "error"
  },
  {
    "anonymous": false,
    "inputs": [
      { "indexed": true, "internalType": "bytes32", "name": "dealId", "type": "bytes32" },
      { "indexed": true, "internalType": "address", "name": "creator", "type": "address" }
    ],
    "name": "DealCancelled",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      { "indexed": true, "internalType": "bytes32", "name": "dealId", "type": "bytes32" },
      { "indexed": true, "internalType": "address", "name": "creator", "type": "address" },
      { "indexed": true, "internalType": "address", "name": "referrer", "type": "address" },
      { "indexed": false, "internalType": "address", "name": "affiliate", "type": "address" },
      { "indexed": false, "internalType": "uint256", "name": "total", "type": "uint256" },
      { "indexed": false, "internalType": "uint256", "name": "grandTotal", "type": "uint256" }
    ],
    "name": "DealCreated",
    "type": "event"
  },
  {
    "anonymous": false,
    "inputs": [
      { "indexed": true, "internalType": "bytes32", "name": "dealId", "type": "bytes32" },
      { "indexed": true, "internalType": "address", "name": "payer", "type": "address" },
      { "indexed": false, "internalType": "uint256", "name": "referrerAmount", "type": "uint256" },
      { "indexed": false, "internalType": "uint256", "name": "affiliateAmount", "type": "uint256" },
      { "indexed": false, "internalType": "uint256", "name": "shakaAmount", "type": "uint256" },
      { "indexed": false, "internalType": "uint256", "name": "grandTotal", "type": "uint256" }
    ],
    "name": "DealPaid",
    "type": "event"
  },
  {
    "inputs": [
      { "internalType": "bytes32", "name": "dealId", "type": "bytes32" }
    ],
    "name": "cancel",
    "outputs": [],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      { "internalType": "address[]", "name": "recipients", "type": "address[]" },
      { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" },
      { "internalType": "address", "name": "referrer", "type": "address" },
      { "internalType": "address", "name": "affiliate", "type": "address" },
      { "internalType": "string", "name": "dealReference", "type": "string" }
    ],
    "name": "createDeal",
    "outputs": [
      { "internalType": "bytes32", "name": "dealId", "type": "bytes32" }
    ],
    "stateMutability": "nonpayable",
    "type": "function"
  },
  {
    "inputs": [
      { "internalType": "bytes32", "name": "", "type": "bytes32" }
    ],
    "name": "deals",
    "outputs": [
      { "internalType": "address", "name": "creator", "type": "address" },
      { "internalType": "address", "name": "referrer", "type": "address" },
      { "internalType": "address", "name": "affiliate", "type": "address" },
      { "internalType": "uint256", "name": "total", "type": "uint256" },
      { "internalType": "bool", "name": "paid", "type": "bool" },
      { "internalType": "bool", "name": "cancelled", "type": "bool" },
      { "internalType": "string", "name": "dealReference", "type": "string" }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      { "internalType": "bytes32", "name": "dealId", "type": "bytes32" }
    ],
    "name": "getDeal",
    "outputs": [
      { "internalType": "address[]", "name": "recipients", "type": "address[]" },
      { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" },
      { "internalType": "address", "name": "creator", "type": "address" },
      { "internalType": "address", "name": "referrer", "type": "address" },
      { "internalType": "address", "name": "affiliate", "type": "address" },
      { "internalType": "bool", "name": "paid", "type": "bool" },
      { "internalType": "bool", "name": "cancelled", "type": "bool" },
      { "internalType": "string", "name": "dealReference", "type": "string" }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      { "internalType": "bytes32", "name": "dealId", "type": "bytes32" }
    ],
    "name": "pay",
    "outputs": [],
    "stateMutability": "payable",
    "type": "function"
  },
  {
    "inputs": [
      { "internalType": "bytes32", "name": "dealId", "type": "bytes32" }
    ],
    "name": "quote",
    "outputs": [
      { "internalType": "uint256", "name": "grandTotal", "type": "uint256" }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "stateMutability": "payable",
    "type": "receive"
  }
]
```

## Function reference

### `createDeal(recipients, amounts, referrer, affiliate, dealReference)`

Creates a new deal onchain. Returns a `bytes32` deal ID.

| Param | Type | Description |
|-------|------|-------------|
| `recipients` | `address[]` | Wallet addresses to receive funds |
| `amounts` | `uint256[]` | Amount each recipient receives, in wei — must be the same length as `recipients` |
| `referrer` | `address` | Wallet that receives Shaka's automatic 1% creator bonus. Use `address(0)` if there isn't one |
| `affiliate` | `address` | Wallet resolved from a referral link. Use `address(0)` if there isn't one — fixed at creation and can't be changed afterward |
| `dealReference` | `string` | Free-form reference stored onchain. It's arbitrary user input — escape it before rendering |

### `pay(dealId)`

Pays a deal in native ETH. `msg.value` must equal the value returned by [`quote(dealId)`](#quotedealid) — call `quote()` right before paying to get the exact figure. If a recipient or the referrer transfer fails, the whole payment reverts; if the affiliate transfer fails, its share is redirected to Shaka instead (with a capped gas forward, to prevent a griefing affiliate from blocking the deal) and the rest of the payment still settles.

### `cancel(dealId)`

Cancels a deal. Creator-only — reverts if the deal is already paid or already cancelled. Once cancelled, a deal can no longer be paid. Note this can race a pending `pay()`: if a buyer's transaction is in flight when `cancel()` lands first, the `pay()` call reverts and the buyer is never charged.

### `quote(dealId)`

Returns the exact `grandTotal`, in wei, to send as `msg.value` to `pay()` — the sum of the recipient amounts plus the referrer, affiliate, and Shaka fee. See the [Fees](/docs/fees) page for how that total is broken down. Reverts if the deal is already paid or cancelled.

### `getDeal(dealId)`

Returns the full deal configuration and status: `recipients`, `amounts`, `creator`, `referrer`, `affiliate`, `paid`, `cancelled`, `dealReference`.

### `deals(dealId)`

Public getter for the underlying `deals` mapping. Returns the deal's scalar fields — `creator`, `referrer`, `affiliate`, `total`, `paid`, `cancelled`, `dealReference` — but not the `recipients` / `amounts` arrays. Use `getDeal()` when you need those.

## Errors

| Error | Thrown when |
|-------|-------------|
| `ReentrancyGuardReentrantCall()` | A reentrant call is detected during `pay()` |
| `TransferFailed(slot, recipient, amount)` | A required ETH transfer (a recipient or the referrer) failed, reverting the whole payment |