# 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": "uint256", "name": "total", "type": "uint256" },
      { "indexed": false, "internalType": "uint256", "name": "grandTotal", "type": "uint256" },
      { "indexed": false, "internalType": "bool", "name": "verificationRequired", "type": "bool" }
    ],
    "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": "shakaAmount", "type": "uint256" },
      { "indexed": false, "internalType": "uint256", "name": "grandTotal", "type": "uint256" }
    ],
    "name": "DealPaid",
    "type": "event"
  },
  {
    "inputs": [
      { "internalType": "bytes32", "name": "dealId", "type": "bytes32" },
      { "internalType": "address", "name": "recipient", "type": "address" },
      { "internalType": "uint256", "name": "amount", "type": "uint256" }
    ],
    "name": "approvalDigest",
    "outputs": [
      { "internalType": "bytes32", "name": "", "type": "bytes32" }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "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": "string", "name": "dealReference", "type": "string" },
      { "internalType": "bool", "name": "verificationRequired", "type": "bool" }
    ],
    "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": "uint256", "name": "total", "type": "uint256" },
      { "internalType": "bool", "name": "paid", "type": "bool" },
      { "internalType": "bool", "name": "cancelled", "type": "bool" },
      { "internalType": "bool", "name": "verificationRequired", "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": "bool", "name": "paid", "type": "bool" },
      { "internalType": "bool", "name": "cancelled", "type": "bool" },
      { "internalType": "bool", "name": "verificationRequired", "type": "bool" },
      { "internalType": "string", "name": "dealReference", "type": "string" }
    ],
    "stateMutability": "view",
    "type": "function"
  },
  {
    "inputs": [
      { "internalType": "bytes32", "name": "dealId", "type": "bytes32" },
      { "internalType": "bytes[]", "name": "signatures", "type": "bytes[]" }
    ],
    "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, dealReference, verificationRequired)`

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 |
| `dealReference` | `string` | Free-form reference stored onchain. It's arbitrary user input — escape it before rendering |
| `verificationRequired` | `bool` | When `true`, every recipient must approve the deal (EIP-712 signature) before it can be paid. When `false`, the deal is payable immediately |

### `pay(dealId, signatures)`

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.

| Param | Type | Description |
|-------|------|-------------|
| `dealId` | `bytes32` | The deal to pay |
| `signatures` | `bytes[]` | Recipient approval signatures. Required only when the deal was created with `verificationRequired = true` — one signature per recipient, each matching [`approvalDigest()`](#approvaldigestdealid-recipient-amount). Pass an empty array for a deal that doesn't require verification |

If a recipient or the referrer transfer fails, the whole payment reverts.

### `approvalDigest(dealId, recipient, amount)`

Returns the `bytes32` digest a recipient signs to approve a deal created with `verificationRequired = true`. The recovered signer must equal the recipient, and the amount must match that recipient's share on the deal, or `pay()` reverts.

### `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 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`, `paid`, `cancelled`, `verificationRequired`, `dealReference`.

### `deals(dealId)`

Public getter for the underlying `deals` mapping. Returns the deal's scalar fields — `creator`, `referrer`, `total`, `paid`, `cancelled`, `verificationRequired`, `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 |