Skip to content

Integrate ZRO staking

For custodians that build and sign the ZRO stake themselves: the flow, the contract addresses, the exact transaction, a sample and the integration checklist.

On this page

This page is for custodians that build and sign the ZRO stake with their own infrastructure. It gives the flow, the contract addresses, the exact transaction and the integration checklist. The staking site builds the same transaction for retail users.

›Transcript
  1. What a custodian signs to stake ZRO, and what happens after that.
  2. You hold ZRO on one of seven source chains, such as Ethereum or Base.
  3. Zero is one chain made of zones. Stakes go to its System Zone.
  4. A stake enters Zero at the EVM Zone, then moves zone to zone to the System Zone.
  5. Transaction 1 is the only one you sign: send on the OFT, on the source chain.
  6. The OFT burns 100 ZRO from the wallet and sends a message to ZoneComposerNative.
  7. The fee from quoteSend, paid as msg.value, covers both EVM Zone transactions.
  8. LayerZero carries the message. DVNs verify it for the EVM Zone.
  9. Transaction 2, sent by the executor: OFTNative credits 100 ZRO to the composer.
  10. The executor sends it and pays its gas. You sign nothing on Zero.
  11. Transaction 3, also from the executor: the composer passes the ZRO to the Airlock.
  12. The Airlock burns it on the EVM Zone and sends it zone to zone, with a nonce.
  13. Once the EVM Zone block settles, the message moves to the System Zone.
  14. The System Zone credits 100 ZRO to the same staker address.
  15. Follow the stake by its guid: OFTSent in your receipt, then LayerZero Scan.
  16. On the EVM Zone, Sent with the same guid shows the ZRO reached the Airlock.
  17. If the zone isn’t active, the composer holds the stake. Anyone can retry it.
  18. You sign one transaction. The executor sends two on the EVM Zone.
  19. Then the ZRO moves zone to zone, and the System Zone credits the staker.
You sign
Source chains
Approval
Staked address
Fee

The flow

A stake is three transactions. You sign only the first. The executor sends the other two on the EVM Zone and pays their gas from your fee.

#TransactionChainSent byWhat it does
1send on OFTSource chainYouBurns the ZRO and sends a LayerZero message to ZoneComposerNative on the EVM Zone. Emits OFTSent with the stake's guid.
2lzReceive on OFTNativeEVM Zone (EID 33002)ExecutorRuns after all four DVNs on the pathway (LayerZero Labs, Twinstake, Blockaid and Canary) verify the message. Credits the ZRO to ZoneComposerNative as native ZRO and queues the compose. Emits OFTReceived.
3lzCompose on ZoneComposerNativeEVM ZoneExecutorDecodes the compose message and calls sendZro on the Airlock, which burns the ZRO on the EVM Zone and sends it to the System Zone. Emits Sent(guid, 33001, nonce).

When the EVM Zone block with transaction 3 is settled, the System Zone (zone 33001) credits the ZRO to the recipient address. See Moving between zones.

Only this transaction, built as below, stakes. ZRO sent to any other contract or address, or with other calldata, isn't staked.

Addresses

ContractChainAddress
OFT (the ZRO token)Ethereum, BNB Chain, Avalanche, Polygon, Arbitrum, Optimism, Base0x6985884C4392D348587B19cb9eAAf157F13271cd (the same address on all seven)
OFTNativeEVM Zone0x1ced7D571059A30Db0FC9aDC40346D2a1CE55B31
ZoneComposerNativeEVM Zone0xD72dE63F9dA5C13dD771038a62952a42E626E064
AirlockEVM Zone0x0000000000000000000000000000000000000a1A
LayerZero endpointEVM Zone0xC8CB2Dfb4E970e66cC1566703CdcD25A3E7cB9C0

The mainnet EVM Zone explorer isn't public yet. Read the EVM Zone contracts through the public RPC, https://public.evm.zero.layerzero.network.

Build the transaction

Call send(SendParam _sendParam, MessagingFee _fee, address _refundAddress) on OFT on the source chain:

FieldValueNotes
dstEid33002The EVM Zone.
to0x000000000000000000000000d72de63f9da5c13dd771038a62952a42e626e064The ZoneComposerNative, left-padded to 32 bytes. Not the staker's address.
amountLDThe stake, in 18 decimalsAt most 6 decimal places: OFT's shared decimals are 6, so it removes anything finer as dust.
minAmountLDEqual to amountLDZRO has no OFT fee, so the full amount arrives.
extraOptionsSee Executor optionsGas for both steps on the EVM Zone.
composeMsgabi.encode(uint64 33001, bytes recipient)See Compose message.
oftCmd0xEmpty.
_fee(nativeFee, 0)nativeFee from quoteSend with the same SendParam. No LayerZero token fee.
_refundAddressThe sending addressReceives any part of msg.value above the fee the endpoint charges.
msg.valuenativeFeeIn the source chain's native token.

