Party Objects
A party object is an object that is transferred using the sui::transfer::party_transfer
or sui::transfer::public_party_transfer
function. It is accessible to the Party
to which it is transferred.
Party objects combine some properties of address-owned objects and shared objects. Like address-owned objects, they can be owned by a single address. Like shared objects, they are versioned by consensus. Unlike shared objects, they can be transferred to and from other ownership types and wrapped.
Currently, single ownership is the only supported mode for party objects. This topic will be updated if support for multiple owners or more granular permissions is added.
Creating party objects
Use one of the following functions (defined in the transfer module) to create party objects:
public fun party_transfer<T: key>(obj: T, party: sui::party::Party)
public fun public_party_transfer<T: key + store>(obj: T, party: sui::party::Party)
Use the sui::transfer::party_transfer
function if you are defining a custom transfer policy for the object. Use the sui::transfer::public_party_transfer
function if the object has the store
capability.
A party object's ownership can change over its lifetime. For example, by adding it as a dynamic object field, transferring it to a different address or owner type, or making it immutable. One exception: after you create an object and set its ownership, you cannot later share it.
Accessing party objects
You can specify party objects as input to a transaction in the same way as shared objects. Sui validators ensure that the sender of the transaction can access the object. The validator might abort a transaction at execution time if the owner of an input party object has changed due to an earlier, conflicting transaction.
Party objects whose owning address corresponds to an object ID are not supported for access through the transfer to object mechanism.
When to use party objects
Use party objects when you want an object to be versioned by consensus, such as for operational convenience. If an object is only used with other party or shared objects, converting it to a party object has no additional performance cost.