Destination contracts must implement lzReceive() to handle incoming messages
The UA has to provide a public entry function
lz_receive()for executors to receive messages from other chains and execute your business logic.
public entry fun lz_receive<Type1, Type2, ...>(src_chain_id: u64, src_address: vector<u8>, payload: vector<u8>)
lz_receive()function has to call the Endpoint's
lz_receive()function to verify the payload and get the nonce.
// endpoint's lz_receive()
public fun lz_receive<UA>(
When an executor calls your UA's
lz_receive(), it needs to know what generic types
<Type1, Type2, ...>to use for consuming the payload. So if your UA needs those types, you also need to provide a public entry function
lz_receive_types()to return the types.
Make sure to assert the provided types against the payload. For example, if the payload indicates coinType A, then the provided coinType must be A.
public fun lz_receive_types(src_chain_id: u64, src_address: vector<u8>, payload: vector<u8>): vector<TypeInfo>
LayerZero is by BLOCKING by default, which means if the message payload fails in the
lz_receive()function, your UA will be blocked and cannot receive next messages from that path until the failed message is received successfully. If this happens, you may have to drop the message or store it and retry later. We provide LZApp Modules to help you handle it.