From dac332c298e06d229052f95d7dd3486ac0ff6e2b Mon Sep 17 00:00:00 2001 From: Jason-Wanxt Date: Wed, 20 Dec 2023 16:35:28 +0800 Subject: [PATCH] fix amount setting --- scripts/chargeEthOrErc20.ts | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/scripts/chargeEthOrErc20.ts b/scripts/chargeEthOrErc20.ts index 2da88da..ae07e31 100644 --- a/scripts/chargeEthOrErc20.ts +++ b/scripts/chargeEthOrErc20.ts @@ -60,19 +60,21 @@ async function main() { ) // deposit 0.4 ETH const tx = await contract.depositEth({ - value: ethers.utils.parseEther('0.4'), + value: ethers.utils.parseEther(amount), }) console.log('Transaction hash on parent chain: ', tx.hash) await tx.wait() console.log('Transaction has been mined') - console.log('0.4 ETHs are deposited to your account') + console.log(amount + ' ETHs are deposited to your account') } else { const nativeTokenContract = ERC20__factory.connect(nativeToken, l2Provider) const decimals = await nativeTokenContract.decimals() - if(decimals !== 18) { - throw new Error("We currently only support 18 decimals token") + if (decimals !== 18) { + throw new Error('We currently only support 18 decimals token') } - tx = await erc20Inbox.depositERC20(ethers.utils.parseUnits(amount, decimals)) + tx = await erc20Inbox.depositERC20( + ethers.utils.parseUnits(amount, decimals) + ) console.log('Transaction hash on parent chain: ', tx.hash) await tx.wait() console.log('Transaction has been mined')