0

Unknown Selector Error (0x98296c54) in BIGTTokenTest.t.sol Description:

I'm encountering an "unknown selector 0x98296c54 for VmCalls" error in my testbobBalance function within the BIGTTokenTest.t.sol file. Here's the relevant code from my ERC-20 implementation and test suite:

BIGTToken.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {ERC20} from "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract BIGTToken is ERC20 {
    constructor(uint256 initialSupply) ERC20("BigTToken", "BIGT") {
        _mint(msg.sender, initialSupply);
    }
}

DeployBIGToken.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {DeployBIGToken} from "../src/BIGTToken.sol";

contract DeployBIGToken is Script {
    uint256 public constant INITIAL_SUPPLY = 10000 ether;

    function run() external returns (BIGTToken) {
        vm.startBroadcast();
        BIGTToken bigt = new BIGTToken(INITIAL_SUPPLY);
        vm.stopBroadcast();
        return bigt;
    }
}

BIGTTokenTest.t.sol

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;

import {Test} from "forge-std/Test.sol";
import {DeployBIGToken} from "../script/DeployBIGToken.s.sol";
import {BIGTToken} from "../src/BIGTToken.sol";

contract BIGTTokenTest is Test {
    BIGTToken public bigtToken;
    DeployBIGToken public deployer;

    uint256 public constant STARTING_BALANCE = 10 ether;

    address bob = makeAddr("bob");
    address alice = makeAddr("alice");

    function setUp() public {
        deployer = new DeployBIGToken();
        bigtToken = deployer.run();

        vm.prank(msg.sender);
        bigtToken.transfer(bob, STARTING_BALANCE);
    }

    function testbobBalance() public view {
        assertEq(STARTING_BALANCE, bigtToken.balanceOf(bob));
    }
}

Error Message:

Encountered 1 failing test in test/BIGTTokenTest.t.sol:BIGTTokenTest
[FAIL. Reason: unknown selector `0x98296c54` for VmCalls] testbobBalance() (gas: 12744)

I am not sure that BIGTToken inherits from the standard OpenZeppelin ERC20 contract and implements the balanceOf function correctly!!. I've checked for any typos or inconsistencies in function names or arguments. I'm at a loss regarding the cause of this error. Any insights or suggestions on how to resolve this issue and successfully test the balanceOf function in my ERC-20 implementation would be greatly appreciated.

1 Answer 1

1

seems like I needed to update my foundry. after foundryup finished working, the issue was resolved and I did run my test again and there were no futher error.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.