I'm trying to deploy any contract on EVM but it fails stating "Transaction has been reverted by the EVM."

356 views Asked by At

So, I am trying to deploy a smart contract on Ethereum using Remix IDE, a few days ago, everything worked just fine, compile the code, select injected provider, mainnet, got some ETH in wallet, click deploy, confirm transaction, all good, now, when I try to click deploy, I get this error:

" creation of MyToken pending...

creation of MyToken errored: Error occured: Transaction has been reverted by the EVM.

Transaction has been reverted by the EVM

Debug the transaction to get more information. "

Here is an example of a code I tried, it is literally the standard version from OppenZeppelin(I also tried my custom code, which worked before, still no success):

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

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Permit.sol";

contract MyToken is ERC20, ERC20Permit {
    constructor() ERC20("MyToken", "MTK") ERC20Permit("MyToken") {}
} 

I tried deploying on Goerli Tesnet, all good there, I did not expected this error, as I did not change anything on my remix IDE settings, I also changed my laptop, with one I never used for deploying smart contracts, still get the same error

Also, I'm a beginner and trying to learn, so, I use just Remix IDE, and I can't get a debug as the debugger requires a transaction hash, but I don't have one since the error occurs just as I hit deploy.

Thanks for helping a newbie people!

1

There are 1 answers

0
galiullinis On

Ensure that you have enough gas limit set for the transaction. Sometimes, if the gas limit is too low, the transaction may fail.