- 05/02/2025
- Autor: admin
- in: CRYPTOCURRENCY
Metamask Execution Rerailed: transaction mined but execution failed
As a MetaMask user with an active wallet, you’re probably no stranger to the frustrations of interacting with decentralized applications (dApps). I recently ran into a similar problem on the Sepolia testnet, where my deployed contract execution was canceled due to a misconfigured metamask transaction. In this article, I will tell you what happened and suggest a possible solution.
Transaction Failed
Let’s assume that the deployment and verification of your Sepolia contract was successful with Remix. You also checked the contract on the second test network or the main network, but unfortunately the execution of the contract was canceled due to an error in the metamask transaction.
Here are the necessary steps:
- Deployed a new contract in Sepolia:
pragma Solidity version 0.8.10; import " contract MyContract is ERC20 { mapping (address => uint256) public balances; }
- Checked the contract on Sepolia:
pragma solidity ^0.6.0 < 0.8.10; import " import " contract MyContractWrapper is SafeERC20 { constructor() public { address _owner = msg.sender; } function transfer(address received, uint256 amount) public { require(msg.value >= amount, "The transfer amount must be non-zero"); super.transfer(recipient, amount); } }
- Used MetaMask on Sepolia:pragma solidity ^0.6.0 < 0.8.10; import " contract MyContractWrapper is SafeERC20 { event Transfer(address indexed received, uint256 indexed amount); }
- Executed the contract using MetaMask:pragma solidity ^0.6.0 < 0.8.10; import " import " contract MyContractWrapper is SafeERC20 { function () public payable { balances[msg.sender] += 10; } }
Redirected Transaction
After the execution of the contract, a new transaction was obtained to cancel the execution of thetransferfunction. However, the execution of the metamask failed due to an error in the
MyContractWrappercontract.
Here's what happened:
- The contract performed the
transfer'' function without any problems.
- The new transaction was mined using MetaMask, which asked to transfer 10 units from the wallet address that owns the contract.
- However, the execution of the metamask failed due to an error in theMyContractWrapper
contract, in particular, because it asked to send a transaction with a different gas limit than the one set in the contract.
Possible Solution
To prevent similar problems in the future, you can try the following:
- Check your metamask settings: make sure MetaMask is set to use the correct gas limit for transactions.
- Double-check the deployment and verification of the contract: double-check that the contract has been deployed and properly verified on Sepolia using Remix.
- Use a second testnet or mainnet: Try executing the contract on a second testnet or mainnet to see if the problem is related to one of them.
By following these steps, you will be able to resolve the issue of metamask execution being canceled due to an error in theMyContractWrapper` contract. If you’re still having trouble, feel free to provide more details and I’ll do my best to help!