I understand what a bridge does but I 'm interested in knowing how it works under the hood. How does it work when transferring assets from one network to another. Lets take for example the ethereum to matic polygon bridge and say I want to transfer an ERC-20 token from Ethereum to Matic:
- So I go to https://wallet-dev.polygon.technology/bridge
- I select the ERC-20 token I want to transfer from Ethereum.
- I approve/confirm transaction
How do the smart contracts interact because I'm assuming the L1 smart contract can't send a signal to the L2 smart contract on Matic for the token transfer. Is it that there exists some code not written in a smart contract programming language e.g. Solidity but something off the chain that poll's the L1 smart contract to see if there's been a token transfer on the smart contract bridge and then creates a new transaction on the L2 bridge to complete the transaction ? Because I'm assuming a smart contract will not be able to automate the full process of transferring assets there has to be some middleman (software) that looks at the L1 contract to determine if there has been a transfer and then that software triggers the L2 contract to send the token transfer to the user on the matic network ?