From 7e941207a76c975d3653efb0969b1226ed0e2894 Mon Sep 17 00:00:00 2001 From: PleBea Date: Thu, 26 Sep 2024 01:47:10 +0900 Subject: [PATCH] refactor: Improve gas limit in transfer method of BlockchainService --- src/modules/blockchain/blockchain.service.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/modules/blockchain/blockchain.service.ts b/src/modules/blockchain/blockchain.service.ts index 36e0f9c..c60184e 100644 --- a/src/modules/blockchain/blockchain.service.ts +++ b/src/modules/blockchain/blockchain.service.ts @@ -73,11 +73,15 @@ export class BlockchainService { async transfer(to: string, amount: number, address: string): Promise { const erc20 = await ethers.getContractAt('ShockiToken', address, this.deployer); - await erc20.approve(this.deployer.address, ethers.parseUnits(amount.toString(), 18), { - nonce: await this.getTransactionCount(), - }); - - await erc20.waitForDeployment(); + const tx = await erc20.approve( + this.deployer.address, + ethers.parseUnits(amount.toString(), 18), + { + nonce: await this.getTransactionCount(), + }, + ); + + await tx.wait(); await erc20.transfer(to, ethers.parseUnits(amount.toString(), 18), { nonce: await this.getTransactionCount(),