-
Notifications
You must be signed in to change notification settings - Fork 6
/
transfer_erc20.s.sol
34 lines (25 loc) · 1.22 KB
/
transfer_erc20.s.sol
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;
import "forge-std/console.sol";
import "forge-std/Script.sol";
import "script/include.s.sol";
contract TransferErc20 is Script {
function run() external {
string memory mnemonic = vm.envString("MNEMONIC");
uint256 deployerPrivateKey = vm.deriveKey(mnemonic, 0);
vm.rememberKey(deployerPrivateKey);
uint256 amount = vm.envUint("TRANSFER_AMOUNT");
string memory target = vm.envString("TRANSFER_TARGET");
console.log("Transfering %s from %s to %s", amount, msg.sender, target);
TestERC20 testerc20 = TestERC20(address(contractTestERC20()));
Bridge bridge = Bridge(address(contractBridge()));
ICommon.ChainTransfer[] memory transfers = new ICommon.ChainTransfer[](1);
transfers[0] = ICommon.ChainTransfer(amount, address(testerc20), target);
console.log("Bridge allowance: %s", testerc20.allowance(msg.sender, address(bridge)));
console.log("Balance before: %s", testerc20.balanceOf(msg.sender));
vm.startBroadcast();
bridge.transferToChain(transfers, 1);
vm.stopBroadcast();
console.log("Balance after: %s", testerc20.balanceOf(msg.sender));
}
}