UA Custom Configuration Overview
User Application contracts may set their own configuration for block confirmation, send version, relayer, oracle, etc.
When a UA wishes to configure their own block confirmations both the outboundBlockConfirmations
of the source and the inboundBlockConfirmations
of the destination must be configured and match.
How to Configure
A User Application (UA) can use non-default protocol settings, and to do so it must implement the interface ILayerZeroUserApplicationConfig
. The UA may then manually update its ApplicationConfig
. See examples below as well as the CONFIG_TYPES
.
This function would be implemented in your UA. This is included in LZapp.sol
if you inherit from it.
function setConfig(
uint16 _version,
uint16 _chainId,
uint _configType,
bytes calldata _config
) external override onlyOwner {
lzEndpoint.setConfig(_version, _chainId, _configType, _config);
}
Config Types
Type | Value |
---|---|
CONFIG_TYPE_INBOUND_PROOF_LIBRARY_VERSION | 1 |
CONFIG_TYPE_INBOUND_BLOCK_CONFIRMATIONS | 2 |
CONFIG_TYPE_RELAYER | 3 |
CONFIG_TYPE_OUTBOUND_PROOF_TYPE | 4 |
CONFIG_TYPE_OUTBOUND_BLOCK_CONFIRMATIONS | 5 |
CONFIG_TYPE_ORACLE | 6 |
The config should be abi encoded.
ethers.utils.defaultAbiCoder.encode([configValueType], [newValue]);
Set: Inbound Proof Library
Config | Definition |
---|---|
1 | MPT |
2 | Feather Proof |
let config = ethers.utils.defaultAbiCoder.encode(['uint16'], [inboundProofLibraryVersion]);
await UA.setConfig(0, dstChainId, CONFIG_TYPE_INBOUND_PROOF_LIBRARY_VERSION, config);
CONFIG_TYPE_INBOUND_PROOF_LIBRARY_VERSION
is 1
in this casse
Set: Inbound Block Confirmations
Config | Definition |
---|---|
42 | How many block confirmations is needed for inbound block confirmations |
let config = ethers.utils.defaultAbiCoder.encode(['uint16'], [42]);
await UA.setConfig(0, dstChainId, CONFIG_TYPE_INBOUND_BLOCK_CONFIRMATIONS, config);
Set: Relayer
Config | Definition |
---|---|
relayerAddr | Which relayer you want to use |
let config = ethers.utils.solidityPack(['address'], [relayerAddr]);
await UA.setConfig(0, dstChainId, CONFIG_TYPE_RELAYER, config);
Set: Outbound Proof Type/LibraryVersion
Config | Definition |
---|---|
1 | MPT |
2 | Feather Proof |
let config = ethers.utils.defaultAbiCoder.encode(['uint16'], [outboundProofType]);
await UA.setConfig(0, dstChainId, CONFIG_TYPE_OUTBOUND_PROOF_TYPE, config);
Set: Outbound Block Confirmations
Config | Definition |
---|---|
42 | How many block confirmations is needed for outbound block confirmations |
let config = ethers.utils.defaultAbiCoder.encode(
['uint16'],
[17], // outbound block confirmations
);
await UA.setConfig(0, dstChainId, CONFIG_TYPE_OUTBOUND_BLOCK_CONFIRMATIONS, config);
Set: Oracle
Config | Definition |
---|---|
Oracle Address | Which oracle to use |
The available oracles can be found here. (Select the oracle type you prefer)
Oracle settings are configured per channel pathway, meaning UAs who want to lock Oracle configs will need to call setConfig
per chain pairing.
let config = ethers.utils.defaultAbiCoder.encode(['address'], [oracleAddr]);
await UA.setConfig(0, dstChainId, CONFIG_TYPE_ORACLE, config);