Questions tagged [revert-opcode]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
15 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
30 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
1
vote
2answers
32 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
0answers
25 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 ...
2
votes
0answers
24 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 ...
0
votes
0answers
27 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
1answer
200 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, ...
1
vote
0answers
31 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 = ...
2
votes
1answer
75 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 ...
1
vote
1answer
44 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, ...
2
votes
1answer
65 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 ...
2
votes
2answers
98 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 ...
2
votes
1answer
244 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
226 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....
4
votes
1answer
287 views

Getting transaction receipt with a reverted transaction to determine how much gas was used?

In web3.js, if a revert occurs, it doesn't give a receipt along with it. I want to determine how much gas was actually used after a revert. In 1.0, I can't even get the tx hash from the event ...
0
votes
2answers
106 views

Require validation error not working

I tried using require method in solidity in the following way: require(validate(personName),"Error: Invalid Person") In this case i am checking if a person is already added to my person list. If not ...
0
votes
2answers
103 views

Here is my sample code, whether the contract to contract calls in setName function is synchronous or asynchronous?

pragma solidity ^0.4.22; contract Testing { function setName(bytes32 firstName , bytes32 lastName) public returns(bool) { Sample _test = new Sample(firstName); _test.addLastName(...
1
vote
1answer
269 views

Solidity/Remix Error : The constructor should be payable if you send value?

Simple contract, but don't transfer ETH! pragma solidity ^0.4.24; contract Upper { uint public count; constructor() payable public {} function() payable public { count++; } ...
0
votes
1answer
71 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 ...
6
votes
2answers
1k 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 ...
0
votes
1answer
94 views

Non deterministic gas usage of the same function

Environment Truffle v4.1.8 node 10.0.0 pragma solidity ^0.4.21; Issue I'm calling the claimRefund function on my smart contract using metamask. When calling the function with 37081 gas limit at 20 ...
1
vote
2answers
708 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 ...
0
votes
1answer
19 views

.transfer question [duplicate]

How does the transfer function behave? Was looking at a function I created, and saw that we transfer ether out of the contract, before deleting the data which determines whether or not it is allowed ...
0
votes
1answer
214 views

Solidity: VM Exception while processing transaction: invalid opcode - What happens?

If VM Exception while processing transaction: invalid opcode is thrown, does it have the same effect than revert?
0
votes
2answers
338 views

Unable to transfer ERC20 tokens from a contract

I'm having trouble getting a solidity contract method to transfer ERC20 tokens from address A to B assuming B has called approve outside the contract and setup sufficient allowance for A. The ...
1
vote
0answers
354 views

How to catch reverted transaction while using metamask

I'm working with metamask and was testing a transaction that should trigger a revert statement inside my contract. When the error is thrown metamask gives the following output: this was while using ...
20
votes
3answers
4k 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
3answers
748 views

Web3 transaction to a contract fails with revert. Same transaction works from truffle console

I have a simple contract transaction that creates another contract. This transaction when called from Node.js using Web3 and truffle-contract throws a revert. ContractFactory.deployed().then(function(...
8
votes
3answers
2k 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
381 views

Can't find a way to log when revert()'ing in remix

This is my first time working with Solidity and I soon ran into an issue. When an address doesn't have enough balance or doesn't have the authority to add coins I want to log an error, when these ...
2
votes
1answer
317 views

TypeError: Member “mint” not found or not visible after argument-dependent lookup in contract ERC20

token.mint(beneficiary, tokens) prevents code from fully compiling using Zeppelin 1.8. Casting your token as a MintableToken* solves this issue and allows your code to compile: MintableToken token = ...
4
votes
0answers
156 views

Is it possible to trace a function call hitting revert?

It is possible to trace a transaction with debug_traceTransaction. But it needs the transaction hash, requiring it to be a transaction in first place. I'm debugging a function call that generates a ...
0
votes
0answers
80 views

Sending ether from contract cause error

Hi In my contract I send ether from my contract to other address like address.transfer(winnerAmount);. It transfer ether successfully if my array have one address. If I have more than one address it ...
1
vote
1answer
5k views

what is [Reverted] during contract execution

I have sent ETH to a contract address, and it "failed" the transaction saying it is: Warning! Error encountered during contract execution [Reverted] contract address and transaction failure here: ...
0
votes
1answer
604 views

Transaction Error. Exception thrown in contract code. REVERT opcode when sending ETH to crowdsale

I wanted to follow the tutorial - https://blog.zeppelin.solutions/how-to-create-token-and-initial-coin-offering-contracts-using-truffle-openzeppelin-1b7a5dae99b6 - but there was a new release - https:/...
0
votes
2answers
156 views

How to intercept Metamask error to display a more user friendly message?

I have a Dapp with smart a contract that has a revert function that can only happen in a specific case. When the revert is triggered, Metamask shows the error like this: Is there a way to "intercept"...
8
votes
1answer
2k 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
1answer
157 views

lost transaction — not back in my MEW

i sent a transaction to credits ico and it came back with a transaction failure due to a revert opcode. the credits team say they are not responsible i should take it up with ethereum. the ether-...
2
votes
2answers
151 views

Does ether transfer consume all gas in case of exception?

If addr.transfer() fails, does it use a revert- or throw-style exception? In other words, does a failed transfer consume all provided gas?
0
votes
2answers
636 views

Transaction Failures from MetaMask

I tried to send some Ether for an ICO (my first ever) but the transaction failed with error revert opcode. Please see below. https://etherscan.io/tx/...
3
votes
1answer
1k views

Truffle sendTransaction sending eth to contract address returns revert

I have a contract address not a deployed contract instance in which i want to send ETH to but it fails giving Error: VM Exception while processing transaction: revert MyContract.deployed() .then(...
1
vote
1answer
312 views

Is it good practice to use revert() in case a function does find a match in case of a search?

This Solidity function: function findSupplierByName(string supplierName) public view returns (address id, string name) { for (uint idx = 0; idx < supplierAddresses.length; idx++) { ...
3
votes
3answers
2k views

why do we use revert() in payable function?

I have seen this snippet in many online examples could you please explain what this is doing and why are we using it in a payable function? function () public payable { revert () ; }
0
votes
1answer
261 views

How to stop contract execution w/o losing events

Function revert() is supposed to stop contract execution and rollback every change on blockchain except events reported. That's exactly what I need, but it seems to me it is not working as expected. ...
38
votes
2answers
11k views

How do I detect a failed transaction after the Byzantium fork as the REVERT opcode does not consume all gas?

Pre Byzantium fork, I could use gas == gasUsed to detect when a transaction has failed (further details in How can the transaction status from a thrown error be detected when gas can be exactly the ...
2
votes
0answers
223 views

Strange revert() behavior on Etherscan

I am testing my contract, which is for an auction. I've deployed it on the Rinkeby testnet. I have a payable function that calls revert() if the bid being placed isn't higher than the existing bid. ...
12
votes
3answers
5k views

Why do `throw` and `revert()` create different bytecodes?

throw and revert() are both compiling to the revert operation (opcode 0xfd). According to the docs: The throw keyword can also be used as an alternative to revert(). Why is it then that the ...
3
votes
0answers
117 views

Assuming EIP140, is remaining gas refunded when a called contract throws?

Under EIP140 (REVERT) and assuming Solidity ≥0.4.10. If I call from my contract to a function on an external contract, and this external function does an invalid jump, does my contract still call ...
6
votes
1answer
2k 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 ...
4
votes
1answer
388 views

Will existing contracts behave differently when REVERT is implemented by Metropolis?

Solidity v0.4.10 introduced the revert() and require() functions, along with support for the REVERT opcode. As far as I can tell, this means that any contract compiled using ^0.4.10 will express ...