Questions tagged [revert-opcode]

Questions about Solidity's `revert()` or the REVERT opcode.

Filter by
Sorted by
Tagged with
1 vote
0 answers
15 views

Will block.coinbase.call{value: _ethAmountToCoinbase}(new bytes(0)) revert if transaction fails?

A similar looking statement address.call(abi.encodeWithSignature()) will not revert if transaction fails because it is an external call. So, will block.coinbase.call{value: _ethAmountToCoinbase}(new ...
aste123's user avatar
  • 233
0 votes
0 answers
208 views

How to call the exchange method on a Curve Pool?

I can't for the life of me figure out where I'm going wrong. I'm trying to write a simple swap inside my contract for the curve pool at this mainnet address: https://etherscan.io/address/...
Anony's user avatar
  • 1
1 vote
1 answer
190 views

Warning! Error encountered during contract execution [invalid opcode: opcode 0x29 not defined]

hello every one hope you are doing fine. i was trying to communicate with my smart contract which is deployed on the goeril test network but i m facing this error Warning! Error encountered during ...
Aditya Sharma's user avatar
0 votes
1 answer
328 views

OPCODES How is work "CODECOPY"?

Somebody could explain how CODECOPY works in practice ? There is only one sample in evm.playground but I dont understand above-mentioned sample. Could you give me another concrete sample (with ...
Engin YILMAZ's user avatar
0 votes
1 answer
201 views

My call to contract method not throw error but stuck, why?

when I call a contract method, which should revert and throw error: Contract souce code: pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@...
Siwei's user avatar
  • 312
0 votes
2 answers
162 views

How to use truffle-assertions to check if a constructor will revert?

Say I have a contract: contract Reverts{ constructor(param1){ require(param1); } } If param1 is false, the constructor should fail and revert state. truffle-assertions allows me to ...
Expectator's user avatar
0 votes
1 answer
171 views

Reentrancy Ethernaut Challenge

I have been trying to pass the Reentrancy attack challenge of Ethernaut. Hence, I am creating this issue to ask help from anybody who knows where is the problem coming from. First of all, here is the ...
Sina Rahimi's user avatar
1 vote
2 answers
168 views

Smart contract is not available on the blockchain during the constructor call

I have the following sample code: // SPDX-License-Identifier: MIT pragma solidity ^0.8.7; import '@openzeppelin/contracts/token/ERC20/IERC20.sol'; import '@openzeppelin/contracts/token/ERC20/ERC20....
toongeorges's user avatar
1 vote
1 answer
68 views

VM Exception while processing transaction: revert — Transferring ether from EOA to contract account

Problem summary I get the following error whenever I try transferring ether from an EOA(externally owned account) to a contract account in one of my functions as seen below. I am currently using the ...
mbappai's user avatar
  • 115
1 vote
1 answer
1k views

Is there a way to add all revert error strings to an ethers js interface?

According to this tool if a contract call has a revert message that starts with the signature 0x08c379a0 then the error message is in the format Error(string) i.e. a standard revert error string(e.g. ...
MShakeG's user avatar
  • 1,593
4 votes
3 answers
3k views

When should I use `require` vs custom `revert` errors?

This applies only to solidity ^0.8 and onward. Let's say I have a function like this: function withdraw() external { (bool success, ) = payable(msg.sender).call{value: address(this).balance}("&...
Patrick Collins's user avatar
0 votes
1 answer
255 views

Understanding revert with array of contracts

I have the following solidity file: // SPDX-License-Identifier: GPL-3.0 pragma solidity >=0.7.0 <0.9.0; error MustBeOwner(); error BookDoesNotExist(); // book contract contract Book { ...
user8555937's user avatar
1 vote
1 answer
362 views

Brownie: TransactionReceipt from a reverted tx inside a script

In the Brownie-documentation it says: Debugging Tools When using the console, transactions that revert still return a TransactionReceipt object. This object provides access to various attributes and ...
Egirus Ornila's user avatar
0 votes
1 answer
451 views

I want to limit the amount of ethers sent to a smart contract

I am a kinda newbie to this, so please excuse my questions. MY FIRST QUESTION: I am creating a simple ICO using a simple smart contract. I want to set a limit for people to send ETH to this smart ...
Admani's user avatar
  • 1
0 votes
1 answer
142 views

How to reject an address from entering a lottery if that person has already entered

I am programming a lottery. I am storing the players (addresses) who enter in a public array, and I only want a person to be able to enter ONCE per lottery. Meaning if they have sent in the required ...
e n's user avatar
  • 41
0 votes
1 answer
116 views

Method works on local but fails on Ropsten [closed]

Trying to debug this transaction (it's a large one that deploys a contract) that works on local but fails on ropsten. First, it said Error: cannot estimate gas; transaction may fail or may require ...
beanie's user avatar
  • 11
1 vote
1 answer
1k views

What is the layout of returndata from returndatacopy opcode?

I am attempting to perform operations on returned data from delegatecall opcode using a similar familiar proxy pattern: assembly { let ptr := mload(0x40) // load empty memory address pointer ...
Shiri's user avatar
  • 786
0 votes
1 answer
116 views

Calling another contract that reverts

If i call a function from another contract(using interface), and that function has require statement that reverts... will my function break, or will it continue to execute? So the question is... will ...
smenir443's user avatar
  • 125
0 votes
1 answer
202 views

ERROR: transact to Lottery.(receive) errored: VM error: revert

I have been developing a personal project and I am getting this error: transact to Lottery.(receive) errored: VM error: revert. Can someone help me? // SPDX-License-Identifier: GPL-3.0 pragma ...
Luis Rodrigues's user avatar
12 votes
2 answers
2k views

How to bubble up a custom error when using DELEGATECALL?

Solidity v0.8.4 introduced custom errors: error Unauthorized(); Say I have contract A which delegate calls to contract B. The latter reverts with the custom error defined above. How can I bubble that ...
Paul Razvan Berg's user avatar
2 votes
1 answer
2k views

Force function execution

I have an approve method. function approve(address spender, uint value) public returns(bool){ if (msg.sender==_owner){ allowance[msg.sender][spender] = value; emit ...
blackdream's user avatar
0 votes
2 answers
658 views

Approve fail [execution reverted]

Novadays we can see a lot of scamcoins on bsc. Why do all approve transactions fail? smart contract link. I thought all reverts preventing transaction execution. But here we can see error messages in ...
blackdream's user avatar
0 votes
1 answer
781 views

BSC Transaction revert but no reason

I encountered a problem. My contract occasionally has execution exceptions, but there is no error prompt. I read the VM trace and found the following errors, but I don't understand why. Can someone ...
bencong he's user avatar
0 votes
1 answer
307 views

Failing to fill 0x quote

I'm trying to fill a quote that I get from the 0x API: const qs = createQueryString({ sellToken: 'TUSD', buyToken: 'WETH', sellAmount: BigInt(882693 * 10 ** 18) }); ..but the transaction ...
dNyrM's user avatar
  • 890
0 votes
1 answer
1k views

QuickSwap transaction reverts on Polygon

I'm attempting to swap USDC for DAI using Web3JS and QuickSwap on Polygon, but the transaction always reverts and I have no idea why. I have tried different value amounts in the transaction without ...
Jak's user avatar
  • 103
0 votes
1 answer
965 views

Fail with error 'TransferHelper: TRANSFER_FROM_FAILED', all gas used up

I'm trying to buy some CHY with USDT on Uniswap main net, fails with error 'TransferHelper: TRANSFER_FROM_FAILED', This is my failed tx link. This is a successful tx link from someone else. I notice ...
aj3423's user avatar
  • 251
0 votes
2 answers
600 views

Why is transaction reverting with custom smart contract?

I have deployed a smart contract to the Polygon Mumbai Testnet (it shouldn't really matter where I deployed it). When sending a transaction to call a function on this contract, the transaction fails, ...
David Callanan's user avatar
3 votes
0 answers
71 views

Is EVM vulnerable to denial of service with out of gas in call to other contract?

if I call a function in a sub-contract and it runs out of gas, the gas is not completely consumed. Instead, it is returned to the calling contract. Could that be a vulnerability for a denial of ...
Mario HSMW's user avatar
0 votes
1 answer
256 views

Aave Flashloan `reverted with reason '73'`

I'm getting an error when attempting to execute an Aave V2 Flashloan within a Hardhat-mocha test while connected to a fork of the Kovan network. It's unclear to me what revert reason "73" ...
pygeek's user avatar
  • 131
1 vote
1 answer
359 views

Why doesn't the shift operation revert on overflow in Solidity ^0.8.0?

Take the following function: solidity ^0.8.0; function foo(uint256 x) external pure returns (uint256) { uint256 y = x << 255; return y; } If you set x = 2, the result is 2**256, which ...
Paul Razvan Berg's user avatar
2 votes
1 answer
1k views

Do all Ethereum networks return the revert reasons as a "message" field?

I noticed that reverted transactions on Kovan don't include the revert reason. I'm getting the generic "Reverted"/ "VM execution error." Is Koval special in this regard? I know ...
Paul Razvan Berg's user avatar
1 vote
2 answers
875 views

I am having an error when I interact with my smart contract

first of all here are the codes var web3 = new Web3(Web3.givenProvider); var contractInstance; var x = 0 $(document).ready(function() { window.ethereum.enable().then(function(accounts){ ...
Newdude's user avatar
  • 61
1 vote
1 answer
2k views

abi.decode with pragma experimental ABIEncoderV2 reverts with nested array

I have a function with a parameter of bytes calldata that needs to be decoded to a struct, but the call reverts in assembly. I believe the issue has something to do with the nested array. I have ...
Ben Schoeler's user avatar
3 votes
2 answers
1k views

Gas refunds via “Self-destruct” prior to a revert()

In a transaction that eventually calls revert(), if prior to the revert we have SELFDESTRUCT some contracts and thus received a gas refund, does the gas refund also get reverted?
Ben Schoeler's user avatar
4 votes
1 answer
2k views

How to get require() error message?

I can see the error message on Etherscan. But I can't find it in getTransactionRecept(). Is there any special settings that I need set in my Genesis.json before I can see it?
s k's user avatar
  • 886
2 votes
1 answer
303 views

UnhandledPromiseRejectionWarning: Error: nonce generation function failed or private key is invalid in Ganache

In Go I am using go-ethereum to read data from the ethereum smart contract. My smart contract is maintained with truffle. I am trying to fetch candidate information based on candidate id. I have a ...
NinjaMAN's user avatar
  • 409
0 votes
0 answers
92 views

Is there a way to get revert message by my client?

I have a smart contract with this simple function: function addUser( string memory _username, string memory _nome, string memory _cognome, string memory _email) public isOwner() { require(bytes(...
alfo888_ibg's user avatar
8 votes
4 answers
18k views

How to get reason revert using web3.eth.call

I have a smart contract with required message and pretend to use the required/validation message in front end. require(bytes(hashAlreadyRegistered[hash]).length == 0, "Hash already registered&...
RAFAEL DA SILVA's user avatar
0 votes
0 answers
177 views

Is there a way to know if a Solidity method will revert?

I have some solidity methods in my contract, and when i make a send in web3.js i would like to know if there is a way to know if the functions are going to revert by using call. Per-example , in ...
jnuno98's user avatar
3 votes
1 answer
260 views

What is the purpose of a `// dev:` comment after a revert or require statement?

What does it mean when a Solidity contract includes a comment starting with // dev: after a revert or require statement? For example: contract Example { function greet(){ revert(); // ...
iamdefinitelyahuman's user avatar
6 votes
1 answer
2k views

How to catch a `revert()` error using Brownie?

I am using Brownie to develop my smart contracts, which helps me to intract with the smart contracts, please see doc. When my call Example.greet() is there any way to return the error message and act ...
alper's user avatar
  • 8,375
1 vote
1 answer
3k views

While testing wrap & unwrap of ETH to WETH on Kovan ,however the wrap function is fine but unwrap func fails,is anything wrong in my approach?

trx fails at & debug at tenderly pragma solidity 0.5.12; contract WETH9_ { mapping (address => uint) public balanceOf; mapping (address => mapping (address => ...
Akki's user avatar
  • 23
9 votes
5 answers
10k views

How can I get the revert reason of a call in Solidity so that I can use it in the same on-chain transaction?

I want to get the revert reason of a failed call and then use that revert reason in the same on-chain transaction. Is this possible?
Shane Fontaine's user avatar
2 votes
1 answer
539 views

On Etherscan, what is the difference between a failed transaction that says 'Reverted' and one that says 'Execution Reverted'?

On Etherscan, a failed transaction will provide a reason for failure. This can be Reverted, Out of Gas, Bad instruction, etc. However, there seems to be an inconsistent message on different testnets. ...
Shane Fontaine's user avatar
2 votes
0 answers
122 views

How to know the reason of transaction's reversion in parity?

I am testing ERC20 USDT contract locally with parity. I imported contract to my private testnet and manually generated raw transaction that calls "transfer" method of contract. I send it to the node ...
Oroffe's user avatar
  • 263
0 votes
1 answer
2k views

Transfer ERC20 Token - Encountered during contract execution [Reverted]

When trying to sent some ERC20 Token from wallet getting following error: Warning! Error encountered during contract execution [Reverted] This error returned when i call transferFrom()( I made ...
pawelnbd1992's user avatar
1 vote
1 answer
422 views

Payable constructor gives revert message

I am trying to execute the following contract on remixe IDE: pragma solidity ^0.5.4; contract GuessTheNumberChallenge { constructor() public payable { require(msg.value == 1 ether); } ...
zak100's user avatar
  • 1,406
1 vote
2 answers
6k views

How to diagnose a "Error: Transaction has been reverted by the EVM"?

This the error intercepted from my javascript, using web3.js Error: Transaction has been reverted by the EVM: { "blockHash": "...
realtebo's user avatar
  • 333
22 votes
1 answer
17k views

Is it possible to perform a try-catch in Solidity?

Does Solidity support try-catch functionality? If so, how does it work? What are the limitations?
Shane Fontaine's user avatar
0 votes
1 answer
98 views

Trying to get array size but it reverts

I wanted to get array length by getter function, but it keeps reverts. But I have no idea why it's reverting. Here is my code. struct ItemAddress { uint8 sendNatCd; uint8 rcvNatCd; uint16 ...
Jung Chun's user avatar
  • 191