Overview
Arbitrum-focused template for L2 development. Includes L1-to-L2 and L2-to-L1 bridge messaging contracts, a bidirectional token gateway, and a gas-efficient ERC-20 token. Pre-configured to fork Arbitrum mainnet with Blockscout explorer.| Difficulty | Intermediate |
| Category | L2 |
| Chains | Arbitrum (fork) |
| Services | Blockscout (port 4000), Prometheus (port 9090) |
| License | Apache-2.0 |
Quick Start
Generated Files
my-arb
dokrypt.yaml
foundry.toml
README.md
contracts
token
ArbitrumToken.sol
bridge
L1ToL2MessageSender.sol
L2ToL1MessageSender.sol
gateway
TokenGateway.sol
test
ArbitrumToken.t.sol
L1ToL2Message.t.sol
TokenGateway.t.sol
scripts
deploy.js
bridge-tokens.js
Contracts
ArbitrumToken.sol
Gas-efficient ERC-20 optimized for Arbitrum. Includes batch transfers and gateway-authorized minting/burning for bridge operations.| Function | Access | Description |
|---|---|---|
| Standard ERC-20 | Public | transfer, approve, transferFrom |
batchTransfer(recipients[], amounts[]) | Public | Send tokens to multiple addresses in one tx |
mint(to, amount) | Gateway | Mint tokens on L2 (called by gateway during bridging) |
burn(from, amount) | Gateway | Burn tokens on L2 (called during withdrawal) |
setGateway(gateway) | Owner | Authorize a gateway contract |
Bridge Module
L1ToL2MessageSender.sol
Sends messages from L1 to L2 via Arbitrum’s Delayed Inbox pattern. Creates retryable tickets with configurable gas parameters.| Function | Access | Description |
|---|---|---|
sendMessage(target, data, maxGas, gasPriceBid) | Public | Create a retryable ticket to L2 |
getTicket(ticketId) | View | Get ticket details |
getTicketCount() | View | Total tickets created |
L2ToL1MessageSender.sol
Sends messages from L2 to L1 via the ArbSys precompile (0x0000000000000000000000000000000000000064). Includes target allowlisting and nonce tracking.| Function | Access | Description |
|---|---|---|
sendMessage(target, data) | Public | Send message to allowed L1 target |
addAllowedTarget(target) | Owner | Add L1 address to allowlist |
removeAllowedTarget(target) | Owner | Remove from allowlist |
confirmMessage(nonce) | Owner | Confirm message delivery |
TokenGateway.sol
Bidirectional token bridging using lock-and-mint (L1 to L2) and burn-and-release (L2 to L1) pattern.| Function | Access | Description |
|---|---|---|
deposit(l1Token, amount) | Public | Lock tokens on L1, mint on L2 |
withdraw(l2Token, amount) | Public | Burn tokens on L2, release on L1 |
finalizeDeposit(l1Token, to, amount, depositId) | Counterpart | Complete deposit on L2 side |
finalizeWithdrawal(l2Token, to, amount, withdrawalId) | Counterpart | Complete withdrawal on L1 side |
mapToken(l1Token, l2Token) | Owner | Register L1/L2 token pair |