Solidity.

Post

Share your knowledge.

foufrix.
Jul 31, 2023
Expert Q&A

Foundry cannot estimate gas price on Arbitrum

Hi,

I'm trying to solve this CTF on Arbitrum: https://arbiscan.io/address/0xdF7cdFF0c5e85c974D6377244D9A0CEffA2b7A86#code

The problem is okay to solve, but I'm having trouble sending the TX from Foundry to Arbitrum.

Here is the code:

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

import {Script, console} from "forge-std/Script.sol";

interface Challenge {
    function solveChallenge(uint256 randomGuess, string memory yourTwitterHandle) external;
}

contract SolveChallenge is Script {
    Challenge challenge = Challenge(0xdF7cdFF0c5e85c974D6377244D9A0CEffA2b7A86);

    function run() external {
        vm.startBroadcast(vm.envUint("PRIVATE_KEY"));
        uint256 correctAnswer =
            uint256(keccak256(abi.encodePacked(msg.sender, block.prevrandao, block.timestamp))) % 100000;
        challenge.solveChallenge(correctAnswer, "foufrix");
        vm.stopBroadcast();
    }
}

I'm launching the script with this command:

forge script script/SolveChallenge.s.sol:SolveChallenge --private-key $PRIVATE_KEY --rpc-url $RPC_URL --broadcast  --skip-simulation -vvvvv

# Also tried with 
--with-gas-price 100000000 --gas-price 100000000 --gas-limit 3000000

The preview runs well, but It failed when trying to send the transaction to Arbitrum:

Any idea on how to solve that? I tried different command from foundry that are suppose to manually set gas price but it does not seems to work.

Note : could be nice to add the foundry tag :) (as well as hardhat & brownie)

  • Smart Contract
  • Solidity
0
1
Share
Comments
.

Answers

1
Daniel.
Aug 8 2023, 16:11

The transaction fails because of the revert. Most probably because the answer is not correct.

Have you checked the value of the msg.sender in the script? Does it match the address of the private key?

Found this possible issue - https://github.com/foundry-rs/foundry/issues/3917

0
Comments
.

Do you know the answer?

Please log in and share it.

We use cookies to ensure you get the best experience on our website.
More info