Skip to content

Mint-Burn gas token privileged contract #334

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

Open
wants to merge 6 commits into
base: mb-arbowner-dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 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
27 changes: 27 additions & 0 deletions src/bridge/IMinterBurnerForwarder.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;

interface IMinterBurnerForwarder {
/**
* @notice Mints some amount of the native gas token for this chain to the calling address.
* @dev This function calls mintNativeToken in the ArbOwner precompile, so this contract must also be a chain owner.
* No events are emitted in this function, since the ArbOwner precompile already emits OwnerActs()
* @param amount The amount of native gas token to mint
*/
function mintNativeToken(
uint256 amount
) external;

/**
* @notice Burns some amount of the native gas token for this chain from the given address.
* @dev This function calls burnNativeToken in the ArbOwner precompile, so this contract must also be a chain owner.
* No events are emitted in this function, since the ArbOwner precompile already emits OwnerActs()
* @param amount The amount of native gas token to burn
*/
function burnNativeToken(
uint256 amount
) external;
}
55 changes: 55 additions & 0 deletions src/bridge/MinterBurnerForwarder.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
// Copyright 2021-2022, Offchain Labs, Inc.
// For license information, see https://github.com/OffchainLabs/nitro-contracts/blob/main/LICENSE
// SPDX-License-Identifier: BUSL-1.1

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/AccessControlEnumerable.sol";
import "./IMinterBurnerForwarder.sol";
import "../precompiles/ArbOwner.sol";

/**
* @title MinterBurnerForwarder
* @notice This contract allows the chain owner of a chain to give rights for minting and burning native gas tokens to third parties.
* Minting and burning will be done by using the ArbOwner functions mintNativeToken and burnNativeToken.
* This contract must be set as a chain owner of the chain to be able to call ArbOwner functions
*/
contract MinterBurnerForwarder is IMinterBurnerForwarder, AccessControlEnumerable {
// Roles
bytes32 public constant MINTER_ROLE = keccak256("MINTER");
bytes32 public constant BURNER_ROLE = keccak256("BURNER");

// ArbOwner precompile
ArbOwner constant ARB_OWNER = ArbOwner(address(112));

constructor(address[] memory admins, address[] memory minters, address[] memory burners) {
// Grant ADMIN role to admins
for (uint256 i = 0; i < admins.length; i++) {
_grantRole(DEFAULT_ADMIN_ROLE, admins[i]);
}

// Grant MINTER role to minters
for (uint256 i = 0; i < minters.length; i++) {
_grantRole(MINTER_ROLE, minters[i]);
}

// Grant BURNER role to burners
for (uint256 i = 0; i < burners.length; i++) {
_grantRole(BURNER_ROLE, burners[i]);
}
}

/// @inheritdoc IMinterBurnerForwarder
function mintNativeToken(
uint256 amount
) external onlyRole(MINTER_ROLE) {
ARB_OWNER.mintNativeToken(msg.sender, amount);
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should do this to burn too

Suggested change
function mintNativeToken(
uint256 amount
) external onlyRole(MINTER_ROLE) {
ARB_OWNER.mintNativeToken(msg.sender, amount);
}
function mintNativeToken(
address to,
uint256 amount
) external onlyRole(MINTER_ROLE) {
ARB_OWNER.mintNativeToken(to, amount);
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


/// @inheritdoc IMinterBurnerForwarder
function burnNativeToken(
uint256 amount
) external onlyRole(BURNER_ROLE) {
ARB_OWNER.burnNativeToken(msg.sender, amount);
}
}