Default OApp Configuration
Child OApp contract configurations are considered active once the OApp owner calls setPeer
for each LayerZero pathway.
If you provide no changes to your application's configuration prior to setting peers, the protocol will interpret your empty OApp configuration as the default configuration.
Default Configuration
The default configuration varies between different chains based on the unique properties of each chain, and which providers run production assets for those networks.
- Security Stack: Varies per chain pathway
- Executor: LayerZero Labs
- Message Library Version: ULN302
- Block Confirmations: Varies per chain pathway
To check the default configuration, you can call the source LayerZero Endpoint to return the default configuration for that destination Endpoint.
The create-lz-oapp npx package provides a hardhat task to check the default configuration for each pathway!
npx hardhat lz:oapp:config:get:default
Custom Configuration
To use non-default protocol settings, the delegate (should always be OApp owner) must call setConfig
from the OApp's Endpoint.
The setDelegate
function in LayerZero's OApp allows the contract owner to appoint a delegate who can manage configurations for both the Executor and ULN. This delegate, once set, has the authority to modify configurations on behalf of the OApp owner. We strongly recommend you always make sure owner and delegate is the same address.
In general, you will start by defining your config based on the following function set in the Endpoint:
/// @dev authenticated by the _oapp
function setConfig(
address _oapp,
address _lib,
SetConfigParam[] calldata _params
) external onlyRegistered(_lib) {
_assertAuthorized(_oapp);
IMessageLib(_lib).setConfig(_oapp, _params);
}
The SetConfigParam
struct is where you set custom parameters for a given configType
and the remote chain's eid
(endpoint ID):
struct SetConfigParam {
uint32 dstEid;
uint32 configType;
bytes config;
}
Configuration types are categorized by their respective components, such as ULN and Executor, for more targeted adjustments.
CONFIG_TYPE_ULN = 2;
CONFIG_TYPE_EXECUTOR = 1;
Each config
is encoded and passed as an ordered bytes array in your SetConfigParam
struct.
Setting your Configuration
To fine-tune your OApp's communication abilities, you can modify both the Security Stack (set of DVNs) and Executor configurations in a single setConfig
call. This customization enhances control over message handling and execution across different blockchains.
To correctly invoke setConfig
with both configurations, you need to call the endpoint on the chain you are setting configurations for. Here's how you can do it:
- Define parameters
// Using ethers v5
const oappAddress = 'YOUR_OAPP_ADDRESS'; // Replace with your OApp address
const messageLibAddress = 'YOUR_LIB_ADDRESS'; // Replace with your message library address
const provider = new ethers.providers.JsonRpcProvider(YOUR_RPC_URL);
const signer = new ethers.Wallet(YOUR_PRIVATE_KEY, provider);
const endpointContract = new ethers.Contract(YOUR_ENDPOINT_CONTRACT_ADDRESS, YOUR_ENDPOINT_ABI, signer);
const setConfigParams = [...]; // Array of SetConfigParam structs, encoded as needed
- Sending the transaction
const tx = await endpointContract.setConfig(oappAddress, libAddress, setConfigParams);
await tx.wait();
Setting Multiple Configurations
To fine-tune your OApp's communication abilities, you can modify both the Security Stack (DVN) and Executor configurations in a single setConfig
call. This customization enhances control over message handling and execution across different blockchains.
To invoke setConfig
with both configurations:
const tx = await endpointContract.setConfig(oappAddress, messageLibraryAddress, [
setConfigParamUln,
setConfigParamExecutor,
]);
await tx.wait();
For detailed, step-by-step instructions on configuring your Executor and DVN (Decentralized Verifier Networks), please refer to their respective sections: Executor Configuration and Security Stack Configuration. These guides will walk you through the process, ensuring your OApp Config is properly set.
Resetting Configurations
See the attached links for specific implementation details on how to reset configurations for Executors and your Security Stack.
Snapshotting Configurations
See the attached links for specific implementation details on how to snapshot configurations for Executors and your Security Stack.