-
Notifications
You must be signed in to change notification settings - Fork 70
feat(l2): implement ERC20 bridge #3241
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
b7330b0
9c87eee
25cbdd1
7346be0
09ea674
c402545
895d0fe
a618588
0212475
d902587
06cb2ee
5655820
1bf5eeb
6c0be9b
52cea43
37af32d
4173ddd
c8573f6
acd8840
ef3f7b3
2273223
d57860f
df461d3
9c897dc
9a21ea3
3e35cc7
9618ced
fe650bf
1eca664
6c68d5b
b69f916
b12f7ec
7e8e08d
092dfd3
72b6b8c
18013bc
fe00936
4f2b9f1
057256a
c1e7d3e
b9dee2f
53eaa11
06232b5
20c5759
fd5b1d2
90592a8
542d7f2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity =0.8.29; | ||
|
||
import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; | ||
import "../l2/interfaces/IERC20L2.sol"; | ||
|
||
/// @title Example L2-side bridgeable token | ||
/// @author LambdaClass | ||
contract TestTokenL2 is ERC20, IERC20L2 { | ||
address public L1_TOKEN = address(0); | ||
address public constant BRIDGE = 0x000000000000000000000000000000000000FFff; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should we put the bridge address on the interface so token operators don't mess up? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Eventually this part of the interface will just become a IERC7802 when ERC-7802 becomes a standard. Token operators may want to allow several bridges. |
||
|
||
constructor(address l1Addr) ERC20("TestTokenL2", "TEST") { | ||
L1_TOKEN = l1Addr; | ||
} | ||
|
||
modifier onlyBridge() { | ||
require(msg.sender == BRIDGE, "TestToken: not authorized to mint"); | ||
_; | ||
} | ||
|
||
function l1Address() external view returns (address) { | ||
return L1_TOKEN; | ||
} | ||
|
||
function crosschainMint(address destination, uint256 amount) external onlyBridge { | ||
_mint(destination, amount); | ||
} | ||
|
||
function crosschainBurn(address from, uint256 value) external onlyBridge { | ||
_burn(from, value); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can this contract change in the future? Consider this scenario:
If the contract was already deployed, this would result in a different genesis file from the original one, right?
Of course, feel free to correct me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would result in a different genesis, but that is intended. The purpose of system_contracts_updater is to update the genesis file with the new bytecode for the system contracts.
As for the contract, it could change albeit very rarely. If you wanted, for example, to allow submitting signed messages on behalf of other users.