Bài viết
Chia sẻ kiến thức của bạn.
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
Câu trả lời
1The 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
Bạn có biết câu trả lời không?
Hãy đăng nhập và chia sẻ nó.
Solidity is an object-oriented, high-level language for implementing smart contracts. It is a curly-bracket language designed to target the Ethereum Virtual Machine (EVM).
- My ERC721 contract successfully deploys, but I can't verify the contract's source code with hardhat21
- Solidity và ethers.js Tính toán các địa chỉ khác nhau từ cùng một chữ ký21
- không thể hiểu các vị trí là gì (uint256)22
- Làm thế nào để đảo ngược keccak256 trong độ rắn22
- Làm rõ về hoàn tiền gas và so sánh giữa “yêu cầu” và “hoàn lại” trong hợp đồng thông minh21