A centralised indexer or relayer can be used as one of many means of communication between layer 2 and layer 1 blockchains. The information exchange between the layer 2 and layer 1 blockchains is handled by this server. The server will keep tabs on the layer 2 blockchain's transactions and state updates, and it will use the Ethereum JSON-RPC API to relay these updates to the Ethereum mainnet.
Using a sidechain is another way to communicate between layer 2 and layer 1 blockchains. A sidechain is built in this configuration and linked to the Ethereum mainnet. Nodes have the ability to verify sidechain transactions before sending the verified transactions to the Ethereum mainnet.
The usage of a cross-chain atomic swap is the final direct method of communication between layer 2 and layer 1 blockchains. With the help of this technique, cross-chain swaps can be done securely without a centralised party.
On both blockchains, a smart contract is created and contains a deposit from each party. By transferring their respective assets to the smart contracts, the two parties can then carry out an exchange. Before releasing the assets to the other party, the contracts will confirm that the assets have been received. With the help of this technique, blockchains can communicate in a secure, decentralised manner.