const l1Url = 'http://localhost:9545';
const l2Url = 'http://localhost:8545';
const key = '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80';
const ethers = require('ethers');
const { predeploys, getContractInterface } = require('@eth-optimism/contracts');
const l1StandardBridgeArtifact = require(`../node_modules/@eth-optimism/contracts/artifacts/contracts/L1/messaging/L1StandardBridge.sol/L1StandardBridge.json`);
const factory__L1StandardBridge = new ethers.ContractFactory(
l1StandardBridgeArtifact.abi,
l1StandardBridgeArtifact.bytecode,
);
const l2StandardBridgeArtifact = require(`../node_modules/@eth-optimism/contracts/artifacts/contracts/L2/messaging/L2StandardBridge.sol/L2StandardBridge.json`);
const factory__L2StandardBridge = new ethers.ContractFactory(
l2StandardBridgeArtifact.abi,
l2StandardBridgeArtifact.bytecode,
);
async function main() {
const l1RpcProvider = new ethers.providers.JsonRpcProvider(l1Url);
const l2RpcProvider = new ethers.providers.JsonRpcProvider(l2Url);
const l1Wallet = new ethers.Wallet(key, l1RpcProvider);
const l2Wallet = new ethers.Wallet(key, l2RpcProvider);
const getBalances = async () => {
var l1Eth = ethers.utils.formatEther(await l1RpcProvider.getBalance(l1Wallet.address));
var l2Eth = ethers.utils.formatEther(await l2RpcProvider.getBalance(l2Wallet.address));
return [l1Eth, l2Eth];
};
const L2StandardBridge = factory__L2StandardBridge
.connect(l2Wallet)
.attach(predeploys.L2StandardBridge);
const L1StandardBridgeAddress = await L2StandardBridge.l1TokenBridge();
const L1StandardBridge = factory__L1StandardBridge
.connect(l1Wallet)
.attach(L1StandardBridgeAddress);
const balancesB4 = await getBalances();
tx = await L1StandardBridge.depositETHTo(
'0x70997970c51812dc3a010c7d01b50e0d17dc79c8',
200000,
[],
);
let balancesNow = await getBalances();
console.log(`Balances before the operation\tL1:${balancesB4[0]}\tL2:${balancesB4[1]}`);
console.log(`Balances after the operation\tL1:${balancesNow[0]}\tL2:${balancesNow[1]}`);
}
main()
.then(() => process.exit(0))
.catch((error) => {
console.error(error);
process.exit(1);
});