Questions tagged [revert-opcode]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
84 views

Calculating a minimum entry fee for a game based on typical minimum gas requirements?

I am creating a dApp that is a game where players compete for the prize pool and that pool is built from the sum of all the entry fees payed by the player at the start of the game. The player that ...
0
votes
0answers
30 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 ...
0
votes
1answer
47 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 ...
0
votes
2answers
48 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, ...
29
votes
7answers
9k views

how to catch “revert” error in truffle test javascript?

How can I catch "revert" error in truffle test written in javascript? Error: VM Exception while processing transaction: revert Here is part of test contract, function doRevert() public { ...
1
vote
1answer
319 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){ ...
3
votes
0answers
9 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 ...
0
votes
1answer
10 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" ...
2
votes
1answer
152 views

Ether in ERC-20 transactions?

I have one contract that I give tokens from a ERC20 contract implemantation. When I call the balanceOf function from the Token conract. Response me that I have x Tokens. Nice !! But when I try to ...
10
votes
1answer
3k 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?
1
vote
1answer
35 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 ...
0
votes
0answers
83 views

Transaction has been reverted by the EVM - How to deduce the revert reason in this case?

I get this error when I call a function that changes the state of the smart contract from the frontend: Error: Transaction has been reverted by the EVM: { "blockHash": "...
2
votes
1answer
271 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 ...
3
votes
2answers
432 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?
11
votes
6answers
5k views

How to receive revert() reason for past transactions?

I run a geth/parity nodes for broadcasting user's transactions to Ethereum blockchain. Some of contract functions provide reasons for revert (see examble below): contract Example { function test (...
0
votes
1answer
524 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 ...
85
votes
4answers
31k views

Difference between require and assert and the difference between revert and throw

I was looking at the docs and Im looking for clarification on the difference between require and assert and throw and revert. assert(bool condition): abort execution and revert state changes if ...
2
votes
1answer
239 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?
4
votes
2answers
1k views

forward revert message from low level solidity call

I'm working on a proxy contract that will perform calls as follows: bool success; bytes memory returndata; (success, returndata) = _to.call.value(_value)(_data); require(success); this works great, ...
2
votes
0answers
133 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 ...
0
votes
0answers
25 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(...
4
votes
2answers
3k 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&...
0
votes
0answers
52 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 ...
3
votes
1answer
62 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(); // ...
5
votes
1answer
233 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 ...
0
votes
1answer
911 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 => ...
1
vote
2answers
1k 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?
4
votes
3answers
1k views

Is there a way to capture the require / revert failure reason?

In my contract, I have a bunch of checking at the start of a public function. It looks something like this: require ( prx < 1e18, "Value prx too high") require ( prx != 0, "Value prx cannot be ...
5
votes
3answers
3k views

How to catch solidity contract revert message using web3j

Is there any way to catch solidity revert message like Remix Javascript VM in web3j Revert message(Remix) transact to Erecruitment.issueNewAdmitCard errored: VM error: revert. revert The ...
2
votes
1answer
129 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. ...
2
votes
0answers
67 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 ...
0
votes
1answer
695 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 ...
1
vote
1answer
59 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); } ...
0
votes
2answers
2k 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": "...
1
vote
2answers
483 views

How to decode error response from contact

When calling a contract function that I expect to fail by invoking revert, I receive the following JSON-RPC response: { "jsonrpc": "2.0", "id": 1, "result": "...
0
votes
1answer
45 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 ...
0
votes
2answers
247 views

Does reverted transactions considered as mined transactions?

I want to know if a reverted transaction is considered as mined one ? this is mean nonce should be incremented
0
votes
0answers
31 views

Cann't send token with looping function

Sorry, I'm a newbie on ERC721 token. Please help. I have deployed ERC721 contract in the localhost testnet. I use looping function for mint token and it works. But when I use looping function for ...
3
votes
0answers
67 views

How do I check transaction status using go-ethereum simulated back-end?

Using the go-ethereum simulated backend, I would like to: 1) Instantly commit a transaction so that it either succeeds or reverts in a given simulated blockchain. So far I'm using sim.Commit() to ...
2
votes
1answer
490 views

How to handle require/revert/assert errors properly

I'm trying to find an easy pattern to revert/rollback a write transaction. The first idea was to log a GenericErrorEvent but then I noticed that it will never be emited if any require/revert/assert ...
0
votes
0answers
42 views

Revert() workflow in re-entrancy vulnerablity?

I am studying the following code contract Mutex { bool locked; modifier noReentrancy() { require(!locked); locked = true; _; locked = false; } function f(unit256 amount) public ...
1
vote
0answers
33 views

Assert after critical instruction

I've seen a particular code style, where after any "critical" state modification operation, a check is done in order to assess the true good result of the operation. Something like: uint _count = ...
1
vote
1answer
111 views

why use up all the gasLimit when use assembly and revert together?

try to call erc20 token's transferFrom() using assembly(to save some gas), code like this: pragma solidity ^0.4.24; contract TestAssemblyAndRevert { function test(address from, address to, ...
3
votes
2answers
362 views

Does a string message increase the gas usage of a `require` statement?

In solc 0.4.22 onward, it is possible to provide a string message containing details about the error that will be passed back to the caller (in require, assert and revert statements). Does the gas ...
6
votes
2answers
2k views

Getting error message from require()

I know that the latest Solidity supports error messages in require/revert (require(stuff, "problem")). Are there any clients that can get this message? Will I be able to see it if I execute the ...
8
votes
1answer
3k views

Returning an error code with revert

According to the newest version of the yellow paper and Solidity assembly specification, revert opcode can return an error code. http://solidity.readthedocs.io/en/develop/assembly.html revert(p, s)...
1
vote
2answers
1k views

Smartcontract: Warning! contract execution experienced an error and gets [Reverted]

I have sent ropsten ETH to my newly created contract address (still on test mode on the Ropsten Test net). Unfortunately it kept "failing". The blockchain reports: Warning! Error encountered during ...
6
votes
1answer
3k views

Will revert() refund all gas of the transaction or just the remaining gas?

According to the docs revert() will not consume any gas: Note that assert-style exceptions consume all gas available to the call, while revert-style exceptions will not consume any gas starting ...
2
votes
1answer
406 views

Recently upgraded Solc and Web3. Transactions with zero addresses now reverting with “invalid address” message?

I recently upgraded Web3JS and Solc. Now every time I pass a zero address to a Solidity contact method the transaction reverts with an "invalid address" message. This message appears to be coming ...
0
votes
1answer
424 views

Is it safe to call revert() instead of returning a value?

I have the following piece of code: function func() public returns (bool) { if (some condition on msg.sender) { do some stuff return true; } revert(); } The compiler (0.4....