Found a balance mismatch (between actual & shown) for the caller's address when used as vm.startBroadcast(caller) in foundry script:

You can reproduce the error using this foundry script:

contract CounterScript is Script {
    address private delegate;

    function setUp() public {
        uint256 privateKey = vm.envUint("DEPLOYER_PRIVATE_KEY");
        delegate = vm.addr(privateKey);

    function run() public {

        console2.log("Balance: ", delegate.balance);

        Counter counter = new Counter();


Now, if you run this command:

$ forge script ./script/Counter.s.sol:AutoBridgeScript --private-key $DEPLOYER_PRIVATE_KEY --rpc-url $NOVA_RPC_URL

Balance:  4611686043903352722517363181

But, actually balance is:

$ cast balance 0xB751710Af8Ce68677aB960adB103060f38d09714 --rpc-url $NOVA_RPC_URL

So, where is the problem?

1 Answer 1


Remove --private-key flag to view the original balance.

Balance:  25476025062017363181

Actually, by default when the same caller is used with private key, foundry somehow adds more gas coin to the caller and thus the balance shows as inflated. Although it would fail in real network, if the caller doesn't have enough gas coin for the transaction.

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.