Party Objects
A party object is a consensus-address-owned object: a single address owns it, but consensus sequences and versions it. APIs expose this ownership with a ConsensusAddressOwner owner variant. Like shared objects, party objects use consensus sequencing. Unlike shared objects, they retain single-address ownership and can be transferred to and from other ownership types and wrapped.
Party objects are 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 currently support only single-address ownership. The sui::party::Party type already models permissions for multiple members, but the public ownership mode is restricted to party::single_owner.
Create party objects
Use these transfer module functions 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_transferfunction if you are defining a custom transfer policy for the object. -
Use the
sui::transfer::public_party_transferfunction if the object has thestorecapability.
A party object's ownership can change over its lifetime, either by adding it as a dynamic object field, transferring it to a different address or ownership type, or making it immutable. However, after you create an object and set its ownership, it cannot be shared.
public fun create_party(value: u64, recipient: address, ctx: &mut TxContext) {
let party = party::single_owner(recipient);
transfer::public_party_transfer(
Object { id: object::new(ctx), value },
party,
)
}
When to use party objects
Use party objects when you want an object to remain owned by one address but be versioned by consensus, such as for operational convenience. If you only use an object with other party or shared objects, converting it to a party object has no additional performance cost.
Party objects can be used by multiple inflight transactions at the same time. This contrasts with address-owned objects, which only allow a single inflight transaction. Many applications can benefit from the ability to pipeline multiple transactions on the same party object.
Coins can be party objects, including Coin<SUI>. However, you cannot use a party object Coin<SUI> for gas payment. To use a party object Coin<SUI> for gas, you must first transfer it back to address-owned.
Interact with 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 because of 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. To transfer a party object owned by an account address:
public fun party_transfer_single_owner(o: Object, recipient: address) {
let party = party::single_owner(recipient);
transfer::public_party_transfer(o, party)
}