Skip to the article
Crypto Docket

Crypto news and comparative analysis

LayerZero OFT Send Function: Fields, Fees and Returns

LayerZero OFT send function parameters are SendParam, MessagingFee and a refund address; the fields set the destination, amount, options and message content.

By Crypto Docket Newsroom#9ea0ff4 min read

LayerZero OFT Send Function: Fields, Fees and Returns

The LayerZero OFT V2 send function takes a SendParam struct, a MessagingFee struct and a refund address, and returns a MessagingReceipt plus an OFTReceipt. SendParam specifies where tokens go, how much to send and what destination execution needs; the fee funds LayerZero messaging, while the refund address receives any endpoint refund.

What goes into an OFT send call?

The OFT send call has three arguments: _sendParam, _fee and _refundAddress. It is payable, so an EVM transaction supplies native currency through msg.value when the quote uses native payment.

  • SendParam: dstEid, to, amountLD, minAmountLD, extraOptions, composeMsg and oftCmd.
  • MessagingFee: nativeFee and lzTokenFee.
  • Refund address: _refundAddress, the address for fee refunds on the source chain.

Each SendParam field has a specific job. dstEid is the destination’s LayerZero endpoint ID; to is the destination recipient encoded as bytes32; amountLD is the requested token amount in local decimals; and minAmountLD is the minimum acceptable amount after conversion and dust removal. extraOptions carries destination execution options, such as gas for receiving the message. composeMsg carries an optional composed-call payload, while oftCmd is reserved for OFT commands and is unused in the default OFT implementation. The last two can be empty bytes, written as 0x, when unused.

MessagingFee contains nativeFee and lzTokenFee. Use quoteSend(_sendParam, false) to get the native payment quote, then pass that fee to send. In the standard OApp implementation, msg.value must equal the quoted nativeFee: a mismatch reverts with NotEnoughNative. If paying the LayerZero token fee instead, quote with the LZ-token payment flag and account for the token fee as well.

What happens, and what comes back?

OFT send debits or burns the source tokens, removes any amount that cannot be represented in shared decimals, then sends a LayerZero message with the destination and options. On receipt, the destination OFT can mint or credit the corresponding tokens, subject to its implementation.

The function returns two receipts. MessagingReceipt contains the message GUID, nonce and fee incurred. OFTReceipt contains amountSentLD, the amount actually debited on the source, and amountReceivedLD, the amount expected on the destination; custom OFTs may make those amounts differ.

Dust removal matters when setting minAmountLD. With the default six shared decimals, an 18-decimal token has a conversion rate of 10¹² local units. A requested amount is rounded down to the nearest multiple of 10¹², so units below that threshold do not cross the chain. For instance, 1.234567890123456789 tokens becomes 1.234567 tokens for the cross-chain amount; the remainder, 890123456789 local units, is dust.

Set minAmountLD against the amount after dust removal, not the full requested amount. If it is higher than the amount the OFT can send, the transfer reverts with SlippageExceeded. For an 18-decimal OFT using the default shared decimals, calculate the rounded amount by removing the final 12 local-decimal places, then choose a minimum at or below that amount based on the slippage you accept.

How would an Ethereum-to-Berachain call work?

For an Ethereum-to-Berachain transfer, dstEid must be Berachain’s LayerZero endpoint ID, 30362. Set to to the recipient’s 20-byte EVM address left-padded with 12 zero bytes to fill bytes32; passing the 20-byte address without padding does not match the expected field.

Say you want to send an 18-decimal OFT to a wallet on Berachain. Build SendParam with dstEid set to 30362, the padded recipient, the requested amount, a minAmountLD that accounts for dust, and the destination gas options in extraOptions. Use 0x for composeMsg and oftCmd if you have no composed call or OFT command. Call quoteSend with the completed SendParam and native payment selected, then send using the returned MessagingFee and set msg.value equal to nativeFee.

Quote after finalizing the amount and options: changing extraOptions or waiting while fee conditions change can leave you with a stale quote, and an insufficient fee can make the call revert. The refund address is where endpoint refunds go; it does not replace the need to use the current quote. The Berachain bridge adds useful background on how cross-chain asset transfers connect to Berachain’s DeFi ecosystem.

Where does the Berachain bridge fit?

The Berachain bridge is the practical destination context for this call: OFT transfers move assets across chains so they can be used in Berachain’s DeFi ecosystem. The parameters decide the route, recipient, spendable amount and destination execution budget; the fee quote determines what the source transaction must fund. For a working integration, the values to watch are the destination EID, bytes32 recipient encoding, post-dust minimum and a fresh native fee quote.