[sui.move]
transfer_policy
, which is the real star of this section.
The transfer_policy
module defines how assets can be transferred and enforces rules on those transfers.
Here’s a table of the transfer policy features:
Feature | What it means |
---|---|
TransferPolicy<T> | A shared object that defines the rules for transferring type T |
TransferPolicyCap<T> | A capability (object) that lets you modify the policy — only the holder can change or add rules |
TransferRequest<T> | An object created whenever someone tries to transfer type T . They must fulfill the policy rules before the transfer is finalized |
add_rule(...) | Adds a custom rule (like “pay 1 SUI”) to the policy |
add_to_balance(...) | Lets you collect fees or payments tied to transfers |
add_receipt(...) | Marks a rule as fulfilled for a given transfer |
confirm_request(...) | Finalizes a transfer if all rules are met |
[sui.move]
[sui.move]
Rule
, and an empty Config
. We’ll plug this into the policy later.
Here’s a basic function to mint a new Art
NFT:
[sui.move]
[sui.move]
transfer_policy::new
creates the policy and its capability (cap
)- The policy is made shared so everyone can access it
- The cap is transferred to the caller so only they can manage the policy
[sui.move]
Rule
) and its config. This function can only be called by whoever holds the TransferPolicyCap
.
Here’s the critical part: enforcing a 1 SUI transfer fee:
[sui.move]
- It checks the coin’s value is exactly 1 SUI (in Mist)
- Adds that payment to the policy’s internal balance
- Marks the
TransferRequest
as passed for this rule
[sui.move]
confirm_request()
, the item is stuck in limbo. That’s why TradePort asks recipients to claim from Kiosks.