Reference
Post conditions
Some Decast calls move assets. Apps should send every call in
deny mode.- Limit senders, not recipients. Post conditions bound what each principal gives away. Who receives it is fixed by the contract.
- Deny mode aborts the transaction if any asset moves that isn't covered by a condition.
- Snippets use
Pcfrom@stacks/transactions, matching Decast Alpha.
decast-postx
mode: denyThe wallet pays fees plus the deposit. Outside the prepare phase the user contract also locks STX through PoX.
| Sender | Condition | Amount | Asset |
|---|---|---|---|
| Owner wallet | sends ≤ | fees + deposit | uSTX |
| User contract | locks = | new stake amount (outside prepare only) | uSTX (lock) |
- fees = protocol-fee-ustx + interface fee-ustx + charity-amount-ustx (referral is paid out of the interface fee).
- deposit = amount-to-stack, or 0 in the prepare phase.
- Stake amount is read after the deposit: already stacking → locked + unlocked + deposit (stake-update); not stacking → unlocked + deposit (stake).
- In the prepare phase there is no lock condition.
typescript
import { Pc } from "@stacks/transactions";
const deposit = inPrepare ? 0n : amountToStack;
const pcs = [Pc.principal(wallet).willSendLte(feesTotal + deposit).ustx()];
if (!inPrepare) {
const unlockedAfter = contractUnlocked + deposit;
const stake = contractLocked > 0n ? contractLocked + unlockedAfter : unlockedAfter;
pcs.push(Pc.principal(userContract).willSendEq(stake).ustxToLock());
}
// postConditionMode: "deny"decast-boostx
mode: denyThe booster's wallet pays fees in STX and sends the boost asset straight to the author and/or current post nft owner.
| Sender | Condition | Amount | Asset |
|---|---|---|---|
| Owner wallet | sends ≤ | fees (+ amount if STX boost) | uSTX |
| Owner wallet | sends ≤ | amount (SIP-010 boost) | the FT |
| Owner wallet | sends | token id (SIP-009 boost) | the NFT |
- Unsold post: the full amount goes to the author. Sold post: 25% author, 75% current owner. NFTs go to the owner.
- The FT and NFT conditions follow the contract's pay-author-and-or-owner.
typescript
// STX boost
[Pc.principal(wallet).willSendLte(feesTotal + amount).ustx()]
// SIP-010 boost
[Pc.principal(wallet).willSendLte(feesTotal).ustx(),
Pc.principal(wallet).willSendLte(amount).ft("SP...token-contract", "token-name")]
// SIP-009 boost
[Pc.principal(wallet).willSendLte(feesTotal).ustx(),
Pc.principal(wallet).willSendAsset().nft("SP...nft-contract::asset-name", Cl.uint(tokenId))]withdraw-yield
mode: denyRewards come from the signer manager into the user contract, then the user contract splits them.
| Sender | Condition | Amount | Asset |
|---|---|---|---|
| User contract | sends ≤ | total available (vault + pending + selected earned) | sBTC |
| Signer manager | sends ≤ | pending + earned in selected cycles | sBTC |
- Recipients are fixed by the contract: 2% protocol, 1% app, 2% Pond Pals, 95% owner.
- Needs more than 100 sats available (u109).
typescript
const sbtcContract = "SN3VMHXEN64ZZF71JQ5VESXDWTR301XTTXGF4J8F1.sbtc-token";
[Pc.principal(userContract).willSendLte(total).ft(sbtcContract, "sbtc-token"),
Pc.principal(signerManager).willSendLte(pending + selectedEarned).ft(sbtcContract, "sbtc-token")]withdraw-principal
mode: denyUnlocked STX moves from the user contract back to the owner wallet.
| Sender | Condition | Amount | Asset |
|---|---|---|---|
| User contract | sends ≤ | amount-ustx, or the unlocked balance if omitted | uSTX |
- The contract also caps this itself with as-contract? / with-stx.
- Decast Alpha currently sends this in allow mode with no conditions. Deny mode with the condition above is recommended.
typescript
[Pc.principal(userContract).willSendLte(amountOrUnlocked).ustx()]transfer
mode: denyMove a post NFT you hold. Listed tokens can't be transferred.
| Sender | Condition | Amount | Asset |
|---|---|---|---|
| Sender | sends | token id | <user-contract>::decast-post |
- The asset issuer is the author's user contract that minted the post.
typescript
[Pc.principal(sender).willSendAsset().nft(`${userContract}::decast-post`, Cl.uint(tokenId))]buy-in-usbtc
mode: denyThe buyer pays sBTC and the seller hands over exactly the listed NFT.
| Sender | Condition | Amount | Asset |
|---|---|---|---|
| Buyer | sends ≤ | max-price-usbtc | sBTC |
| Seller | sends | token id | <user-contract>::decast-post |
- Pair with expected-listing-id so a changed listing fails with u120.
typescript
[Pc.principal(buyer).willSendLte(maxPrice).ft(sbtcContract, "sbtc-token"),
Pc.principal(seller).willSendAsset().nft(`${userContract}::decast-post`, Cl.uint(tokenId))]set-* (owner config)
mode: denyset-storage-uri, set-charity-principal, set-charity-amount-ustx and set-interface-fee-max move no assets.
- Send in deny mode with an empty list, so any unexpected transfer aborts the transaction.
typescript
postConditions: [], postConditionMode: "deny"Asset identifiers
testnet
sBTC SN3VMHXEN64ZZF71JQ5VESXDWTR301XTTXGF4J8F1.sbtc-token::sbtc-token
Post NFT <author-user-contract>::decast-post
Signer manager ST27J8CK2MP0TE57CT9DP0X672EWXDRR3FEGZJKPJ.fastpool-max500-signer-manager