Skip to content

Commit

Permalink
refactor: Improve gas limit in transfer method of BlockchainService
Browse files Browse the repository at this point in the history
  • Loading branch information
PleBea committed Sep 25, 2024
1 parent 5d4486b commit 7e94120
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/modules/blockchain/blockchain.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,11 +73,15 @@ export class BlockchainService {
async transfer(to: string, amount: number, address: string): Promise<void> {
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(),
Expand Down

0 comments on commit 7e94120

Please sign in to comment.