Security
Where a payment is refused. And what we have not done.
Three separate checks stand between an agent and the money, and each refuses for its own reasons. Everything below names the file or the test behind it, so you can go and disagree with us.
Three keys
Three keys, and what each one cannot do.
Every action on a channel is signed by one of three keys. None of them can do another’s job, none of them can change what the agent signed, and the contract has no admin key that could. Dinara never holds your funds: the deposit sits in the contract, and only its rules move it.
The owner’s wallet
Any EVM wallet you connect. It funds the channel, sets its terms and pays its fees in a stablecoin.
Can
- Open a channel and deposit into it
- Add funds, raise the ceiling or extend the expiry
- Bring expiry forward to five minutes from now, with
requestClose - Reclaim everything if nobody settles within an hour of expiry
Cannot
- Lower a ceiling
- Shorten an expiry, except by that five-minute notice
- Settle or propose before expiry
- Reclaim before the hour of grace has passed, or while a settlement is under dispute
The agent key
A secp256k1 key the owner names when opening the channel. It signs EIP-712 states, not transactions, so it never holds money or pays a fee.
Can
- Sign a new running total for each charge
- Propose a settlement before expiry, open for ten minutes to any state that owes a payee more
Cannot
- End its channel with a state that underpays: a payee’s voucher that owes it more raises the proposal
- Get a state over the ceiling settled
- Pay an address that is not one of the channel’s payees
- Change the deposit, the ceiling or the payees
The operator
An optional metering service the owner names when opening the channel.
Can
- Settle at once with a state the agent signed, when the owner or agent asks
- Challenge a stale proposal with the newest state it holds
Cannot
- Change an amount
- Sign a state of its own
- Overtake a proposal under dispute
- Touch the deposit any other way
Three refusals
Three places can refuse a payment, and none trusts the others.
The SDK refuses before the agent signs. The payee refuses before it serves. The contract refuses before money moves. Each runs its own checks, so a bug in one is not a hole in all three.
The agent’s SDK
A charge the channel would refuse is never signed.
TempoMeterSession.chargechecks each charge against the channel’s terms before it signs: a payee that is not on the list, a charge that would pass the ceiling or what the channel holds, an expired channel, or a token the channel does not hold. An x402 quote above the agent’s ownmaxPrice, or from a payee that does not trust the channel’s operator, is refused before that. It throws aMeterRefusalwith the reason, and nothing exists to settle.In the repository
packages/sdk/src/agent.tspackages/sdk/src/x402.tsThe payee
An API serves only against a voucher it has checked itself.
verifyTempoX402Paymentreads the voucher from x402’sPAYMENT-SIGNATUREand checks it on the payee’s own server, asking Dinara and no facilitator for anything. It recovers the agent’s EIP-712 signature locally and refuses a bad signature, a voucher for another chain, contract, channel or payee, a closed or expired channel, a state over the ceiling, a charge below the price, a channel holding another token, and anything older than, or owing less than, the newest voucher it already accepted. The amount is the agent’s signature, never the client’s copy of the quote.In the repository
packages/sdk/src/payee.tspackages/sdk/src/x402.tsThe contract
Settlement pays what the agent signed, and nothing else.
settlerecovers the agent’s EIP-712 signature over the state itself, under a domain bound to Tempo’s chain id and the contract’s address. It fails withWrongSignerfor any key but the agent’s,MalformedSignaturefor a signature that is not 65 bytes with a lows,CeilingExceededfor a state over the ceiling,LinesMismatchfor a state without one line per payee, andSettlerNotAllowedfor anyone but the operator. Everyone else proposes, and a proposal stays open to any state that owes a payee more.In the repository
contracts/src/DinaraChannels.sol
No layer trusts the answer of the one before it. The contract checks the ceiling again although the SDK already did, because a payee can be handed a state that never went through the SDK.
The path of a paid call
Five steps between a call and a payment.
The API names a price and the agent signs for it. Three of the five steps can refuse on their own, and none of them takes the previous one’s word for anything. Refusing is not an error, which is why one of the two endings is amber and neither is red.
Five stages in order, then two endings. The third, fourth and fifth stages can each refuse on their own, and no stage trusts the answer of the one before it.
The call
The agent calls an API through
tempoPayingFetch, the way it would callfetch.Refuses nothing. Nothing has been asked for yet.
The 402
The API answers 402 Payment Required, with its price, address and token in x402’s
PAYMENT-REQUIRED.Refuses nothing. It only names a price.
The SDK
The agent’s session checks the charge against the channel, signs a new running total with EIP-712 and retries with it in
PAYMENT-SIGNATURE.Refuses an unknown payee, a charge over the ceiling, an expired channel. Nothing signed.
The payee
verifyTempoX402Paymentchecks the voucher on the API’s own server and keeps the newest one. Then the API serves, withPAYMENT-RESPONSE.Refuses a bad signature, an underpaid or a stale voucher, or one that lowers another payee’s line. Not served.
The contract
At the end, one settlement carries the newest signed state to the contract on Tempo.
Refuses a wrong signer, a state over the ceiling, a line for anyone but the payees. No money moved.
Two endings
- Paid
$39.99 to three payees, in one transaction.
The receipt records what each payee’s balance gained and what came back to the owner, so the figures written down are the figures that moved.
- Refused
Nothing signed, nothing owed.
Each refusal carries its reason: a
MeterRefusalfrom the SDK, a reason fromverifyTempoX402Payment, or the contract’s own custom error. None of them leaves a payment half done.
Enforced on chain
The rules the contract enforces.
Each rule is checked by the contract that holds the deposit, and each has a test that it holds and a test that breaking it is refused with its exact custom error. The names under each rule are Foundry tests in contracts/test.
- The ceiling is funded
- A ceiling is never more than the deposit the contract measured, so every metered dollar exists. Opening a channel with a ceiling above its deposit, or raising one above it later, fails with
InvalidCeiling.test_refusesAZero Ceiling Or One Above The Deposit test_neverRaises The Ceiling Above The Deposit - Terms only widen
topUpadds funds, raises the ceiling or extends the expiry, and nothing else. A lower ceiling isCeilingLowered; an earlier expiry isExpiryShortened. Ending early goes throughrequestClose, which leaves five minutes to settle.test_neverLowers ACeiling Or Shortens An Expiry test_pullsThe Expiry In To The Close Notice - Only the agent’s signature counts
- Every state is an EIP-712 signature the contract recovers itself. A state signed by any other key, or changed after signing, is
WrongSigner; one signed for another channel isWrongChannel; and a signature that is not 65 bytes, low-s, with avof 27 or 28 isMalformedSignature.test_refusesAState Signed By Any Key But The Agents test_refusesAState Signed For Another Channel test_refusesThe Malleated High SForm Of AValid Signature - Never over the ceiling
- A state whose total is above the ceiling is
CeilingExceeded, even one the agent signed, and one above what the channel holds isInsufficientBalance.test_refusesAState Over The Ceiling Even One The Agent Signed testFuzz_refuses Every State Above The Ceiling - Only the channel’s payees
- A state carries exactly one line per payee, in the order the owner named them, and its lines add up to its total. Anything else is
LinesMismatchorTotalMismatch, so a settlement can pay nobody else.test_refusesAState Without Exactly One Line Per Payee test_refusesAState Whose Lines Do Not Add Up To Its Total - Only the operator settles at once
settleis the operator’s alone; anyone else isSettlerNotAllowed, the agent included, before or after expiry. Everyone else usesproposeSettlement: the agent or operator before expiry, anyone after, so a payee is never stuck behind a silent agent.test_letsNobody But The Operator Settle At Once Even After Expiry test_letsAnyone Propose After Expiry So APayee Is Never Stuck Behind ASilent Agent - A stale state cannot end a channel
- A proposal stays open for ten minutes. Anyone holding an agent-signed state that owes some payee more raises that payee’s line with
challengeSettlement; one that owes nobody more isStaleState, whatever sequence number the agent signed. Only when the window closes can anyonefinalizeSettlement, and the owner cannot reclaim while it runs (DisputeInProgress).test_refusesAChallenge That Raises No Payees Line However High Its Seq test_mergesTwo Incompatible Histories To Each Payees Maximum test_neverReclaims While ASettlement Is Under Dispute - A merge never pays out more than there is
- When the merged lines of a dispute owe more than the ceiling or the balance,
finalizeSettlementscales every line down pro rata, rounding down, and refunds the rest to the owner.test_scalesAMerge That Owes More Than The Ceiling Down Pro Rata And Refunds The Rest testFuzz_scaling Is Pro Rata Floored And Within The Cap - An hour of grace, then the owner
- If nobody settles within an hour of expiry,
reclaimreturns everything to the owner. Before then it fails withGraceNotOver.test_returnsEverything Once The Grace Period Has Passed And Not Before - Measured, not claimed
- Every payout and refund is measured from balances before and after it, and the receipt stores what each payee actually received, the refund, how many charges were metered and the head of their hash chain. A transfer that leaves the payee with less, or the contract with more, fails with
TransferFailed.test_paysEach Payee Its Line Refunds The Rest And Writes AMeasured Receipt test_recordsWhat Each Payee And The Owner Really Received From AFee On Transfer Token test_refusesAPayout That Leaves The Payee With Less - One channel never spends another’s money
- One contract holds every deposit, and it accounts each channel’s share on its own. A settlement that would cost the contract more than its own channel holds, whatever the token does, fails with
TransferFailedand moves nothing.test_numbersChannels From One And Keeps Their Money Apart test_neverLets AToken That Takes More From The Sender Spend Another Channels Money invariant_holdsExactly What Every Channel Holds - No way back in
- Every function that changes state is guarded, so a token or payee that calls back into the contract during a payout is refused with
Reentrancy.test_refusesASecond Settlement From Inside APayout test_refusesEvery Other Entry Point While Locked - Exactly once
- A channel ends in one receipt. A second settlement, or a settlement after a reclaim, fails with
ChannelNotOpen.test_settlesExactlyOncetest_cannotSettle Propose Or Reclaim Again Once Reclaimed
The contract is deployed on Tempo mainnet at 0x98C00995Fb264305Dd1065Ed3E7B62aC7003B733 Open on Tempo’s explorer
Stated plainly
What is not true yet.
This is the half that usually gets left off. It is here at the same size as everything above it, because a page about what refuses a payment is not worth reading if it is quiet about what does not.
A payee has to answer within the window
A stale proposal is only raised if someone holding a state that owes more challenges it within ten minutes. Dinara’s operator does so for the vouchers it has seen; a payee that keeps its vouchers to itself has to watch for proposals. Ten minutes suits a demo with small amounts; a deployment holding larger sums would use hours.
Payees trust the operator they accept
The operator settles at once, without a window, with a state the agent signed. It cannot change an amount, but it could pick an older state, so a payee should only serve channels whose operator it trusts: the SDK’s
verifyTempoPaymenttakestrustedOperators, thedinararequirement names them so an agent refuses before it signs, and the demo APIs accept only Dinara’s. A channel with no operator always settles through the window.Payees must keep their newest voucher
The newest voucher is all a payee needs to be paid, and nobody holds it on its behalf. The app keeps a log of the vouchers its demo APIs accept, but that log is a convenience for the screen, not a guarantee: a payee that loses its newest voucher can only settle for less.
Real money, so keep it small
This deployment runs on Tempo mainnet and holds real USDC.e, USDC bridged to Tempo. Because nothing here has been audited, the app takes at most $100.00 per channel; the contract itself has no cap. Dinara never holds your funds: the deposit sits in the contract until a settlement or a reclaim pays it out. The app never makes a wallet for you here, so no key that holds real money is ever kept in your browser.
Nobody outside this project has reviewed it
There has been no independent security review. The tests were written beside the code by the people who wrote the code, which is the arrangement least likely to find what the author did not think of. Read the contract as unaudited work, because that is what it is.
If a claim on this page is not backed by a file you can open or a test you can run, it should not be here. Report a security issue to the 71Labs team where you found this project.