The deal flow from creation to settlement.
The flow
-
Create a deal — A deal is defined by a set of recipient wallets and the exact amount (in wei) each one receives. The creator can also set a
referrerwallet (to receive Shaka’s automatic 1% creator bonus) and anaffiliatewallet (resolved from a referral link) — both optional, both fixed at creation. The contract returns a deal ID. -
Quote — Before paying, the payer calls
quote(dealId)to get the exactgrandTotal, in wei, to send — the recipient amounts plus the referrer, affiliate, and Shaka fee. -
Pay — The payer sends
grandTotalto the contract’spay()function, referencing the deal ID. -
Route — The contract distributes the recipient amounts, the referrer’s bonus, the affiliate’s share, and Shaka’s fee — all in the same transaction. The transaction is final and irreversible.
A deal can also be cancelled by its creator at any point before it’s paid — after that, it can never be paid.
Key properties
- Single transaction — recipients, referrer, and Shaka are all settled in one
pay()call. If a recipient or the referrer transfer fails, the whole payment reverts. The affiliate is the one exception: if its transfer fails, that share is redirected to Shaka (with a capped gas forward, so a broken affiliate wallet can’t block the deal) and the rest of the payment still settles. - Immutable — the contract cannot be modified after deployment. No admin can change the routing logic or fee rate.
- Permissionless — anyone can create a deal or pay into one. No account required.
- Cancellable, not editable — the creator can cancel an unpaid deal, but nothing about a deal (recipients, amounts, referrer, affiliate) can be changed after creation.
Fee calculation
The fee (routed to the referrer, the affiliate, and Shaka) is added on top of the recipient amounts, not deducted from them — recipients always receive their amounts in full. Rather than computing it yourself, call quote(dealId) to get the exact total to send:
const grandTotal = await shaka.quote(dealId);
await shaka.pay(dealId, { value: grandTotal });
See the Fees page for how grandTotal breaks down between recipients, referrer, affiliate, and Shaka.
Events
Every payment emits a DealPaid event:
event DealPaid(
bytes32 indexed dealId,
address indexed payer,
uint256 referrerAmount,
uint256 affiliateAmount,
uint256 shakaAmount,
uint256 grandTotal
);
Cancelling a deal emits DealCancelled:
event DealCancelled(
bytes32 indexed dealId,
address indexed creator
);