Instruction: Send
This instruction sends a cross-chain message to one of the allowlisted remote contracts.
Input parameters
dst_eid
: This is the ID of the remote endpoint contract.message
: This is the message to be sent to the remote contract.options
: These are additional send options, merged with the enforced options configured for thedst_eid
in the remote peer configuration.native_fee
: This is the amount of native currency to be used to pay for messaging fees.lz_token_fee
: This is the amount of LZ token to be used to pay for messaging fees.
Accounts
peer
: Account representing the allowlisted remote contract to which the message is sent.PDA: Yes, with seeds
PEER_SEED
,store.key()
, andparams.dst_eid
.
store
: Account storing the OApp global configuration.PDA: Yes, with seed
STORE_SEED
.
endpoint
: Account storing the settings for the LayerZero endpoint on Solana.PDA: Yes, with seed
ENDPOINT_SEED
, derived from the endpoint program ID.
CPI
The LayerZero endpoint program is invoked to send the outgoing message.
The SendParams
struct of arguments passed to the CPI is initialized as follows:
dst_eid
:params.dst_eid
.receiver
:ctx.accounts.peer.peer_address
.message
:params.message
encoded by prepending the string length (32 bytes) before the UTF-8 representation of the string.options
:params.options
appended to the options enforced by the OApp global configuration.native_fee
:params.native_fee
.lz_token_fee
:params.lz_token_fee
.