Skip to main content
Version: Endpoint V1

Set Trusted Remotes

For a contract using LayerZero, a trusted remote is another contract it will accept messages from

What is a Trusted Remote

A trusted remote is the 40 bytes (for evm-to-evm messaging) that identifies another contract which you will receive messages from within your LayerZero User Application contract. The 40 bytes object is the packed bytes of the remoteAddress + localAddress

The reason to care about Trusted Remotes is that from a security perspective contracts should only receive messages from known contracts. Hence, contracts are securely connected by "setting trusted remotes"

The team has produced this GitHub Repository as an example of how to automate setting trusted remotes.

40 byte Format

info

for EVM <-> EVM, A Trusted Remote is 40 bytes. It is the REMOTE contract address concatenated with the LOCAL contract address.

Solana, Aptos, et al. & 32 Byte Addresses

caution

For NON-evm chains with addresses that are not 20 bytes obviously the Trusted Remotes will not be exactly 40 bytes, but we will regularly use "40 byte" Trusted Remotes in the nomenclature.

Generate TrustedRemote Using Ethers.js

// the trusted remote (or sometimes referred to as the path or pathData)
// is the packed 40 bytes object of the REMOTE + LOCAL user application contract addresses
let trustedRemote = hre.ethers.utils.solidityPack(
['address', 'address'],
[remoteContract.address, localContract.address],
);

Trusted Remote Usage

The Trusted Remote is now used in a few places. Here is a list of which functions expect the trusted remote format:

FunctionParamIs it a trusted remote?
retryPayload()_srcAddress
hasStoredPayload()_srcAddress
forceResumeReceive()_srcAddress
setTrustedRemote()_srcAddress
isTrustedRemote()_srcAddress
lzReceive()_srcAddress