From ef905c0f7524d76acb31d13ae3101e4e601d218e Mon Sep 17 00:00:00 2001 From: 0xMosas Date: Thu, 26 Feb 2026 18:09:49 +0100 Subject: [PATCH 1/2] fix(contract): skip fee transfer when fee is zero Guard the fee stx-transfer? call with a check for fee > 0. Previously, setting fee-basis-points to 0 would cause tips to fail because stx-transfer? rejects zero-amount transfers. --- contracts/tipstream.clar | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contracts/tipstream.clar b/contracts/tipstream.clar index 75e2aa32..c56821a4 100644 --- a/contracts/tipstream.clar +++ b/contracts/tipstream.clar @@ -111,7 +111,10 @@ (asserts! (not (default-to false (map-get? blocked-users { blocker: recipient, blocked: tx-sender }))) err-user-blocked) (try! (stx-transfer? net-amount tx-sender recipient)) - (try! (stx-transfer? fee tx-sender (var-get contract-owner))) + (if (> fee u0) + (try! (stx-transfer? fee tx-sender (var-get contract-owner))) + true + ) (map-set tips { tip-id: tip-id } From a20f504c8a2cf001d64ed864a2150c384f936d70 Mon Sep 17 00:00:00 2001 From: 0xMosas Date: Thu, 26 Feb 2026 18:10:03 +0100 Subject: [PATCH 2/2] test: verify zero-fee tipping transfers full amount to recipient Confirm that when fee-basis-points is set to 0, sending a tip produces only one STX transfer event with the full amount going to the recipient and no fee transfer to the contract owner. --- tests/tipstream.test.ts | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/tests/tipstream.test.ts b/tests/tipstream.test.ts index 97baea0a..90de67ed 100644 --- a/tests/tipstream.test.ts +++ b/tests/tipstream.test.ts @@ -420,6 +420,29 @@ describe("TipStream Contract Tests", () => { ); expect(result).toBeErr(Cl.uint(100)); }); + + it("sending a tip with zero fee transfers full amount to recipient", () => { + simnet.callPublicFn( + "tipstream", + "set-fee-basis-points", + [Cl.uint(0)], + deployer + ); + + const { result, events } = simnet.callPublicFn( + "tipstream", + "send-tip", + [Cl.principal(wallet2), Cl.uint(1000000), Cl.stringUtf8("No fee tip")], + wallet1 + ); + + expect(result).toBeOk(Cl.uint(0)); + + const transfers = events.filter(e => e.event === "stx_transfer_event"); + expect(transfers).toHaveLength(1); + expect(transfers[0].data.amount).toBe("1000000"); + expect(transfers[0].data.recipient).toBe(wallet2); + }); }); describe("Batch Tipping", () => {