Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Getting invalid opcode error when the simulation should work properly #5548

Closed
sanjukammath opened this issue Jul 25, 2024 · 1 comment
Closed
Assignees

Comments

@sanjukammath
Copy link

Version of Hardhat

2.22.6

What happened?

I have created a hardhat forked avalanche network and am trying to send a simple approval transaction to the blob token. It is failing with the error:

{"jsonrpc":"2.0","id":44,"error":{"code":-32603,"message":"Error: VM Exception while processing transaction: invalid opcode","data":{"message":"Error: VM Exception while processing transaction: invalid opcode","txHash":"0xa2f2c330ec0d3cba23d6daaed95135f2d4c5f02e26aba0dbb6bab9fdec396ffc","data":"0x"}}}

Minimal reproduction steps

Create a hardhat fork using the following config:

import "tsconfig-paths/register";

const config = {
  solidity: "0.8.17",
  networks: {
    hardhat: {
      chainId: 31337,
      gasMultiplier: 1,
      hardfork: "istanbul",
      accounts: [],
    },
  },
};

export default config;
npx hardhat --config <your file path> node --fork <your avalanche url>

In your code try to send this transaction using impersonated signer:

                        await provider.send("hardhat_impersonateAccount", [
                          fromAccount,
                        ]);
                        const impersonatedSigner = provider.getSigner(
                         from
                        );
                        await impersonatedSigner.sendTransaction(
                          impersonatingTransaction
                        );

Actual values used

impersonatingTransaction: {
    to: '0x334efd1aa0caf4b9b206dd8b9002b7172fc805e6',
    data: '0x095ea7b3000000000000000000000000111111125421ca6dc452d289314280a0f8842a65ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff',
    value: '0x0',
    gasLimit: 800000,
    gasPrice: 0,
    chainId: 31337
  },
  from: '0xEE37005b86410cA49991d8bbC78Ad94316aF2A6e'

Search terms

avalanche

@schaable
Copy link
Member

schaable commented Aug 8, 2024

I just tested this locally and it works as expected. I noticed a couple of minor issues in your sample code. You’re missing the await keyword on the second statement, and you’re using both fromAccount and from, which should hold the same value. Here’s the code I used for testing:

async function main() {
  const fromAccount = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266";
  const toAccount = "0x70997970C51812dc3A010C7d01b50e0d17dc79C8";

  const impersonatedSigner = await hre.ethers.getImpersonatedSigner(fromAccount);
  await impersonatedSigner.sendTransaction({
    to: toAccount,
    value: hre.ethers.parseEther("1.0"),
    gasLimit: 21000,
  });
}

I hope this helps! Let me know if you have any other questions.

@schaable schaable closed this as not planned Won't fix, can't repro, duplicate, stale Aug 8, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in Hardhat Aug 8, 2024
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
Archived in project
Development

No branches or pull requests

2 participants