Lokesh Tuli
Lokesh Tuli

Reputation: 1

TypeError: Cannot read properties of undefined (reading 'getBalance') - Getting this error when trying to get a balance for an address

const { expect, assert } = require("chai");

const { ethers, waffle } = require("hardhat");

const { impersonateFundErc20 } = require("../utils/utilities");

const { abi } = require("../artifacts/contracts/interfaces/IERC20.sol/IERC20.json");

const { provider } = waffle.provider;

describe("FlashSwap Contract", ()=>{

    let FLASHSWAP, BORROW_AMOUNT, FUND_AMOUNT, initialFundingHuman, txArbitrage, gasUsedUSD;

    const DECIMALS = 18;

    const BUSD_WHALE = "0x47ac0fb4f2d84898e4d9e7b4dab3c24507a6d503";
    const BUSD = "0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56";
    const CAKE = "0x0E09FaBB73Bd3Ade0a17ECC321fD13a19e81cE82";
    const USDT = "0x55d398326f99059fF775485246999027B3197955";
    const CROX = "0x2c094F5A7D1146BB93850f629501eB749f6Ed491";

    const BASE_TOKEN_ADDRESS = BUSD;

    const tokenBase = new ethers.Contract(BASE_TOKEN_ADDRESS, abi, provider);

    beforeEach(async()=>{

        //Get owner as signer 

        [owner] = await ethers.getSigners();

        const whale_balances = await provider.getBalance(BUSD_WHALE);

        //ensure that whale has balance

        expect(whale_balances).not.equal("0");

    });

    it("test", async () =>{

        console.log(BUSD_WHALES);



    });


});

when doing npz hardhat getting this error

=-----------

0 passing (3s) 1 failing

  1. FlashSwap Contract "before each" hook for "test": TypeError: Cannot read properties of undefined (reading 'getBalance') at Context. (test\tester.js:33:47) at processTicksAndRejections (node:internal/process/task_queues:96:5)

Upvotes: 0

Views: 940

Answers (2)

Jeffery Oke-Samuel
Jeffery Oke-Samuel

Reputation: 1

I fixed it by adding "allowUnlimitedContractSize: true" in my hardhat.config.js under networks

Upvotes: 0

Fatihov Andrey
Fatihov Andrey

Reputation: 1

console.log(BUSD_WHALE-S-);const BUSD_WHALE extra S

Upvotes: -1

Related Questions