Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3cc85fe
add test
critesjosh Jan 28, 2025
310b3eb
update
critesjosh Jan 28, 2025
5d066b1
rm old
critesjosh Jan 28, 2025
546d083
fix links
critesjosh Jan 29, 2025
48536f1
update comments
critesjosh Jan 29, 2025
8df63f6
write tutorial
critesjosh Jan 29, 2025
903887a
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Jan 29, 2025
7220398
clarify
critesjosh Jan 29, 2025
a276228
Merge branch 'jc/docs-bridge-tutorial' of https://github.com/AztecPro…
critesjosh Jan 29, 2025
cb2e4c4
use compose for test
critesjosh Jan 30, 2025
84528d3
fix link to test file
critesjosh Jan 30, 2025
2353b49
fmt
critesjosh Jan 30, 2025
402a54e
run test w/ compose
critesjosh Jan 30, 2025
37a88e4
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Jan 30, 2025
cf5cc72
fmt
critesjosh Jan 30, 2025
c2f8201
fix filename
critesjosh Jan 30, 2025
61f46b1
add token bridge test to ci
critesjosh Jan 31, 2025
a4a7cf0
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Jan 31, 2025
e884962
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Jan 31, 2025
d7c93fa
passing
critesjosh Jan 31, 2025
9732e5f
try bump test timeout
critesjosh Jan 31, 2025
4890cbf
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Jan 31, 2025
d742f5a
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Feb 2, 2025
74f107f
cats comments
critesjosh Feb 5, 2025
f8dba2a
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Feb 5, 2025
a3855c7
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Feb 5, 2025
4ffb66d
fix links
critesjosh Feb 5, 2025
450ac31
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Feb 5, 2025
80acf5c
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Feb 6, 2025
47036ce
add cat's suggestions
critesjosh Feb 7, 2025
da23343
update rootDir
critesjosh Feb 7, 2025
685c44f
simp tsconfig, specify node version
critesjosh Feb 7, 2025
531540b
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Feb 7, 2025
41c5188
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Feb 10, 2025
eedceea
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Feb 10, 2025
8037bae
james comments
critesjosh Feb 11, 2025
9ce59b4
Merge branch 'master' into jc/docs-bridge-tutorial
critesjosh Feb 12, 2025
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
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ Hence, it's necessary to add a "randomness" field to your note to prevent such a

### L1 -- L2 interactions

Refer to [Token Portal codealong tutorial on bridging tokens between L1 and L2](../../../../tutorials/codealong/contract_tutorials/token_bridge/0_setup.md) and/or [Uniswap smart contract example that shows how to swap on L1 using funds on L2](../../../../tutorials/codealong/contract_tutorials/uniswap/index.md). Both examples show how to:
Refer to [Token Portal codealong tutorial on bridging tokens between L1 and L2](../../../../tutorials/codealong/contract_tutorials/token_bridge.md) and/or [Uniswap smart contract example that shows how to swap on L1 using funds on L2](../../../../tutorials/codealong/contract_tutorials/uniswap/index.md). Both examples show how to:

1. L1 -> L2 message flow
2. L2 -> L1 message flow
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title: Communicating with L1
tags: [contracts, portals]
---

Follow the [token bridge tutorial](../../../../tutorials/codealong/contract_tutorials/token_bridge/index.md) for hands-on experience writing and deploying a Portal contract.
Follow the [token bridge tutorial](../../../../../tutorials/codealong/contract_tutorials/token_bridge.md) for hands-on experience writing and deploying a Portal contract.

## Passing data to the rollup

Expand All @@ -13,10 +13,10 @@ The `Inbox` can be seen as a mailbox to the rollup, portals put messages into th

When sending messages, we need to specify quite a bit of information beyond just the content that we are sharing. Namely we need to specify:

| Name | Type | Description |
| ----------- | ------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Recipient | `L2Actor` | The message recipient. This **MUST** match the rollup version and an Aztec contract that is **attached** to the contract making this call. If the recipient is not attached to the caller, the message cannot be consumed by it. |
| Secret Hash | `field` (~254 bits) | A hash of a secret that is used when consuming the message on L2. Keep this preimage a secret to make the consumption private. To consume the message the caller must know the pre-image (the value that was hashed) - so make sure your app keeps track of the pre-images! Use `computeSecretHash` to compute it from a secret. |
| Name | Type | Description |
| ----------- | ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Recipient | `L2Actor` | The message recipient. This **MUST** match the rollup version and an Aztec contract that is **attached** to the contract making this call. If the recipient is not attached to the caller, the message cannot be consumed by it. |
| Secret Hash | `field` (~254 bits) | A hash of a secret that is used when consuming the message on L2. Keep this preimage a secret to make the consumption private. To consume the message the caller must know the pre-image (the value that was hashed) - so make sure your app keeps track of the pre-images! Use `computeSecretHash` to compute it from a secret. |
| Content | `field` (~254 bits) | The content of the message. This is the data that will be passed to the recipient. The content is limited to be a single field. If the content is small enough it can just be passed along, otherwise it should be hashed and the hash passed along (you can use our [`Hash` (GitHub link)](https://github.com/AztecProtocol/aztec-packages/blob/master/l1-contracts/src/core/libraries/Hash.sol) utilities with `sha256ToField` functions) |

With all that information at hand, we can call the `sendL2Message` function on the Inbox. The function will return a `field` (inside `bytes32`) that is the hash of the message. This hash can be used as an identifier to spot when your message has been included in a rollup block.
Expand All @@ -41,7 +41,7 @@ Note that while the `secret` and the `content` are both hashed, they are actuall

### Token bridge example

Computing the `content` must currently be done manually, as we are still adding a number of bytes utilities. A good example exists within the [Token bridge example (codealong tutorial)](../../../../tutorials/codealong/contract_tutorials/token_bridge/index.md).
Computing the `content` must currently be done manually, as we are still adding a number of bytes utilities. A good example exists within the [Token bridge example (codealong tutorial)](../../../../../tutorials/codealong/contract_tutorials/token_bridge.md).

#include_code claim_public /noir-projects/noir-contracts/contracts/token_bridge_contract/src/main.nr rust

Expand Down
Loading