hardhat icon indicating copy to clipboard operation
hardhat copied to clipboard

ArbSys does not work on Arbitrum Fork

Open Archethect opened this issue 2 years ago • 2 comments

Version of Hardhat

2.18.1

What happened?

It seems it is not possible to use ArbSys(100) contract methods on Arbitrum forks. While testing ArbSys(address(100)).arbBlockNumber() it reverts without a reason. It would be cool to make forks work with all Arbitrum Precompiles: https://docs.arbitrum.io/for-devs/dev-tools-and-resources/precompiles

Minimal reproduction steps

  • Fork Arbitrum on an existing block
  • Test some solidity code containing ArbSys(address(100)).arbBlockNumber() (or any other method in that contract)

Search terms

Arbitrum, Fork, ArbSys

Archethect avatar Oct 12 '23 08:10 Archethect

Hey @Archethect, thanks for opening this. We are in the middle of a big refactor of the Hardhat network, but after that we want (at some point) to have some mechanism for adding custom precompiles, which should help with this.

fvictorio avatar Oct 20 '23 13:10 fvictorio

I'd like to have following api to support the precompile contracts

const precompiles = [
  {
    address: "0x...",
    gas(input) {
      return 100; // gas required for the call
    },
    run(input) {
      return [0x1, 0x2]; // return bytes or throw an error
    },
  },
];

await hardhat.addPrecompiles(...precompiles);

islishude avatar Jul 22 '24 08:07 islishude

Any progress on this?

escottalexander avatar Mar 05 '25 17:03 escottalexander

For Hardhat 3 we are building out better support for layer 2s, including precompiles and predeploys.

We are still in early Alpha - Optimism is currently the only supported L2 chain type, but hopefully that will give some insight into the general approach:

https://hardhat.org/hardhat3-alpha

kanej avatar Mar 07 '25 12:03 kanej