The staking site also has each wallet sign its terms as a gasless EIP-712 message. No contract checks that signature, so a custodian applies its own terms.

Compose message

Compose message
abi.encode(uint64 dstZone, bytes recipient)
 
dstZone    33001, the System Zone
recipient  20 bytes: the address credited on the System Zone

The recipient MUST be 20 bytes: a recipient of any other length is consumed on the System Zone without a credit, and the ZRO stays burned. The staking site uses the sending address and no memo. Check an encoding against the decoder in ZoneComposerNative; it returns the zone, the recipient and an empty memo:

Decode a compose message on the EVM Zone
cast call 0xD72dE63F9dA5C13dD771038a62952a42E626E064 \
  "decode(bytes)(uint64,bytes,bytes)" \
  $(cast abi-encode "f(uint64,bytes)" 33001 <recipient>) \
  --rpc-url https://public.evm.zero.layerzero.network

Executor options

OptionGasValueCovers
lzReceive200,000noneTransaction 2
lzCompose, index 050,000,000noneTransaction 3, including sendZro, which uses about 44,000,000 gas

The lzCompose option MUST carry no value: ZoneComposerNative reverts UnexpectedValue when value is attached. Use 50,000,000 gas. The endpoint forwards only 63/64 of its remaining gas, so a limit near 44,000,000 can run out. A limit far above 50,000,000 can push the executor's transaction past the EVM Zone's per-transaction limit of 67,108,864 gas.

extraOptions used by stakes on mainnet
0x0003
  01 0011 01 00000000000000000000000000030d40
  01 0013 03 0000 00000000000000000000000002faf080

Each option is the executor worker ID (01), the option length, the option type (01 lzReceive, 03 lzCompose), then the fields: a uint128 gas for lzReceive; a uint16 compose index and a uint128 gas for lzCompose.

Check before you sign

Run these reads before the first stake and after any change to your integration. The sample below runs them.

ReadChainExpected
peers(uint32)(bytes32) with 33002 on 0x6985884C4392D348587B19cb9eAAf157F13271cdSource chain0x0000000000000000000000001ced7d571059a30db0fc9adc40346d2a1ce55b31
approvalRequired()(bool) on OFTSource chainfalse
OFT()(address) on ZoneComposerNativeEVM Zone0x1ced7D571059A30Db0FC9aDC40346D2a1CE55B31
ROUTER()(address) on ZoneComposerNativeEVM Zone0x0000000000000000000000000000000000000a1A, the Airlock
TOKEN()(address) on ZoneComposerNativeEVM Zone0x0000000000000000000000000000000000000000, native ZRO
ENDPOINT()(address) on ZoneComposerNativeEVM ZoneThe same value as endpoint()(address) on OFTNative
isActiveZone(uint64)(bool) with 33001 on the AirlockEVM Zonetrue

Sample

This sample uses viem and LayerZero's @layerzerolabs/lz-v2-utilities options builder. It runs the checks, builds the SendParam, quotes the fee and prints the unsigned transaction. Pass to, data and value to your signing infrastructure. With SEND=1 it sends from STAKER through the RPC's own account, as on a local fork.

stake.ts
import { Options } from '@layerzerolabs/lz-v2-utilities';
import {
  type Address,
  type Hex,
  createPublicClient,
  createWalletClient,
  encodeAbiParameters,
  encodeFunctionData,
  getAddress,
  http,
  isAddressEqual,
  pad,
  parseAbi,
  parseUnits,
} from 'viem';
 
const ZRO_OFT: Address = '0x6985884C4392D348587B19cb9eAAf157F13271cd';
const OFT_NATIVE: Address = '0x1ced7D571059A30Db0FC9aDC40346D2a1CE55B31';
const ZONE_COMPOSER_NATIVE: Address = '0xD72dE63F9dA5C13dD771038a62952a42E626E064';
const AIRLOCK: Address = '0x0000000000000000000000000000000000000a1A';
const EVM_ZONE_EID = 33002;
const SYSTEM_ZONE = 33001n;
const LZ_RECEIVE_GAS = 200_000n;
const LZ_COMPOSE_GAS = 50_000_000n;
const DECIMAL_CONVERSION_RATE = 10n ** 12n;
 
