BridgeCreator
0x24c4a1754484c1e8c500b264d9c1284f8a09b3b0
Verification
Verified
v0.8.17+commit.8df45f5f
Type
Contract
6,306 bytes
ABI entries
6
2 read · 1 write
License
none
Contract information
- Address
- 0x24c4a1754484c1e8c500b264d9c1284f8a09b3b0
- Chain
- Robinhood Chain (4663)
- Compiler
- v0.8.17+commit.8df45f5f
- Optimization
- Enabled
- Creator
- 0x26E8134eCC…f318B25158
- Creation tx
- 0x59243e32c6…4f1b428dae
Token
Not a token
This contract does not expose ERC-20 metadata.
Read contract (2)
erc20BasedTemplates() → address, address, address, address, address, address
ethBasedTemplates() → address, address, address, address, address, address
Events (2)
ERC20TemplatesUpdatedTemplatesUpdated
ABI
[
{
"inputs": [
{
"components": [
{
"internalType": "contract IBridge",
"name": "bridge",
"type": "address"
},
{
"internalType": "contract ISequencerInbox",
"name": "sequencerInbox",
"type": "address"
},
{
"internalType": "contract ISequencerInbox",
"name": "delayBufferableSequencerInbox",
"type": "address"
},
{
"internalType": "contract IInboxBase",
"name": "inbox",
"type": "address"
},
{
"internalType": "contract IRollupEventInbox",
"name": "rollupEventInbox",
"type": "address"
},
{
"internalType": "contract IOutbox",
"name": "outbox",
"type": "address"
}
],
"internalType": "struct BridgeCreator.BridgeTemplates",
"name": "_ethBasedTemplates",
"type": "tuple"
},
{
"components": [
{
"internalType": "contract IBridge",
"name": "bridge",
"type": "address"
},
{
"internalType": "contract ISequencerInbox",
"name": "sequencerInbox",
"type": "address"
},
{
"internalType": "contract ISequencerInbox",
"name": "delayBufferableSequencerInbox",
"type": "address"
},
{
"internalType": "contract IInboxBase",
"name": "inbox",
"type": "address"
},
{
"internalType": "contract IRollupEventInbox",
"name": "rollupEventInbox",
"type": "address"
},
{
"internalType": "contract IOutbox",
"name": "outbox",
"type": "address"
}
],
"internalType": "struct BridgeCreator.BridgeTemplates",
"name": "_erc20BasedTemplates",
"type": "tuple"
}
],
"stateMutability": "nonpayable",
"type": "constructor"
},
{
"anonymous": false,
"inputs": [],
"name": "ERC20TemplatesUpdated",
"type": "event"
},
{
"anonymous": false,
"inputs": [],
"name": "TemplatesUpdated",
"type": "event"
},
{
"inputs": [
{
"internalType": "address",
"name": "adminProxy",
"type": "address"
},
{
"internalType": "address",
"name": "rollup",
"type": "address"
},
{
"internalType": "address",
"name": "nativeToken",
"type": "address"
},
{
"components": [
{
"internalType": "uint256",
"name": "delayBlocks",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "futureBlocks",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "delaySeconds",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "futureSeconds",
"type": "uint256"
}
],
"internalType": "struct ISequencerInbox.MaxTimeVariation",
"name": "maxTimeVariation",
"type": "tuple"
},
{
"components": [
{
"internalType": "uint64",
"name": "threshold",
"type": "uint64"
},
{
"internalType": "uint64",
"name": "max",
"type": "uint64"
},
{
"internalType": "uint64",
"name": "replenishRateInBasis",
"type": "uint64"
}
],
"internalType": "struct BufferConfig",
"name": "bufferConfig",
"type": "tuple"
},
{
"internalType": "contract IFeeTokenPricer",
"name": "feeTokenPricer",
"type": "address"
}
],
"name": "createBridge",
"outputs": [
{
"components": [
{
"internalType": "contract IBridge",
"name": "bridge",
"type": "address"
},
{
"internalType": "contract IInboxBase",
"name": "inbox",
"type": "address"
},
{
"internalType": "contract ISequencerInbox",
"name": "sequencerInbox",
"type": "address"
},
{
"internalType": "contract IRollupEventInbox",
"name": "rollupEventInbox",
"type": "address"
},
{
"internalType": "contract IOutbox",
"name": "outbox",
"type": "address"
}
],
"internalType": "struct BridgeCreator.BridgeContracts",
"name": "",
"type": "tuple"
}
],
"stateMutability": "nonpayable",
"type": "function"
},
{
"inputs": [],
"name": "erc20BasedTemplates",
"outputs": [
{
"internalType": "contract IBridge",
"name": "bridge",
"type": "address"
},
{
"internalType": "contract ISequencerInbox",
"name": "sequencerInbox",
"type": "address"
},
{
"internalType": "contract ISequencerInbox",
"name": "delayBufferableSequencerInbox",
"type": "address"
},
{
"internalType": "contract IInboxBase",
"name": "inbox",
"type": "address"
},
{
"internalType": "contract IRollupEventInbox",
"name": "rollupEventInbox",
"type": "address"
},
{
"internalType": "contract IOutbox",
"name": "outbox",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
},
{
"inputs": [],
"name": "ethBasedTemplates",
"outputs": [
{
"internalType": "contract IBridge",
"name": "bridge",
"type": "address"
},
{
"internalType": "contract ISequencerInbox",
"name": "sequencerInbox",
"type": "address"
},
{
"internalType": "contract ISequencerInbox",
"name": "delayBufferableSequencerInbox",
"type": "address"
},
{
"internalType": "contract IInboxBase",
"name": "inbox",
"type": "address"
},
{
"internalType": "contract IRollupEventInbox",
"name": "rollupEventInbox",
"type": "address"
},
{
"internalType": "contract IOutbox",
"name": "outbox",
"type": "address"
}
],
"stateMutability": "view",
"type": "function"
}
]Source code
// 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 "../bridge/Bridge.sol";
import "../bridge/SequencerInbox.sol";
import "../bridge/Inbox.sol";
import "../bridge/Outbox.sol";
import "./RollupEventInbox.sol";
import "../bridge/ERC20Bridge.sol";
import "../bridge/ERC20Inbox.sol";
import "../rollup/ERC20RollupEventInbox.sol";
import "../bridge/ERC20Outbox.sol";
import "../bridge/IBridge.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
import "@openzeppelin/contracts/proxy/transparent/ProxyAdmin.sol";
contract BridgeCreator {
BridgeTemplates public ethBasedTemplates;
BridgeTemplates public erc20BasedTemplates;
event TemplatesUpdated();
event ERC20TemplatesUpdated();
struct BridgeTemplates {
IBridge bridge;
ISequencerInbox sequencerInbox;
ISequencerInbox delayBufferableSequencerInbox;
IInboxBase inbox;
IRollupEventInbox rollupEventInbox;
IOutbox outbox;
}
struct BridgeContracts {
IBridge bridge;
IInboxBase inbox;
ISequencerInbox sequencerInbox;
IRollupEventInbox rollupEventInbox;
IOutbox outbox;
}
constructor(
BridgeTemplates memory _ethBasedTemplates,
BridgeTemplates memory _erc20BasedTemplates
) {
ethBasedTemplates = _ethBasedTemplates;
erc20BasedTemplates = _erc20BasedTemplates;
}
function _createBridge(
bytes32 create2Salt,
address adminProxy,
BridgeTemplates memory templates,
bool isDelayBufferable
) internal returns (BridgeContracts memory) {
BridgeContracts memory frame;
frame.bridge = IBridge(
address(
new TransparentUpgradeableProxy{salt: create2Salt}(
address(templates.bridge), adminProxy, ""
)
)
);
frame.sequencerInbox = ISequencerInbox(
address(
new TransparentUpgradeableProxy{salt: create2Salt}(
address(
isDelayBufferable
? templates.delayBufferableSequencerInbox
: templates.sequencerInbox
),
adminProxy,
""
)
)
);
frame.inbox = IInboxBase(
address(
new TransparentUpgradeableProxy{salt: create2Salt}(
address(templates.inbox), adminProxy, ""
)
)
);
frame.rollupEventInbox = IRollupEventInbox(
address(
new TransparentUpgradeableProxy{salt: create2Salt}(
address(templates.rollupEventInbox), adminProxy, ""
)
)
);
frame.outbox = IOutbox(
address(
new TransparentUpgradeableProxy{salt: create2Salt}(
address(templates.outbox), adminProxy, ""
)
)
);
return frame;
}
function createBridge(
address adminProxy,
address rollup,
address nativeToken,
ISequencerInbox.MaxTimeVariation calldata maxTimeVariation,
BufferConfig calldata bufferConfig,
IFeeTokenPricer feeTokenPricer
) external returns (BridgeContracts memory) {
// use create2 salt to ensure deterministic addresses
bytes32 create2Salt = keccak256(abi.encode(msg.data, msg.sender));
// create delay bufferable sequencer inbox if threshold is non-zero
bool isDelayBufferable = bufferConfig.threshold != 0;
// create ETH-based bridge if address zero is provided for native token, otherwise create ERC20-based bridge
BridgeContracts memory frame = _createBridge(
create2Salt,
adminProxy,
nativeToken == address(0) ? ethBasedTemplates : erc20BasedTemplates,
isDelayBufferable
);
// init contracts
if (nativeToken == address(0)) {
IEthBridge(address(frame.bridge)).initialize(IOwnable(rollup));
} else {
IERC20Bridge(address(frame.bridge)).initialize(IOwnable(rollup), nativeToken);
}
frame.sequencerInbox.initialize(
IBridge(frame.bridge), maxTimeVariation, bufferConfig, feeTokenPricer
);
frame.inbox.initialize(frame.bridge, frame.sequencerInbox);
frame.rollupEventInbox.initialize(frame.bridge);
frame.outbox.initialize(frame.bridge);
return frame;
}
}
Chain explorer6306msChain node82ms