Receive a Sui object sent to another object’s address

A transfer to a mailbox object can succeed before the mailbox has processed the incoming asset. Its module needs a receiving argument and mutable access to the correct parent.

Match the child reference with the parent

The excerpt belongs in the module defining Mailbox. Supply the incoming child’s ID, version and digest as a receiving object reference in the transaction builder. Pass the mailbox whose object address currently owns that child.

public fun collect<T: key + store>(
    mailbox: &mut Mailbox,
    message: sui::transfer::Receiving<T>,
): T {
    sui::transfer::public_receive(&mut mailbox.id, message)
}

Decide who can release an asset

A successful receive returns the actual Move value. The caller still needs to store, consume or transfer it. On a shared mailbox, a public collect function like this lets anyone with suitable inputs receive assets. Add the protocol’s authorization check before exposing withdrawals. A ticket for child A cannot establish ownership by unrelated mailbox B.

Sources