-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #11 from bobanetwork/wsdt/local-fixes
fix: local stack
- Loading branch information
Showing
5 changed files
with
155 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,33 @@ | ||
const { ethers } = require('ethers'); | ||
const {ethers} = require('ethers'); | ||
require("dotenv").config(); | ||
|
||
const RPC_URL = 'http://localhost:8545'; | ||
const RPC_URL_L1 = 'http://localhost:8545'; | ||
const RPC_URL_L2 = 'http://localhost:9545'; | ||
const PRIVATE_KEY = process.env.PRIVATE_KEY; | ||
const L1StandardBridge = '0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9'; | ||
const provider = new ethers.JsonRpcProvider(RPC_URL); | ||
const wallet = new ethers.Wallet(PRIVATE_KEY, provider); | ||
|
||
const l1provider = new ethers.JsonRpcProvider(RPC_URL_L1); | ||
const l2provider = new ethers.JsonRpcProvider(RPC_URL_L2); | ||
|
||
const walletL2 = new ethers.Wallet(PRIVATE_KEY, l2provider); | ||
const walletL1 = new ethers.Wallet(PRIVATE_KEY, l1provider); | ||
|
||
async function main() { | ||
const tx = { | ||
to: L1StandardBridge, | ||
value: ethers.parseEther('100.0') | ||
}; | ||
const response = await wallet.sendTransaction(tx); | ||
await response.wait(); | ||
if ((await l2provider.getBalance(walletL2)) > 1) { | ||
console.log("Deployer already has funds on L2, continue"); | ||
} else { | ||
console.log('Funding L2...') | ||
try { | ||
const tx = { | ||
to: L1StandardBridge, | ||
value: ethers.parseEther('100') | ||
}; | ||
const response = await walletL1.sendTransaction(tx); | ||
await response.wait(); | ||
} catch (e) { | ||
console.error("Error: ", e); | ||
} | ||
} | ||
} | ||
|
||
main().catch(console.error); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters