Skip to content
This repository has been archived by the owner on Aug 8, 2024. It is now read-only.

Attempted to make the instructions clearer #15

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 21 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,9 @@ starknet-compile contracts/Evaluator.cairo

### Step 3 - Set up your Solidity environmment
The simplest way to develop and deploy Solidity contract is to use Remix:
Navigate to https://remix.ethereum.org/ create a new file, compile it and deploy to Goerli using metamask

## Working on the tutorial

Expand All @@ -146,7 +149,7 @@ To do this tutorial you will have to interact with the [`Evaluator.cairo`](contr

### Exercises & Contract addresses

| Contract code | Contract on voyager |
| Contract code | Contract on explorer |
| -------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [L2 Evaluator](contracts/Evaluator.cairo) | [0x595bfeb84a5f95de3471fc66929710e92c12cce2b652cd91a6fef4c5c09cd99](https://goerli.voyager.online/contract/0x595bfeb84a5f95de3471fc66929710e92c12cce2b652cd91a6fef4c5c09cd99) |
| [Points counter ERC20](contracts/token/ERC20/TDERC20.cairo) | [0x38ec18163a6923a96870f3d2b948a140df89d30120afdf90270b02c609f8a88](https://goerli.voyager.online/contract/0x38ec18163a6923a96870f3d2b948a140df89d30120afdf90270b02c609f8a88) |
Expand All @@ -161,27 +164,27 @@ To do this tutorial you will have to interact with the [`Evaluator.cairo`](contr

### Exercise 0 - Send an L2→L1→L2 message with existing contracts (2 pts)

Use a predeployed contract to mint ERC20 tokens on L1 from L2. A secret message is passed with the messages; be sure to find it in order to collect your points.
Use a predeployed contract to mint ERC20 tokens on L1 approved from L2. A secret is passed with the L2toL1 messages; be sure to find it in order to collect your points.

- Call function [`ex_0_a`](contracts/Evaluator.cairo#L121) of [*L2 Evaluator*](https://goerli.voyager.online/contract/0x595bfeb84a5f95de3471fc66929710e92c12cce2b652cd91a6fef4c5c09cd99)
- You need to specify an L1 address, and an amount of ERC20 to mint
- The secret message is sent from L2 to L1 at this stage.
- You need to specify an L1 address of a user, and an amount of ERC20 to mint
- The secret message is sent from L2 to L1 within the message.
- Call [`mint`](contracts/L1/DummyToken.sol#L37) of [*L1 DummyToken*](https://goerli.etherscan.io/address/0x0232CB90523F181Ab4990Eb078Cf890F065eC395)
- You need to show that you know the secret value at this step
- Call [`i_have_tokens`](contracts/L1/DummyToken.sol#L48) of [*L1 DummyToken*](https://goerli.etherscan.io/address/0x0232CB90523F181Ab4990Eb078Cf890F065eC395)
- This function checks that you have indeed been able to mint ERC20 tokens, and will then send a message back to L2 to credit your points
- This is done using [`ex_0_b`](contracts/Evaluator.cairo#L143) of the L2 evaluator
- This message will be automatically handled by [`ex_0_b`](contracts/Evaluator.cairo#L143) of the L2 evaluator

### Exercise 1 - Send an L2→L1 message with your contract (2 pts)

Write and deploy a contract on L2 that *sends* messages to L1.

- Write a contract on L2 that will send a message to [L1 MessagingNft](https://goerli.etherscan.io/address/0x6DD77805FD35c91EF6b2624Ba538Ed920b8d0b4E) and trigger [`createNftFromL2`](contracts/L1/MessagingNft.sol#L35)
- Your function should be called [`create_l1_nft_message`](contracts/Evaluator.cairo#L198)
- Write a contract on L2 that will send a message to [L1 MessagingNft](https://goerli.etherscan.io/address/0x6DD77805FD35c91EF6b2624Ba538Ed920b8d0b4E) and allow you to use [`createNftFromL2`](contracts/L1/MessagingNft.sol#L35) by consuming your message
- Your function should be called [`create_l1_nft_message`](contracts/Evaluator.cairo#L198) so that L2 Evaluator could trigger it properly
- Deploy your contract
- Submit the contract address to L2 Evaluator by calling its [`submit_exercise`](contracts/Evaluator.cairo#L166)
- Call [`ex1a`](contracts/Evaluator.cairo#L188) of L2 Evaluator to trigger the message sending to L2
- Call [`createNftFromL2`](contracts/L1/MessagingNft.sol#L35) of L1 MessagingNft to trigger the message consumption on L1
- Call [`ex1a`](contracts/Evaluator.cairo#L188) of L2 Evaluator to trigger the message sending by your contract to L1
- Call [`createNftFromL2`](contracts/L1/MessagingNft.sol#L35) of L1 MessagingNft to consumme message on L1
- L1 MessagingNft [sends back](contracts/L1/MessagingNft.sol#L47) a message to L2 to [credit your points](contracts/Evaluator.cairo#L205) on L2

### Exercise 2 - Send an L1→L2 message with your contract (2 pts)
Expand All @@ -193,24 +196,24 @@ Write and deploy a contract on L1 that *sends* messages to L2.
- You can get latest address of the StarkNet Core Contract Proxy on Goerli by running `starknet get_contract_addresses --network alpha-goerli` in your CLI
- Learn how to get the [selector](https://starknet.io/docs/hello_starknet/l1l2.html#receiving-a-message-from-l1) of a StarkNet contract function
- Deploy your contract
- Trigger the message sending on L1. Your points are automatically attributed on L2.
- Use it to send a message to L2 Evaluator from L1. Your points are automatically attributed on L2.

### Exercise 3 - Receive an L2→L1 message with your contract (2 pts)

- Write a contract on L1 that will receive a message from from function [`ex3_a`](contracts/Evaluator.cairo#L231).
- Write a contract on L1 that will consumme a message from function [`ex3_a`](contracts/Evaluator.cairo#L231).
- Make sure your contract is able to handle the message.
- Your message consumption function should be called [`consumeMessage`](contracts/L1/Evaluator.sol#L51)
- Deploy your L1 contract
- Call [`ex3_a`](contracts/Evaluator.cairo#L231) of [*L2 Evaluator*](https://goerli.voyager.online/contract/0x595bfeb84a5f95de3471fc66929710e92c12cce2b652cd91a6fef4c5c09cd99) to send an L2→L1 message
- Call [`ex3`](contracts/L1/Evaluator.sol#L32)of *L1 Evaluator*, which triggers message consumption from your L1 contract
- Call [`ex3`](contracts/L1/Evaluator.sol#L32)of *L1 Evaluator*, which consumes a message from your L1 contract
- L1 evaluator will also [send back](contracts/L1/Evaluator.sol#L57) a message to L2 to distribute your points

### Exercise 4 - Receive an L1→L2 message with your contract (2 pts)

- Write a L2 contract that is able to receive a message from [`ex4`](contracts/L1/Evaluator.sol#L60) of [*L1 Evaluator*](https://goerli.etherscan.io/address/0x8055d587A447AE186d1589F7AAaF90CaCCc30179)
- Write a L2 contract that is able to handle a message from [`ex4`](contracts/L1/Evaluator.sol#L60) of [*L1 Evaluator*](https://goerli.etherscan.io/address/0x8055d587A447AE186d1589F7AAaF90CaCCc30179)
- You can name your function however you like, since you provide the function selector as a parameter on L1
- Deploy your contract on L2
- Call [`ex4`](contracts/L1/Evaluator.sol#L60) of *L1 Evaluator* to send the random value out to your L2 contract
- Call [`ex4`](contracts/L1/Evaluator.sol#L60) of *L1 Evaluator* to send the random value out to your L2 contract and to L2 Evaluator
- Submit your L2 contract address by calling [`submit_exercise`](contracts/Evaluator.cairo#L166) of *L2 Evaluator*
- Call [`ex4_b`](contracts/Evaluator.cairo#L266) of *L2 Evaluator* that will check you completed your work correctly and distribute your points

Expand Down Expand Up @@ -256,7 +259,10 @@ You can (and should) check the status of your transaction with the following URL

### Articles & documentation

- [Messaging Mechanism | StarkNet Docs](https://docs.starknet.io/docs/L1%3C%3EL2%20Communication/messaging-mechanism)
- [Messaging Mechanism | StarkNet Docs](https://docs.starknet.io/documentation/architecture_and_concepts/L1-L2_Communication/messaging-mechanism/)
- [Interacting with L1 contracts | StarkNet Documentation](https://starknet.io/docs/hello_starknet/l1l2.html)
- Sample Project: [StarkNet graffiti | GitHub](https://github.com/l-henri/StarkNet-graffiti)
- [Thread on StarkNet ⇄ Ethereum Messaging | Twitter](https://twitter.com/HenriLieutaud/status/1466324729829154822)
- It is also usefull to bear in mind the following simplified schema:
![alt text](https://github.com/panda4us/starknet-messaging-bridge/blob/main/images/simplified_messaging_schema.png?raw=true)

Binary file added images/simplified_messaging_schema.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.