const oftAbi = parseAbi([
  'struct SendParam { uint32 dstEid; bytes32 to; uint256 amountLD; uint256 minAmountLD; bytes extraOptions; bytes composeMsg; bytes oftCmd; }',
  'struct MessagingFee { uint256 nativeFee; uint256 lzTokenFee; }',
  'function quoteSend(SendParam _sendParam, bool _payInLzToken) view returns (MessagingFee)',
  'function send(SendParam _sendParam, MessagingFee _fee, address _refundAddress) payable',
  'function peers(uint32 eid) view returns (bytes32)',
  'function approvalRequired() view returns (bool)',
]);
 
const zoneComposerNativeAbi = parseAbi([
  'function OFT() view returns (address)',
  'function ROUTER() view returns (address)',
  'function TOKEN() view returns (address)',
  'function ENDPOINT() view returns (address)',
]);
 
const oftNativeAbi = parseAbi(['function endpoint() view returns (address)']);
const airlockAbi = parseAbi(['function isActiveZone(uint64 zone) view returns (bool)']);
 
function stakingOptions(): Hex {
  return Options.newOptions()
    .addExecutorLzReceiveOption(LZ_RECEIVE_GAS, 0)
    .addExecutorComposeOption(0, LZ_COMPOSE_GAS, 0)
    .toHex() as Hex;
}
 
function stakingComposeMsg(staker: Address): Hex {
  return encodeAbiParameters([{ type: 'uint64' }, { type: 'bytes' }], [SYSTEM_ZONE, staker]);
}
 
function assertAddress(label: string, actual: string, expected: string): void {
  if (!isAddressEqual(getAddress(actual), getAddress(expected))) {
    throw new Error(`${label} is ${actual}, expected ${expected}`);
  }
}
 
async function checkZero(zeroRpcUrl: string): Promise<void> {
  const zero = createPublicClient({ transport: http(zeroRpcUrl) });
  const read = (functionName: 'OFT' | 'ROUTER' | 'TOKEN' | 'ENDPOINT') =>
    zero.readContract({ address: ZONE_COMPOSER_NATIVE, abi: zoneComposerNativeAbi, functionName });
  assertAddress('ZoneComposerNative OFT()', await read('OFT'), OFT_NATIVE);
  assertAddress('ZoneComposerNative ROUTER()', await read('ROUTER'), AIRLOCK);
  assertAddress('ZoneComposerNative TOKEN()', await read('TOKEN'), '0x0000000000000000000000000000000000000000');
  const oftNativeEndpoint = await zero.readContract({ address: OFT_NATIVE, abi: oftNativeAbi, functionName: 'endpoint' });
  assertAddress('ZoneComposerNative ENDPOINT()', await read('ENDPOINT'), oftNativeEndpoint);
  const active = await zero.readContract({
    address: AIRLOCK,
    abi: airlockAbi,
    functionName: 'isActiveZone',
    args: [SYSTEM_ZONE],
  });
  if (!active) throw new Error('System Zone 33001 is not active: the stake would be held');
}
 
export async function buildStake(sourceRpcUrl: string, staker: Address, amountZro: string) {
  const amountLD = parseUnits(amountZro, 18);
  if (amountLD <= 0n || amountLD % DECIMAL_CONVERSION_RATE !== 0n) {
    throw new Error('amount must be positive with at most 6 decimals');
  }
  const source = createPublicClient({ transport: http(sourceRpcUrl) });
  const peer = await source.readContract({
    address: ZRO_OFT,
    abi: oftAbi,
    functionName: 'peers',
    args: [EVM_ZONE_EID],
  });
  if (peer.toLowerCase() !== pad(OFT_NATIVE).toLowerCase()) {
    throw new Error(`peers(33002) is ${peer}, expected OFTNative`);
  }
  if (await source.readContract({ address: ZRO_OFT, abi: oftAbi, functionName: 'approvalRequired' })) {
    throw new Error('this OFT needs an approval: stop and check the chain');
  }
  const sendParam = {
    dstEid: EVM_ZONE_EID,
    to: pad(ZONE_COMPOSER_NATIVE),
    amountLD,
    minAmountLD: amountLD,
    extraOptions: stakingOptions(),
    composeMsg: stakingComposeMsg(staker),
    oftCmd: '0x',
  } as const;
  const fee = await source.readContract({
    address: ZRO_OFT,
    abi: oftAbi,
    functionName: 'quoteSend',
    args: [sendParam, false],
  });
  const data = encodeFunctionData({
    abi: oftAbi,
    functionName: 'send',
    args: [sendParam, { nativeFee: fee.nativeFee, lzTokenFee: 0n }, staker],
  });
  return { from: staker, to: ZRO_OFT, data, value: fee.nativeFee, sendParam };
}
 
