Assessment reports>Example String-Passing Solana OApp>Threat Model>Instruction: LzReceiveTypes

Instruction: LzReceiveTypes

This instruction returns the list of accounts needed by the LzReceive instruction to process a given message. It is used by message relayers to build a transaction that correctly invokes LzReceive. The list must include the accounts used by the OApp itself as well as accounts needed by the endpoint program Clear instruction.

The accounts needed by the example OApp are just the Store account holding the global configuration, which is a singleton with a fixed seed, and the account representing an allowlisted remote peer contract; the address of the account representing the remote peer is a PDA derived from the seeds PEER_SEED, ctx.accounts.store.key(), and params.src_eid.

The Store account is marked as writable, since the LzReceive instruction will write its data.

The list of accounts is extended by adding the accounts returned by the SDK function get_accounts_for_clear, which include (among others) the endpoint program, the OApp registry, and the nonce account used to prevent message-replay issues. The OApp itself does not need to be concerned with which specific accounts are necessary for LayerZero inner workings and does not need to validate the list returned by get_accounts_for_clear.

Input parameters

This instruction receives as argument an instance of the LzReceiveParams struct defined by the LayerZero SDK.

pub struct LzReceiveParams { pub src_eid: u32, pub sender: [u8; 32], pub nonce: u64, pub guid: [u8; 32], pub message: Vec, pub extra_data: Vec, }
  • src_eid: This is the ID of the sender endpoint.

  • sender: This is the address of the sender of the message.

  • nonce: This is used by get_accounts_for_clear to derive the PDA of the payload hash account needed by LayerZero internal logic.

  • guid: This is unused.

  • message: This is unused.

  • extra_data: This is unused.

More sophisticated OApps may need to inspect the unused fields such as the message passed to LzReceive to determine which accounts are needed.

Accounts

  • store: Singleton account storing the OApp global configuration.

    • PDA: Yes, with seed STORE_SEED.

Zellic © 2025Back to top ↑