Post Conditions
Clarigen can make it easier for you to write post conditions in your app.
NFT Post Conditions
To create a NFT post condition, use makeNonFungiblePostCondition
.
The arguments are:
contract
: a Clarigen-created contract (see factories)address
: The address that this post condition is forcondition
: AnNFTConditionCode
value
: the asset ID for this post condition.
For this example, assume there is an NFT contract defined like this:
To create a post condition:
Note that this is strongly typed, so using a value other than a bigint
as an ID would show a type error.
If the NFT has a different type of key, like for BNS:
Then you'd need to use an appropriate tuple type:
Fungible token post conditions
Creating post conditions for a fungible token follows a similar process, except that you use an amount
instead of a specific NFT.
When calling makeFungiblePostCondition
, the amount
argument can be:
- A bigint (
123n
) - A string-encoded integer (
"123"
) - A number type integer (
123
)