async function main(): Promise<void> {
  const sourceRpcUrl = process.env.SOURCE_RPC_URL ?? 'http://127.0.0.1:8545';
  const zeroRpcUrl = process.env.ZERO_RPC_URL ?? 'https://public.evm.zero.layerzero.network';
  if (!process.env.STAKER) throw new Error('set STAKER to the address that signs the stake');
  const staker = getAddress(process.env.STAKER);
  const amountZro = process.env.AMOUNT_ZRO ?? '1';
 
  await checkZero(zeroRpcUrl);
  const tx = await buildStake(sourceRpcUrl, staker, amountZro);
  console.log({ to: tx.to, value: tx.value, data: tx.data });
 
  if (process.env.SEND !== '1') return;
  const wallet = createWalletClient({ account: staker, transport: http(sourceRpcUrl) });
  const hash = await wallet.sendTransaction({ chain: null, to: tx.to, data: tx.data, value: tx.value });
  const receipt = await createPublicClient({ transport: http(sourceRpcUrl) }).waitForTransactionReceipt({ hash });
  console.log({ hash, status: receipt.status });
}
 
main().catch((error: unknown) => {
  console.error(error);
  process.exit(1);
});

To try it without funds, run it on a fork of the source chain as an impersonated ZRO holder:

Run the sample on a fork of Ethereum
npm install viem @layerzerolabs/lz-v2-utilities tsx
anvil --fork-url <Ethereum RPC> --port 8545
cast rpc anvil_impersonateAccount <ZRO holder> --rpc-url http://127.0.0.1:8545
STAKER=<ZRO holder> AMOUNT_ZRO=25 SEND=1 npx tsx stake.ts

Or use the Value Transfer API

The staking site gets the same transaction from the Value Transfer API's staking route and checks every field before the wallet signs. A custodian can do the same with its own API key; ask your LayerZero contact to enable the staking route for that key. Check the returned transaction against Build the transaction before you sign.

Integration checklist

Required

#Do thisIf you don't
1Call send on the OFT in Addresses, on one of the seven source chains.ZRO sent anywhere else, including directly to a Zero contract, isn't staked.
2Set dstEid to 33002 and to to ZoneComposerNative, left-padded to 32 bytes.The ZRO is credited to that other address on the EVM Zone and isn't staked.
3Encode the compose message as abi.encode(uint64 33001, bytes recipient), with a 20-byte recipient that the staker controls. See Compose message.A message ZoneComposerNative can't decode is held for the owner's rescue. A recipient of another length is consumed on the System Zone without a credit.
4Set the lzCompose option to index 0, 50,000,000 gas and no value, and the lzReceive option to 200,000 gas. See Executor options.With value attached, the compose reverts UnexpectedValue. With too little gas, the compose fails and stays retryable until someone retries it with enough gas. With far more, the executor's transaction can exceed the EVM Zone's per-transaction limit of 67,108,864 gas.
5Quote with quoteSend using the exact SendParam you send, and send msg.value equal to nativeFee.The fee depends on the options and the compose message. A fee quoted for other parameters can be too low, and the send reverts.
6Set minAmountLD equal to amountLD, with an amount of at most 6 decimal places.An amount with finer precision loses its dust, and the send reverts on the slippage check.
7Run the reads in Check before you sign before the first stake.A wrong peer or ZoneComposerNative address can't be found from the transaction alone.
8Don't send to the MultiHopComposerNative or any other EVM Zone contract.The ZRO doesn't reach the System Zone as a stake.
#Do thisIf you don't
9Follow each stake to the Sent event from ZoneComposerNative, not only to Scan's DELIVERED. See Follow a stake.A stake held with UnroutableZone or DecodeFailed shows as delivered on the source pathway but isn't in the System Zone.
10Check the Wallet requirements for the address that receives the stake.The stake is credited to the recipient address on Zero, and only the key that controls that address can act on it later.

Follow a stake

  1. Source transaction. The receipt holds OFTSent from OFT. Its first topic after the event signature is the guid.
  2. LayerZero Scan. Look up the source transaction on LayerZero Scan, or call https://scan.layerzero-api.com/v1/messages/tx/<source tx hash>. A stake is delivered when the message status is DELIVERED and its lzCompose status is SUCCEEDED. Scan lists the lzReceive and lzCompose transaction hashes on the EVM Zone.
  3. The compose result. In the lzCompose transaction's receipt, ZoneComposerNative emits one of:
    • Sent(bytes32 indexed guid, uint64 indexed dstZone, uint64 nonce): the ZRO was sent to the System Zone. nonce is the Airlock's transfer nonce. This is the expected result.
    • UnroutableZone(bytes32 indexed guid, uint64 dstZone, bytes recipient, bytes memo): the zone wasn't active and ZoneComposerNative holds the stake. See When a step fails.
    • DecodeFailed(bytes32 indexed guid, bytes message): the compose message couldn't be decoded, and ZoneComposerNative holds the ZRO for the owner.

