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
- What a custodian signs to stake ZRO, and what happens after that.
- You hold ZRO on one of seven source chains, such as Ethereum or Base.
- Zero is one chain made of zones. Stakes go to its System Zone.
- A stake enters Zero at the EVM Zone, then moves zone to zone to the System Zone.
- Transaction 1 is the only one you sign: send on the OFT, on the source chain.
- The OFT burns 100 ZRO from the wallet and sends a message to ZoneComposerNative.
- The fee from quoteSend, paid as msg.value, covers both EVM Zone transactions.
- LayerZero carries the message. DVNs verify it for the EVM Zone.
- Transaction 2, sent by the executor: OFTNative credits 100 ZRO to the composer.
- The executor sends it and pays its gas. You sign nothing on Zero.
- Transaction 3, also from the executor: the composer passes the ZRO to the Airlock.
- The Airlock burns it on the EVM Zone and sends it zone to zone, with a nonce.
- Once the EVM Zone block settles, the message moves to the System Zone.
- The System Zone credits 100 ZRO to the same staker address.
- Follow the stake by its guid: OFTSent in your receipt, then LayerZero Scan.
- On the EVM Zone, Sent with the same guid shows the ZRO reached the Airlock.
- If the zone isn’t active, the composer holds the stake. Anyone can retry it.
- You sign one transaction. The executor sends two on the EVM Zone.
- Then the ZRO moves zone to zone, and the System Zone credits the staker.
- You sign
- One
sendonOFT, on the chain where the ZRO is held - Source chains
- Ethereum, BNB Chain, Avalanche, Polygon, Arbitrum, Optimism and Base
- Approval
- None:
OFTis the ZRO token on every source chain - Staked address
- The 20-byte recipient in the compose message, credited on the System Zone
- Fee
- One LayerZero messaging fee from
quoteSend, paid asmsg.valuein the source chain's native token. Nothing is paid on Zero
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.
| # | Transaction | Chain | Sent by | What it does |
|---|---|---|---|---|
| 1 | send on OFT | Source chain | You | Burns the ZRO and sends a LayerZero message to ZoneComposerNative on the EVM Zone. Emits OFTSent with the stake's guid. |
| 2 | lzReceive on OFTNative | EVM Zone (EID 33002) | Executor | Runs 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. |
| 3 | lzCompose on ZoneComposerNative | EVM Zone | Executor | Decodes 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
| Contract | Chain | Address |
|---|---|---|
OFT (the ZRO token) | Ethereum, BNB Chain, Avalanche, Polygon, Arbitrum, Optimism, Base | 0x6985884C4392D348587B19cb9eAAf157F13271cd (the same address on all seven) |
OFTNative | EVM Zone | 0x1ced7D571059A30Db0FC9aDC40346D2a1CE55B31 |
ZoneComposerNative | EVM Zone | 0xD72dE63F9dA5C13dD771038a62952a42E626E064 |
Airlock | EVM Zone | 0x0000000000000000000000000000000000000a1A |
| LayerZero endpoint | EVM Zone | 0xC8CB2Dfb4E970e66cC1566703CdcD25A3E7cB9C0 |
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:
| Field | Value | Notes |
|---|---|---|
dstEid | 33002 | The EVM Zone. |
to | 0x000000000000000000000000d72de63f9da5c13dd771038a62952a42e626e064 | The ZoneComposerNative, left-padded to 32 bytes. Not the staker's address. |
amountLD | The stake, in 18 decimals | At most 6 decimal places: OFT's shared decimals are 6, so it removes anything finer as dust. |
minAmountLD | Equal to amountLD | ZRO has no OFT fee, so the full amount arrives. |
extraOptions | See Executor options | Gas for both steps on the EVM Zone. |
composeMsg | abi.encode(uint64 33001, bytes recipient) | See Compose message. |
oftCmd | 0x | Empty. |
_fee | (nativeFee, 0) | nativeFee from quoteSend with the same SendParam. No LayerZero token fee. |
_refundAddress | The sending address | Receives any part of msg.value above the fee the endpoint charges. |
msg.value | nativeFee | In 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
abi.encode(uint64 dstZone, bytes recipient)
dstZone 33001, the System Zone
recipient 20 bytes: the address credited on the System ZoneThe 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:
cast call 0xD72dE63F9dA5C13dD771038a62952a42E626E064 \
"decode(bytes)(uint64,bytes,bytes)" \
$(cast abi-encode "f(uint64,bytes)" 33001 <recipient>) \
--rpc-url https://public.evm.zero.layerzero.networkExecutor options
| Option | Gas | Value | Covers |
|---|---|---|---|
| lzReceive | 200,000 | none | Transaction 2 |
| lzCompose, index 0 | 50,000,000 | none | Transaction 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.
0x0003
01 0011 01 00000000000000000000000000030d40
01 0013 03 0000 00000000000000000000000002faf080Each 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.
| Read | Chain | Expected |
|---|---|---|
peers(uint32)(bytes32) with 33002 on 0x6985884C4392D348587B19cb9eAAf157F13271cd | Source chain | 0x0000000000000000000000001ced7d571059a30db0fc9adc40346d2a1ce55b31 |
approvalRequired()(bool) on OFT | Source chain | false |
OFT()(address) on ZoneComposerNative | EVM Zone | 0x1ced7D571059A30Db0FC9aDC40346D2a1CE55B31 |
ROUTER()(address) on ZoneComposerNative | EVM Zone | 0x0000000000000000000000000000000000000a1A, the Airlock |
TOKEN()(address) on ZoneComposerNative | EVM Zone | 0x0000000000000000000000000000000000000000, native ZRO |
ENDPOINT()(address) on ZoneComposerNative | EVM Zone | The same value as endpoint()(address) on OFTNative |
isActiveZone(uint64)(bool) with 33001 on the Airlock | EVM Zone | true |
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.
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:
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.tsOr 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 this | If you don't |
|---|---|---|
| 1 | Call 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. |
| 2 | Set 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. |
| 3 | Encode 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. |
| 4 | Set 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. |
| 5 | Quote 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. |
| 6 | Set 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. |
| 7 | Run 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. |
| 8 | Don't send to the MultiHopComposerNative or any other EVM Zone contract. | The ZRO doesn't reach the System Zone as a stake. |
Recommended
| # | Do this | If you don't |
|---|---|---|
| 9 | Follow 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. |
| 10 | Check 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
- Source transaction. The receipt holds
OFTSentfromOFT. Its first topic after the event signature is theguid. - 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 isDELIVEREDand itslzComposestatus isSUCCEEDED. Scan lists thelzReceiveandlzComposetransaction hashes on the EVM Zone. - The compose result. In the
lzComposetransaction's receipt,ZoneComposerNativeemits one of:Sent(bytes32 indexed guid, uint64 indexed dstZone, uint64 nonce): the ZRO was sent to the System Zone.nonceis 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 andZoneComposerNativeholds the stake. See When a step fails.DecodeFailed(bytes32 indexed guid, bytes message): the compose message couldn't be decoded, andZoneComposerNativeholds 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 happens | What you see | Who can act |
|---|---|---|
The source send reverts, for example because the fee is too low or the amount has dust below minAmountLD | The source transaction failed | No 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 delivered | The 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 allowlist | OFTNative credits an escrow instead, and lzCompose reverts ZeroAmount | Only the escrow's owner can return the ZRO. |
| The compose runs out of gas, or the Airlock call reverts | Scan shows lzCompose failed | The compose stays retryable on the endpoint. Anyone can call lzCompose on the endpoint again with enough gas. |
| The System Zone isn't active | UnroutableZone | ZoneComposerNative 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 decoded | DecodeFailed | Only 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 bytes | Sent, but no credit on the System Zone | The 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:
| Step | Transaction | Result |
|---|---|---|
| Send on Ethereum | 0x8f2fa8896f8ac0f62008165656e1afc6b4a1fefe430e9b43fcfa411063e7e6b8 | 29 ZRO burned. nativeFee and msg.value 0.000154373611511595 ETH. 348,477 gas |
| Message | guid 0xb08a224a2ba14b62c5d9a4b43fe09a37b04104818f193b11e662a8c997efe0e7On LayerZero Scan | DELIVERED. Four DVNs verified |
lzReceive on the EVM Zone | 0xcabfe6f17692852a87caf8a88d68b0ea27e658c8693ef22a16870e2678b539a4 | OFTReceived: 29 ZRO credited to ZoneComposerNative. Block 38331 |
lzCompose on the EVM Zone | 0x491f7a3419b4f6c4efb200354724a4afb48a2b31e6157a6eea4f61c3b50be15d | Sent(guid, 33001, 3847). 44,249,009 gas. Block 38332 |
| Field | Value |
|---|---|
| Staker | 0x6067284E0DEacc5cA67222a0bEba31AEF61b4bc9Also the compose message's recipient and the refund address |
| A second stake, from Base | 0xeedce111586bc44439aa590910a382ae7f112c2263570df4cdeabbc84a55ece4The same fields with 2.32 ZRO and its own sender. Message on LayerZero Scan |
The decoded send of the 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