Sample Contracts to handle transactions on L1 from StarkNet L2 L1L2 #StarkNet repository to automate Swaps on L1 from L2 (e.g swapping directly on Uniswap based on price using @EmpiricNetwork) This could be a good stepping stone for creating automated strategy directly from L2 using L1 liquidity(dca, ..)
The L1 Contrat will behave like a Pool Contract where users can deposit tokens and therefore sharing fees while consumming L2 message.
Contracts on L2 can interact asynchronously with contracts on L1 via the L2 -> L1 messaging protocol. How this works ?
-
The StarkNet(L2) contract calls the syscall starknet function
send_message_to_l1()
- The destination L1 contract to send message
- the payload size
- The payload data to send
-
The L1 contract specified by the to address invokes the
consumeMessageFromL2()
of the StarkNet core contract. Since any L2 contract can send message to any L1 contract, it's highly recommended that the L1 contract check the from address.
Since we will handle both L1 contracts and L2 contracts, the projeect setup needs to be done seperatly in 2 different environment :
- L1 - Solidity Contracts
Go to L1 repository and check README.md
cd L1
- L2 - Cairo Contracts
Go to L2 repository and check README.md
cd L2