Skip to main content
Version: Endpoint V1 Docs

Relayer Adapter Parameters

Advanced relayer usage, and usage of _adapterParams

Looking to Airdrop native gas tokens on a destination chain?

Abstract: Every transaction costs a certain amount of gas. Since LayerZero delivers the destination transaction when a message is sent it must pay for that destination gas. A default of 200,000 gas is priced into the call for simplicity.

As a message sender, your contract may use more or less than 200k on destination.

To instruct LayerZero to use a custom amount of gas, you must pass the adapterParams argument of send() or estimateFees()

Version 1 - Example: You want to call estimateFees() and get a quote for a custom gas amount.

DescriptionTypeExample Value
versionuint161
valueuint256200000

Encode the adapterParams and use them in the send() or estimateFees() function call

Heres an example of how to encode the adapterParams

// v1 adapterParams, encoded for version 1 style, and 200k gas quote
let adapterParams = ethers.utils.solidityPack(
['uint16','uint256'],
[1, 200000]
)

The resulting adapterParams should look like this (34 total bytes in length): 0x00010000000000000000000000000000000000000000000000000000000000030d40

Airdrop

Version 2 - Here is an example of how to encode the adapterParams for version 2, which may modify the default 200k gas, and instruct the Relayer to send native gas into a wallet address!

DescriptionTypeExample Value
versionuint162
gasAmountuint200000
nativeForDstuint55555555555
addressOnDstaddress0x1234512345123451234512345123451234512345
// v2 adapterParams, encoded for version 2 style
// which can instruct the LayerZero message to give
// destination 55555555555 wei of native gas into a specific wallet
let adapterParams = ethers.utils.solidityPack(
['uint16', 'uint', 'uint', 'address'],
[2, 200000, 55555555555, '0x1234512345123451234512345123451234512345'],
);

The above adapterParams can be sent to send() or estimateFees() to receive a quote for a non-standard amount of gas for the destination lzReceive() and to give an amount of destination native gas to an address!

You can also read the Max native gas drop amount by querying the relayer.

Codesandbox: https://codesandbox.io/p/sandbox/read-max-native-gas-drop-layerzero-tkfd3f?embed=1&file=%2Findex.js%3A52%2C1

// airdrop caps out at these values, per network (values shown imply 18 decimals)
// Note: these values may change occasionally. Read onchain values in Relayer.sol for accuracy.
ethereum: 0.24;
bsc: 1.32;
avalanche: 18.47;
polygon: 681;
arbitrum: 0.24;
optimism: 0.24;
fantom: 1304;
swimmer: 30000;