Skip to content

Commit

Permalink
Standard Bridger
Browse files Browse the repository at this point in the history
This patch adds a simple Legend Script for pushing ERC20 assets over the standard Optimism/Base bridge. The real bridge seems to use a mix of CCIP and CCTP bridges, as well, but this is a good starting point for understanding cross-chain actions.
  • Loading branch information
hayesgm committed Mar 11, 2024
1 parent 89d57b6 commit 87622d9
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/legend-scripts/src/StandardBridger.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
pragma solidity 0.8.23;

import {IERC20} from "openzeppelin/token/ERC20/IERC20.sol";

interface StandardBridge {
function bridgeERC20To(
address _localToken,
address _remoteToken,
address _to,
uint256 _amount,
uint32 _minGasLimit,
bytes calldata _extraData
) external;
}

contract StandardBridger {
StandardBridge immutable bridge;

constructor(StandardBridge bridge_) {
bridge = bridge_;
}

/**
* @notice Bridge token over standard bridge.
*/
function bridgeToken(address localToken,
address remoteToken,
address to,
uint256 amount,
uint32 minGasLimit,
bytes calldata extraData) external {
IERC20(localToken).approve(address(bridge), amount);
bridge.bridgeERC20To(localToken, remoteToken, to, amount, minGasLimit, extraData);
}
}

0 comments on commit 87622d9

Please sign in to comment.