Project scaffold
LayerZero’s CLI lets you spin up an OFT workspace in seconds:Add private keys
Rename.env.example file to .env and update it with needed configurations:
PRIVATE_KEY. RPC URLs are optional, but strongly recommended. If you don’t provide them, public RPCs will be used, but public RPCs can be unreliable or slow, leading to long waiting times for transactions to be confirmed or, at worst, cause your transactions to fail.
Hardhat network config
Update yourhardhat.config.ts file to include the networks you want to deploy your contracts to:
LayerZero wiring config
Modify yourlayerzero.config.ts file to include the chains and channel security settings you want for each connection:
The token contract
contracts/MyOFT.sol
Deploy
Connect the chains
Transfer
Calling send
Since the send logic has already been defined, we’ll instead view how the function should be called.
Done!
You’ve issued an omnichain token and bridged it from Blast Mainnet to Optimism. Customize supply logic, fees, or add more chains by applying changes to the core contract, redeploying, and repeating the wiring step.Troubleshooting
If yourquoteSend call reverts, it usually means that your LayerZero wiring hasn’t been fully configured or there’s no default pathway for the chains you’re trying to bridge. Here’s how to diagnose and fix it:
-
Wiring Didn’t Succeed
Run the following to inspect your on‑chain wiring configuration:See that your source configuration has a valid send library, DVN address, and target eid. -
No Default Pathway
LayerZero default settings should be considered placeholders. Sometimes the LayerZero defaults will contain aLzDeadDVN. Those entries indicate that a default pathway setting does not exist.- Check: You can see if your configuration contains a LzDeadDVN by viewing the Default Config Checker on LayerZero Scan.
-
Fix: Open your
layerzero.config.tsand under the relevantpathwaysentry, add working DVN providers (in the[ requiredDVN[], [ optionalDVN[], threshold ] ]section). -
Re-run your wiring command for the connections so that the wiring on both chains is live.
quoteSend flow. It should now return a fee estimate instead of reverting.
Next steps
- See the Configuring Pathways section to learn more about managing your OFTs across the entire network mesh.
- See the Available DVNs and Executor to configure between.
- Learn how the protocol works by reading the Core Concepts section.
- Learn more about how the OFT contract works on the EVM by reading the OFT Quickstart in the EVM section.