Skip to content

Commit 8aea049

Browse files
committed
added SFT PC example to PC guide
1 parent 3584376 commit 8aea049

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed

content/docs/stacks/stacks.js/guides/post-conditions.mdx

+47
Original file line numberDiff line numberDiff line change
@@ -201,6 +201,53 @@ Construct a post-condition for sending / not-sending a specific NFT.
201201
</Tab>
202202
</Tabs>
203203

204+
## Amount SFT sent / not sent
205+
206+
Construct a post-condition for sending / not-sending a specific SFT (semi-fungible token).
207+
208+
Semi-Fungible-Tokens (SFTs) are an innovative way to bring multiple ownership of a single unique digital item. SFTs are a combination of an NFT portion and an FT portion: where a unique tuple represents the NFT id and the amount units represented as fungible tokens. Therefore, at least two post-conditions are needed to handle the transfer of an SFT.
209+
210+
Check out the SFT starter contract template on the Hiro Platform.
211+
212+
<Tabs id="post-condition-examples" items={["Pc","Legacy"]}>
213+
<Tab value={"Pc"}>
214+
```ts
215+
import { Pc } from '@stacks/transactions';
216+
217+
const postCondition1 = Pc.principal('STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6')
218+
.willSendAsset()
219+
.nft(
220+
"ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.semi-fungible-token::semi-fungible-token-id",
221+
Cl.tuple({ "token-id": Cl.uint(1), owner: Cl.principal('STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6') })
222+
);
223+
224+
const postCondition2 = Pc.principal('STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6')
225+
.willSendEq(500)
226+
.ft("ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.semi-fungible-token", "semi-fungible-token");
227+
228+
```
229+
</Tab>
230+
<Tab value={"Legacy"}>
231+
```ts
232+
import { createNonFungiblePostCondition, NonFungibleConditionCode, createSTXPostCondition, FungibleConditionCode } from '@stacks/transactions';
233+
234+
const postCondition1 = createNonFungiblePostCondition(
235+
"STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6",
236+
NonFungibleConditionCode.DoesSend,
237+
"ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.semi-fungible-token::semi-fungible-token-id",
238+
Cl.tuple({ "token-id": Cl.uint(1), owner: Cl.principal('STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6') })
239+
);
240+
241+
const postCondition = createSTXPostCondition(
242+
"STB44HYPYAT2BB2QE513NSP81HTMYWBJP02HPGK6",
243+
FungibleConditionCode.Equal,
244+
500,
245+
"ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM.semi-fungible-token::semi-fungible-token"
246+
);
247+
```
248+
</Tab>
249+
</Tabs>
250+
204251
<Callout title="Note" type="warn">
205252
Post-conditions can only ensure the transfer of assets and cannot guarantee the end-state after a transaction. To learn more, read the [post-conditions](/stacks/stacks.js/concepts/post-conditions) guide.
206253
</Callout>

0 commit comments

Comments
 (0)