The public RPC serves recent blocks only. For older EVM Zone receipts, use the archive RPC, https://archive.evm.zero.layerzero.network.

When a step fails

What happensWhat you seeWho can act
The source send reverts, for example because the fee is too low or the amount has dust below minAmountLDThe source transaction failedNo ZRO moves. Fix the transaction and send again.
OFTNative can't credit: the inbound rate limit for the source chain is reached (RateLimitExceeded), or its native ZRO balance is too low (CreditFailed)Scan shows the message verified but not deliveredThe message stays retryable on the endpoint. LayerZero Labs resolves the cause, then anyone can retry the delivery.
The credit redirect on OFTNative is on and ZoneComposerNative isn't on its allowlistOFTNative credits an escrow instead, and lzCompose reverts ZeroAmountOnly the escrow's owner can return the ZRO.
The compose runs out of gas, or the Airlock call revertsScan shows lzCompose failedThe compose stays retryable on the endpoint. Anyone can call lzCompose on the endpoint again with enough gas.
The System Zone isn't activeUnroutableZoneZoneComposerNative holds the stake in retryableMessages. Anyone can call retry(guid, dstZone, recipient, memo) with the event's values once the zone is active. ZoneComposerNative then emits Retried(guid) and Sent(guid, dstZone, nonce).
The compose message can't be decodedDecodeFailedOnly the owner of ZoneComposerNative can act, with rescue(guid, to), which sends the ZRO to an address the owner chooses on the EVM Zone.
The recipient isn't 20 bytesSent, but no credit on the System ZoneThe System Zone consumes the message without a credit, and the ZRO stays burned. Nobody can recover it.

The owner of ZoneComposerNative is a contract controlled by LayerZero. It can rescue a stake that ZoneComposerNative holds after UnroutableZone or DecodeFailed, until a retry succeeds. It can't take a stake after Sent. Nothing returns ZRO to the source chain.

Worked example

A 29 ZRO stake from Ethereum on mainnet, read on December 1, 2026. The EVM Zone explorer isn't public yet, so the two EVM Zone transactions are listed on the message's LayerZero Scan page:

StepTransactionResult
Send on Ethereum0x8f2fa8896f8ac0f62008165656e1afc6b4a1fefe430e9b43fcfa411063e7e6b829 ZRO burned. nativeFee and msg.value 0.000154373611511595 ETH. 348,477 gas
Messageguid 0xb08a224a2ba14b62c5d9a4b43fe09a37b04104818f193b11e662a8c997efe0e7On LayerZero ScanDELIVERED. Four DVNs verified
lzReceive on the EVM Zone0xcabfe6f17692852a87caf8a88d68b0ea27e658c8693ef22a16870e2678b539a4OFTReceived: 29 ZRO credited to ZoneComposerNative. Block 38331
lzCompose on the EVM Zone0x491f7a3419b4f6c4efb200354724a4afb48a2b31e6157a6eea4f61c3b50be15dSent(guid, 33001, 3847). 44,249,009 gas. Block 38332
FieldValue
Staker0x6067284E0DEacc5cA67222a0bEba31AEF61b4bc9Also the compose message's recipient and the refund address
A second stake, from Base0xeedce111586bc44439aa590910a382ae7f112c2263570df4cdeabbc84a55ece4The same fields with 2.32 ZRO and its own sender. Message on LayerZero Scan

The decoded send of the Ethereum stake:

Decoded send, Ethereum stake
SendParam
  dstEid        33002
  to            0x000000000000000000000000d72de63f9da5c13dd771038a62952a42e626e064
  amountLD      29000000000000000000
  minAmountLD   29000000000000000000
  extraOptions  0x00030100110100000000000000000000000000030d4001001303000000000000000000000000000002faf080
  composeMsg    abi.encode(33001, 0x6067284e0deacc5ca67222a0beba31aef61b4bc9)
  oftCmd        0x
MessagingFee    (154373611511595, 0)
refundAddress   0x6067284E0DEacc5cA67222a0bEba31AEF61b4bc9
msg.value       154373611511595