Decastecastdocstestnet

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 Pc from @stacks/transactions, matching Decast Alpha.

decast-postx

mode: deny

The wallet pays fees plus the deposit. Outside the prepare phase the user contract also locks STX through PoX.

SenderConditionAmountAsset
Owner walletsends ≤fees + deposituSTX
User contractlocks =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: deny

The booster's wallet pays fees in STX and sends the boost asset straight to the author and/or current post nft owner.

SenderConditionAmountAsset
Owner walletsends ≤fees (+ amount if STX boost)uSTX
Owner walletsends ≤amount (SIP-010 boost)the FT
Owner walletsendstoken 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: deny

Rewards come from the signer manager into the user contract, then the user contract splits them.

SenderConditionAmountAsset
User contractsends ≤total available (vault + pending + selected earned)sBTC
Signer managersends ≤pending + earned in selected cyclessBTC
  • 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: deny

Unlocked STX moves from the user contract back to the owner wallet.

SenderConditionAmountAsset
User contractsends ≤amount-ustx, or the unlocked balance if omitteduSTX
  • 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: deny

Move a post NFT you hold. Listed tokens can't be transferred.

SenderConditionAmountAsset
Sendersendstoken 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: deny

The buyer pays sBTC and the seller hands over exactly the listed NFT.

SenderConditionAmountAsset
Buyersends ≤max-price-usbtcsBTC
Sellersendstoken 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: deny

set-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