You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We will also be writing some helper functions that should exist elsewhere so we don't overcomplicated our contract. In `src` create two more files - one called `util.nr` and one called `token_interface` - so your dir structure should now look like this:
@@ -74,6 +75,7 @@ aztec-contracts
74
75
├── src
75
76
├── main.nr
76
77
├── token_interface.nr
78
+
├── util.nr
77
79
```
78
80
79
81
# Create a JS hardhat project
@@ -99,7 +101,7 @@ touch TokenPortal.sol
99
101
Now add dependencies that are required. These include interfaces to Aztec Inbox, Outbox and Registry smart contracts, OpenZeppelin contracts, and NomicFoundation.
Copy file name to clipboardExpand all lines: docs/docs/dev_docs/tutorials/token_portal/withdrawing_to_l1.md
+13-7Lines changed: 13 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,8 +42,10 @@ For both the public and private flow, we use the same mechanism to determine the
42
42
After the transaction is completed on L2, the portal must call the outbox to successfully transfer funds to the user on L1. Like with deposits, things can be complex here. For example, what happens if the transaction was done on L2 to burn tokens but can’t be withdrawn to L1? Then the funds are lost forever! How do we prevent this?
#include_code token_portal_withdraw /l1-contracts/test/portals/TokenPortal.sol raw
47
+
}
48
+
```
47
49
48
50
Here we reconstruct the L2 to L1 message and check that this message exists on the outbox. If so, we consume it and transfer the funds to the recipient. As part of the reconstruction, the content hash looks similar to what we did in our bridge contract on aztec where we pass the amount and recipient to the the hash. This way a malicious actor can’t change the recipient parameter to the address and withdraw funds to themselves.
49
51
@@ -53,13 +55,17 @@ We call this pattern _designed caller_ which enables a new paradigm **where we c
53
55
54
56
Before we can compile and use the contract, we need to add two additional functions.
55
57
56
-
We need a function that let's us read the token value.
58
+
We need a function that lets us read the token value. Paste this into `main.nr`:
0 commit comments