layerzero-messaging
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseLayerZero Messaging (Hedera)
LayerZero 消息传递(Hedera)
OFT pattern: deploy paired Omnichain Fungible Tokens — a standard on the EVM side and an HTS connector OFT on Hedera — then both ways and send with LayerZero V2 fees.
OFTsetPeertext
OFT (EVM) ←setPeer→ HTSConnectorOFT (Hedera)
│ send / quoteSend │ _debit burn / _credit mint (HTS 0x167)
└──────── Endpoint V2 + ULN + DVN + Executor ────────┘This skill focuses on LayerZero V2 OApp/OFT + Hedera HTS. Educational templates may use simple workers and a manual/UI relay — not the same as production LayerZero Labs verification.
lzReceiveOFT模式: 部署配对的全链同质化代币——EVM侧为标准,Hedera侧为HTS连接器OFT——之后双向执行,并支付LayerZero V2费用进行消息发送。
OFTsetPeertext
OFT (EVM) ←setPeer→ HTSConnectorOFT (Hedera)
│ send / quoteSend │ _debit burn / _credit mint (HTS 0x167)
└──────── Endpoint V2 + ULN + DVN + Executor ────────┘本技能聚焦于LayerZero V2 OApp/OFT + Hedera HTS。教学模板可能会使用简单工作节点和手动/UI式中继——这与生产环境的LayerZero Labs验证机制不同。
lzReceiveQuick Reference
快速参考
| Concept | Rule |
|---|---|
| Endpoint | |
| Peer | |
| Send | |
| Receiver | |
| Hedera OFT | HTS-backed connector — create HTS token, burn on send, mint on receive |
| HTS fee | Deploy connector with native value to pay |
| Approval | User must |
| IDs | Use LayerZero EIDs in peers/ |
See references/hedera-endpoints.md for where to source Endpoint/ULN/DVN addresses. See references/examples.md for wire and send sketches.
| 概念 | 规则 |
|---|---|
| Endpoint | 每条链对应一个 |
| Peer | 需在两端执行 |
| Send | 先调用 |
| Receiver | |
| Hedera OFT | HTS支撑的连接器——创建HTS代币,发送时销毁,接收时铸造 |
| HTS fee | 部署连接器时附带原生代币价值,用于支付 |
| Approval | 在Hedera向EVM执行 |
| IDs | 在对等节点/ |
Endpoint/ULN/DVN地址的获取方式请参考references/hedera-endpoints.md。连接配置与发送流程的示例请参考references/examples.md。
Critical: Wire Both Directions
关键注意事项:双向配置连接
Incomplete peer config bricks the pathway. For each local OApp:
setPeer(remoteEid, remoteOAppAsBytes32)- /
setSendLibrary(ULN302)setReceiveLibrary - — ExecutorConfig (type
setConfig) on send lib; UlnConfig (type1) on send + receive libs2 - — e.g.
setEnforcedOptionsgas for msgTypelzReceive(token send)1
Verify with on both chains before sending.
peers(remoteEid)对等节点配置不完整会导致通路完全失效。对于每个本地OApp,需完成以下配置:
setPeer(remoteEid, remoteOAppAsBytes32)- 配置/
setSendLibrary(使用ULN302)setReceiveLibrary - 执行——发送库配置ExecutorConfig(类型
setConfig);发送库与接收库均需配置UlnConfig(类型1)2 - 配置——例如为消息类型
setEnforcedOptions(代币发送)设置1的gas上限lzReceive
发送前,请在两条链上分别调用验证配置是否正确。
peers(remoteEid)Critical: Hedera HTS Connector Semantics
关键注意事项:Hedera HTS连接器语义
On Hedera, do not use a plain ERC-20 OFT as the primary path. Use an HTS-backed connector:
- Constructor creates fungible HTS via precompile (supply key = connector)
0x167 - : transfer HTS in → burn
_debit - : mint → transfer HTS out
_credit - Amounts must fit for HTS mint/burn/transfer
int64 - Associate the receiver account with the HTS token before EVM → Hedera receives
solidity
// Deploy with value so createFungibleToken fee is paid
new HTSConnectorOFT{ value: htsCreateValue }(name, symbol, lzEndpoint, owner);在Hedera上,请勿使用普通ERC-20 OFT作为主通路,应使用HTS支撑的连接器:
- 构造函数通过预编译合约创建同质化HTS代币(供应密钥为连接器合约)
0x167 - :转入HTS → 销毁
_debit - :铸造 → 转出HTS
_credit - HTS的铸造/销毁/转账金额必须在范围内
int64 - 在EVM向Hedera转账前,需将接收方账户与HTS代币进行关联
solidity
// Deploy with value so createFungibleToken fee is paid
new HTSConnectorOFT{ value: htsCreateValue }(name, symbol, lzEndpoint, owner);Send Flow
发送流程
solidity
SendParam memory sendParam = SendParam({
dstEid: remoteEid,
to: bytes32(uint256(uint160(receiver))),
amountLD: amountLD,
minAmountLD: (amountLD * 9) / 10,
extraOptions: OptionsBuilder.newOptions().addExecutorLzReceiveOption(lzReceiveGas, 0),
composeMsg: "",
oftCmd: ""
});
MessagingFee memory fee = IOFT(localOFT).quoteSend(sendParam, false);
IOFT(localOFT).send{ value: fee.nativeFee }(sendParam, fee, payable(refundTo));Hedera → EVM note: forge fee simulation can disagree with Hedera JSON-RPC wei/tinybar scaling — often via + scaled native fee for that direction.
quotecastsolidity
SendParam memory sendParam = SendParam({
dstEid: remoteEid,
to: bytes32(uint256(uint160(receiver))),
amountLD: amountLD,
minAmountLD: (amountLD * 9) / 10,
extraOptions: OptionsBuilder.newOptions().addExecutorLzReceiveOption(lzReceiveGas, 0),
composeMsg: "",
oftCmd: ""
});
MessagingFee memory fee = IOFT(localOFT).quoteSend(sendParam, false);
IOFT(localOFT).send{ value: fee.nativeFee }(sendParam, fee, payable(refundTo));Hedera → EVM注意事项: forge的费用模拟结果可能与Hedera JSON-RPC的wei/tinybar换算比例不一致——该方向通常使用调用并按比例调整原生代币费用。
castquoteDeploy Checklist (generic)
部署检查清单(通用)
- Deploy EVM (optional premint)
OFT - Deploy Hedera HTS connector OFT with HTS create value
- Deploy workers (Labs DVN/executor or educational simple workers)
- Wire both OApps (+ libraries + config + enforced options)
setPeer - Associate Hedera account with
htsTokenAddress() - Sync frontend config if applicable; fund relay key if using UI auto-relay
- Send small amount; track on LayerZero Scan (testnet/mainnet as appropriate)
- 部署EVM端(可选择预铸造)
OFT - 附带HTS创建费用,部署Hedera HTS连接器OFT
- 部署工作节点(可使用Labs DVN/执行器或教学用简单工作节点)
- 配置两个OApp的双向连接(+ 库配置 + 参数配置 + 强制选项)
setPeer - 将Hedera账户与对应的代币关联
htsTokenAddress() - 如适用,同步前端配置;如使用UI自动中继,为中继密钥充值
- 发送小额测试;在LayerZero Scan上追踪交易(根据环境选择测试网/主网)
Educational Relay
教学用中继
Some templates use simple DVN/executor mocks and an explicit relay step. Treat that as a learning aid — production apps rely on LayerZero’s verification network, not a custom relayer key in the app server.
lzReceive部分模板使用简易DVN/执行器模拟程序和显式的中继步骤。这仅作为学习辅助——生产应用应依赖LayerZero的验证网络,而非应用服务器中自定义的中继密钥。
lzReceiveChecklist
检查清单
- Peers set both ways with correct EIDs (not EVM chain IDs)
- Send/receive libraries + ULN/executor config applied
- Hedera side is HTS connector; create fee paid; supply key is connector
- Receiver associated with HTS token before inbound transfers
- native fee attached to
quoteSendsend - Receiver address encoded as
bytes32 - Educational disclaimer: not audited / not for mainnet funds
- 已双向配置对等节点,且使用正确的EIDs(而非EVM链ID)
- 已配置发送/接收库 + ULN/执行器参数
- Hedera端为HTS连接器;已支付创建费用;供应密钥为连接器合约
- 入账前,接收方已与HTS代币关联
- 调用已附带
send计算出的原生代币费用quoteSend - 接收方地址已编码为格式
bytes32 - 教学免责声明:未经过审计/不可用于主网资金
References
参考资料
- references/examples.md — OFT, HTS connector, wire, send
- references/hedera-endpoints.md — EIDs vs chain IDs, where to source addresses
- LayerZero V2 docs
- LayerZero deployments metadata
- references/examples.md — OFT、HTS连接器、连接配置、发送流程
- references/hedera-endpoints.md — EID与链ID的区别、地址获取方式
- LayerZero V2 官方文档
- LayerZero部署元数据