0x2::transfer
Receiving
transfer
public_transfer
freeze_object
public_freeze_object
share_object
public_share_object
receive
public_receive
receiving_object_id
freeze_object_impl
share_object_impl
transfer_impl
receive_impl
use 0x2::object;
Receiving
This represents the ability to receive
an object of type T
.
This type is ephemeral per-transaction and cannot be stored on-chain.
This does not represent the obligation to receive the object that it
references, but simply the ability to receive the object with object ID
id
at version version
if you can prove mutable access to the parent
object during the transaction.
Internals of this struct are opaque outside this module.
struct Receiving<T: key> has drop
id: object::ID
version: u64
Serialization of the object failed.
const EBCSSerializationFailure: u64 = 1;
The object being received is not of the expected type.
const EReceivingObjectTypeMismatch: u64 = 2;
Shared an object that was previously created. Shared objects must currently be constructed in the transaction they are created.
const ESharedNonNewObject: u64 = 0;
Shared object operations such as wrapping, freezing, and converting to owned are not allowed.
const ESharedObjectOperationNotSupported: u64 = 4;
Represents both the case where the object does not exist and the case where the object is not able to be accessed through the parent that is passed-in.
const EUnableToReceiveObject: u64 = 3;
transfer
Transfer ownership of obj
to recipient
. obj
must have the key
attribute,
which (in turn) ensures that obj
has a globally unique ID. Note that if the recipient
address represents an object ID, the obj
sent will be inaccessible after the transfer
(though they will be retrievable at a future date once new features are added).
This function has custom rules performed by the Sui Move bytecode verifier that ensures
that T
is an object defined in the module where transfer
is invoked. Use
public_transfer
to transfer an object with store
outside of its module.
public fun transfer<T: key>(obj: T, recipient: address)
public fun transfer<T: key>(obj: T, recipient: address) {
transfer_impl(obj, recipient)
}
public_transfer
Transfer ownership of obj
to recipient
. obj
must have the key
attribute,
which (in turn) ensures that obj
has a globally unique ID. Note that if the recipient
address represents an object ID, the obj
sent will be inaccessible after the transfer
(though they will be retrievable at a future date once new features are added).
The object must have store
to be transferred outside of its module.
public fun public_transfer<T: store, key>(obj: T, recipient: address)
public fun public_transfer<T: key + store>(obj: T, recipient: address) {
transfer_impl(obj, recipient)
}
freeze_object
Freeze obj
. After freezing obj
becomes immutable and can no longer be transferred or
mutated.
This function has custom rules performed by the Sui Move bytecode verifier that ensures
that T
is an object defined in the module where freeze_object
is invoked. Use
public_freeze_object
to freeze an object with store
outside of its module.
public fun freeze_object<T: key>(obj: T)
public fun freeze_object<T: key>(obj: T) {
freeze_object_impl(obj)
}
public_freeze_object
Freeze obj
. After freezing obj
becomes immutable and can no longer be transferred or
mutated.
The object must have store
to be frozen outside of its module.
public fun public_freeze_object<T: store, key>(obj: T)
public fun public_freeze_object<T: key + store>(obj: T) {
freeze_object_impl(obj)
}
share_object
Turn the given object into a mutable shared object that everyone can access and mutate.
This is irreversible, i.e. once an object is shared, it will stay shared forever.
Aborts with ESharedNonNewObject
of the object being shared was not created in this
transaction. This restriction may be relaxed in the future.
This function has custom rules performed by the Sui Move bytecode verifier that ensures
that T
is an object defined in the module where share_object
is invoked. Use
public_share_object
to share an object with store
outside of its module.
public fun share_object<T: key>(obj: T)
public fun share_object<T: key>(obj: T) {
share_object_impl(obj)
}
public_share_object
Turn the given object into a mutable shared object that everyone can access and mutate.
This is irreversible, i.e. once an object is shared, it will stay shared forever.
Aborts with ESharedNonNewObject
of the object being shared was not created in this
transaction. This restriction may be relaxed in the future.
The object must have store
to be shared outside of its module.
public fun public_share_object<T: store, key>(obj: T)
public fun public_share_object<T: key + store>(obj: T) {
share_object_impl(obj)
}
receive
Given mutable (i.e., locked) access to the parent
and a Receiving
argument
referencing an object of type T
owned by parent
use the to_receive
argument to receive and return the referenced owned object of type T
.
This function has custom rules performed by the Sui Move bytecode verifier that ensures
that T
is an object defined in the module where receive
is invoked. Use
public_receive
to receivne an object with store
outside of its module.
public fun receive<T: key>(parent: &mut object::UID, to_receive: transfer::Receiving<T>): T
public fun receive<T: key>(parent: &mut UID, to_receive: Receiving<T>): T {
let Receiving { id, version } = to_receive;
receive_impl(parent.to_address(), id, version)
}
public_receive
Given mutable (i.e., locked) access to the parent
and a Receiving
argument
referencing an object of type T
owned by parent
use the to_receive
argument to receive and return the referenced owned object of type T
.
The object must have store
to be received outside of its defining module.
public fun public_receive<T: store, key>(parent: &mut object::UID, to_receive: transfer::Receiving<T>): T
public fun public_receive<T: key + store>(parent: &mut UID, to_receive: Receiving<T>): T {
let Receiving { id, version } = to_receive;
receive_impl(parent.to_address(), id, version)
}
receiving_object_id
Return the object ID that the given Receiving
argument references.
public fun receiving_object_id<T: key>(receiving: &transfer::Receiving<T>): object::ID
public fun receiving_object_id<T: key>(receiving: &Receiving<T>): ID {
receiving.id
}
freeze_object_impl
public(friend) fun freeze_object_impl<T: key>(obj: T)
public(package) native fun freeze_object_impl<T: key>(obj: T);
share_object_impl
public(friend) fun share_object_impl<T: key>(obj: T)
public(package) native fun share_object_impl<T: key>(obj: T);
transfer_impl
public(friend) fun transfer_impl<T: key>(obj: T, recipient: address)
public(package) native fun transfer_impl<T: key>(obj: T, recipient: address);
receive_impl
fun receive_impl<T: key>(parent: address, to_receive: object::ID, version: u64): T
native fun receive_impl<T: key>(parent: address, to_receive: ID, version: u64): T;