Real-world integration examples.
Example 1 — Real estate commission split
A real estate deal closing with a listing agent and a buyer’s agent, paid in native ETH. The listing agent’s wallet is set as referrer, so they automatically receive Shaka’s 1% creator bonus on top of their commission — no separate claim needed.
import { ethers } from 'ethers';
const SHAKA_ADDRESS = '0x8eEb3D6053014446cD92C58E233B2a5084E54a1a'; // Ethereum mainnet
async function createCommissionSplit(signer) {
const shaka = new ethers.Contract(SHAKA_ADDRESS, SHAKA_ABI, signer);
const recipients = [
'0xListingAgent...',
'0xBuyerAgent...',
];
const amounts = [
ethers.parseEther('12'), // listing agent's commission
ethers.parseEther('6'), // buyer's agent commission
];
const referrer = '0xListingAgent...'; // gets Shaka's automatic 1% creator bonus
const affiliate = ethers.ZeroAddress; // set from a referral link if there is one
const dealReference = '123 Ocean Ave — commission split';
const tx = await shaka.createDeal(recipients, amounts, referrer, affiliate, dealReference);
const receipt = await tx.wait();
const dealId = receipt.logs[0].args.dealId;
console.log('Deal ID:', dealId);
return dealId;
}
async function payDeal(signer, dealId) {
const shaka = new ethers.Contract(SHAKA_ADDRESS, SHAKA_ABI, signer);
// quote() returns the exact amount to send — recipient amounts plus the
// referrer, affiliate, and Shaka fees. See the Fees page for the breakdown.
const grandTotal = await shaka.quote(dealId);
const payTx = await shaka.pay(dealId, { value: grandTotal });
await payTx.wait();
}
Example 2 — Cancel a deal
Creator-only. Reverts if the deal has already been paid or already cancelled — once cancelled, it can never be paid.
async function cancelDeal(signer, dealId) {
const shaka = new ethers.Contract(SHAKA_ADDRESS, SHAKA_ABI, signer);
const tx = await shaka.cancel(dealId);
await tx.wait();
}
Example 3 — Read deal status
async function checkDeal(provider, dealId) {
const shaka = new ethers.Contract(SHAKA_ADDRESS, SHAKA_ABI, provider);
const [recipients, amounts, creator, referrer, affiliate, paid, cancelled, dealReference] =
await shaka.getDeal(dealId);
return {
recipients,
amounts: amounts.map(a => ethers.formatEther(a)),
creator,
referrer,
affiliate,
paid,
cancelled,
dealReference,
};
}
Example 4 — Listen for DealPaid and DealCancelled events
shaka.on('DealPaid', (dealId, payer, referrerAmount, affiliateAmount, shakaAmount, grandTotal) => {
console.log({
dealId,
payer,
referrerAmount: ethers.formatEther(referrerAmount),
affiliateAmount: ethers.formatEther(affiliateAmount),
shakaAmount: ethers.formatEther(shakaAmount),
grandTotal: ethers.formatEther(grandTotal),
});
});
shaka.on('DealCancelled', (dealId, creator) => {
console.log({ dealId, creator });
});
viem example
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';
const publicClient = createPublicClient({ chain: mainnet, transport: http() });
const deal = await publicClient.readContract({
address: SHAKA_ADDRESS,
abi: SHAKA_ABI,
functionName: 'getDeal',
args: [dealId],
});
const grandTotal = await publicClient.readContract({
address: SHAKA_ADDRESS,
abi: SHAKA_ABI,
functionName: 'quote',
args: [dealId],
});