> For the complete documentation index, see [llms.txt](https://docs.stacks.co/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.stacks.co/cookbook/stacks.js/cryptography-and-security/build-an-nft-pc.md).

# Build an nft pc

{% code fullWidth="false" expandable="true" %}

```typescript
import { Pc, Cl } from '@stacks/transactions';

// Ensure a specific NFT will be sent
const sendPC = Pc.principal("ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM")
  .willSendAsset()
  .nft('ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.cool-nfts::nft-token', Cl.uint(42));

// Ensure a specific NFT will NOT be sent
const keepPC = Pc.principal("ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM")
  .willNotSendAsset()
  .nft('ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.cool-nfts::nft-token', Cl.uint(1));

// Allow a specific NFT to be sent, without requiring it (SIP-040)
const maybePC = Pc.principal("ST1PQHQKV0RJXZFY1DGX8MNSNYVE3VGZJSRTPGZGM")
  .willMaybeSendAsset()
  .nft('ST1HTBVD3JG9C05J7HBJTHGR0GGW7KXW28M5JS8QE.cool-nfts::nft-token', Cl.uint(7));
```

{% endcode %}

### Description

Builds post-conditions that require a specific NFT to be sent, forbid it from being sent, or allow it to be sent without requiring it.

### Use Cases

* Protecting valuable NFTs from accidental transfers
* Ensuring specific NFTs are transferred in marketplace transactions
* Safeguarding NFT collections during contract interactions

### Key Concepts

* **Asset identifier** - Contract address + asset name with `::` separator
* **Token ID** - The specific NFT ID as a Clarity value (using `Cl.uint()`)
* NFT post-conditions use the `.nft()` method
* `.willMaybeSendAsset()` - The NFT may or may not be sent, and the condition always passes. It still counts as covering that NFT instance under `Deny` or `Originator` mode, so an optional transfer can be authorized without falling back to `Allow`. Added by [SIP-040](https://github.com/stacksgov/sips/blob/main/sips/sip-040/sip-040-post-conds.md), available in `@stacks/transactions` 7.4.0 and later.
* Staking and PoX post-conditions - Locking STX in `SP000000000000000000002Q6VF78.pox-5` and the four gated PoX actions have their own post-condition types, built with `.ustxToLock()` and `.willPerformPox()` from `@stacks/transactions` 7.5.0. [Build a STX pc](/cookbook/stacks.js/cryptography-and-security/build-a-stx-pc.md) shows both.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.stacks.co/cookbook/stacks.js/cryptography-and-security/build-an-nft-pc.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
