-
Notifications
You must be signed in to change notification settings - Fork 292
/
Copy pathChildChainToken.sol
42 lines (36 loc) · 1.31 KB
/
ChildChainToken.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// SPDX-License-Identifier: Apache-2.0
pragma solidity ^0.8.0;
import "./interfaces/IArbToken.sol";
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
/**
* @title Example implementation of a custom ERC20 token to be deployed on L2
*/
contract ChildChainToken is ERC20, IArbToken {
address public l2GatewayAddress;
address public override l1Address;
modifier onlyL2Gateway() {
require(msg.sender == l2GatewayAddress, "NOT_GATEWAY");
_;
}
/**
* @dev See {ERC20-constructor}
* @param l2GatewayAddress_ address of the L2 custom gateway
* @param l1TokenAddress_ address of the custom token deployed on L1
*/
constructor(address l2GatewayAddress_, address l1TokenAddress_) ERC20("L2CustomToken", "LCT") {
l2GatewayAddress = l2GatewayAddress_;
l1Address = l1TokenAddress_;
}
/**
* Should increase token supply by amount, and should only be callable by the L2Gateway.
*/
function bridgeMint(address account, uint256 amount) external override onlyL2Gateway {
_mint(account, amount);
}
/**
* Should decrease token supply by amount, and should only be callable by the L2Gateway.
*/
function bridgeBurn(address account, uint256 amount) external override onlyL2Gateway {
_burn(account, amount);
}
}