Skip to content

forge create ignores --value argument during gas estimation #7828

@sealer3

Description

@sealer3

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (721eb94 2024-05-01T00:20:21.524571876Z)

What command(s) is the bug in?

forge create

Operating System

Linux

Describe the bug

With this contract and an anvil instance running:

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

contract NeedValue {
    constructor() payable {
        require(msg.value > 0, "Payment required in constructor");
    }
}

I run:

./forge create --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 --value 100 --rpc-url http://localhost:8545 ./contracts/NeedValue.sol:NeedValue

and get the following error:

[⠊] Compiling...
[⠒] Compiling 1 files with 0.8.25
[⠢] Solc 0.8.25 finished in 9.96ms
Compiler run successful!
Error: 
server returned an error response: error code 3: execution reverted: revert: Payment required in constructor

It might be that the gas estimation is ignoring the --value parameter, but I don't know.

Update: Gas estimation ignores the value parameter:

provider.estimate_gas(&deployer.tx, BlockId::latest()).await
}?);
// set tx value if specified
if let Some(value) = self.tx.value {
deployer.tx.set_value(value);
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions