|
| 1 | +// SPDX-License-Identifier: MIT |
| 2 | +pragma solidity 0.8.26; |
| 3 | + |
| 4 | +import {Script, console} from "forge-std/Script.sol"; |
| 5 | +import {DevOpsTools} from "lib/foundry-devops/src/DevOpsTools.sol"; |
| 6 | +import {AmoyTokenTransfer} from "src/AmoyTokenTransfer.sol"; |
| 7 | +import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol"; |
| 8 | +import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol"; |
| 9 | + |
| 10 | +contract TransferTokenFromAmoyToSepolia is Script { |
| 11 | + using SafeERC20 for IERC20; |
| 12 | + |
| 13 | + uint64 constant SEPOLIA_CHAIN_SELECTOR = 16015286601757825753; |
| 14 | + address constant RECEIVER = 0xFB6a372F2F51a002b390D18693075157A459641F; |
| 15 | + address constant TOKEN = 0xcab0EF91Bee323d1A617c0a027eE753aFd6997E4; |
| 16 | + uint256 constant AMOUNT = 1e15; // 0.0001 ETH |
| 17 | + |
| 18 | + AmoyTokenTransfer amoyTokenTransfer; |
| 19 | + |
| 20 | + function sendCCIPBnMTokenToThisContract() public { |
| 21 | + vm.startBroadcast(); |
| 22 | + IERC20(TOKEN).approve(address(amoyTokenTransfer), AMOUNT); |
| 23 | + IERC20(TOKEN).safeTransfer(address(amoyTokenTransfer), AMOUNT); |
| 24 | + vm.stopBroadcast(); |
| 25 | + |
| 26 | + console.log( |
| 27 | + "CCIP BnM token sent to contract address.", |
| 28 | + address(amoyTokenTransfer) |
| 29 | + ); |
| 30 | + } |
| 31 | + |
| 32 | + function run() public { |
| 33 | + address mostRecentlyDeployed = DevOpsTools.get_most_recent_deployment( |
| 34 | + "AmoyTokenTransfer", |
| 35 | + block.chainid |
| 36 | + ); |
| 37 | + console.log("Most recently deployed address: ", mostRecentlyDeployed); |
| 38 | + |
| 39 | + amoyTokenTransfer = AmoyTokenTransfer(payable(mostRecentlyDeployed)); |
| 40 | + |
| 41 | + // send CCIP BnM token to this contract first |
| 42 | + sendCCIPBnMTokenToThisContract(); |
| 43 | + |
| 44 | + // then transfer from Amoy to Sepolia |
| 45 | + vm.startBroadcast(); |
| 46 | + amoyTokenTransfer.transferTokensPayLINK( |
| 47 | + SEPOLIA_CHAIN_SELECTOR, |
| 48 | + RECEIVER, |
| 49 | + TOKEN, |
| 50 | + AMOUNT |
| 51 | + ); |
| 52 | + vm.stopBroadcast(); |
| 53 | + |
| 54 | + console.log("Transfer from Amoy to Sepolia!"); |
| 55 | + } |
| 56 | +} |
0 commit comments