A user, operating on the mainchain, sends X tokens to a custom address that locks assets. Those funds are locked on the mainchain, and a corresponding number of tokens are created on the sidechain. The user can now use the tokens on the sidechain. Eventually, the user can transfer back the tokens to the main chain, which causes assets on the sidechain to be locked or destroyed, depending on the implementation.
Three major types of two-way pegs
Example services: BTC Relay, Zendoo
How it Works
hand an earlier timelock than Alice's
sbefore the earlier timelock to acquire his assets
sto Alice's smart contract between the two time intervals to acquire her assets
A trusted federation to attest to events on another chain. This federation will verify to chain A that an event on chain B took place. The notaries will come to an agreement via some consensus algorithm and will issue a signature that can be used to finalize payments on chain A conditional on this consensus.
Federated Pegged Sidechain
The federation will be in control of a multisig address on chain A such that assets locked up in the multisig can be issued synthetically on the sidechain (chain B). Liquid network does this(?)
Instead of having a federation that verifies events on another chain, relays allow the chains to do this themselves.
Contract on chain A that functions as a light client of chain B, using chain B’s standard verification procedure to verify block headers fed into the contract.
E.g. BTCRelay is a smart contract on Ethereum that can read the Bitcoin chain. However, it's 1-way; Bitcoin can't read the Ethereum chain as there is no Ethereum relay contract on Bitcoin.
Relayers are those who submit block headers to BTC Relay. To incentivize the community to be relayers, and thus allow BTC Relay to be autonomous and up-to-date with the Bitcoin blockchain, Relayers can submit block headers to BTC Relay. When any transaction is verified in the block, or the header is retrieved, Relayers will be rewarded a fee. ~How to be a Relayer and receive incentives?
Today's relays are mostly 1-way pegged. There's work happening on 2-way pegs via a central hub called a relay chain**.
Relay chains are distinct blockchains that function as light clients for connected “member” blockchains. Member chains can leverage information on other chains by messaging through the relay chain, which tracks part of the state of all connected chains and can be given a degree of control over assets on those chains
Relay chain architectures work best with chains that have certain characteristics, including flexible multisig capability and fast consensus finality, and as such are creating software development toolkits that make it easy for developers to create these types of blockchains.
...downside of the relay architecture is that it is very difficult to connect existing blockchains that don’t have the desired characteristics, including both Bitcoin and Ethereum. Cosmos and Polkadot both use variants of proof of stake (POS) and the Practical Byzantine Fault Tolerant (PBFT) family of consensus algorithms, which limit the number of nodes that actively participate in consensus in exchange for increased throughput and fast consensus finality.
Cosmos and Polkadot present potentially advantageous new paradigms for constructing blockchain networks rather than solutions targeted to existing blockchains.