question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Contract that reverts with Solidity Custom Error fails to deploy to Javascript VM

See original GitHub issue

Using the contract from the Custom Errors explainer blog post:

// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;

error Unauthorized();

contract VendingMachine {
    address payable owner = payable(msg.sender);

    function withdraw() public {
        if (msg.sender != owner)
            revert Unauthorized();

        owner.transfer(address(this).balance);
    }
    // ...
}

The contract compiles correctly in Remix IDE, and ABI is created correctly:

{
    "inputs": [],
    "name": "Unauthorized",
    "type": "error"
}

But deployment to Javascript VM fails with following error:

creation of VendingMachine pending...

creation of VendingMachine errored: invalid fragment object (argument="value", value={"inputs":[],"name":"Unauthorized","type":"error"}, code=INVALID_ARGUMENT, version=abi/5.0.7)

On the other hand, deployment to Rinkeby succeeds.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
LianaHuscommented, Apr 28, 2021

ethers.js (5.1.4) was published I think yesterday. thanks anyway 😃

On Wed, Apr 28, 2021 at 1:41 PM Edward Grech @.***> wrote:

@LianaHus https://github.com/LianaHus Cool. Thanks.

TBH I was waiting for ethers-io/ethers.js#1498 https://github.com/ethers-io/ethers.js/issues/1498 fix to be announced, and was intending to create a PR with the dependency upgrade 😊 Was it fixed in a different way?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/ethereum/remix-project/issues/1138#issuecomment-828385841, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACJ4S3EZLB2XBVGD34KE4H3TK7YANANCNFSM43M5WZPQ .

1reaction
LianaHuscommented, Apr 28, 2021

this should be fixed in remix.ethereum.org in an hour. Alpha is already updated

Read more comments on GitHub >

github_iconTop Results From Across the Web

Solidity revert with custom error explained with example
The new method allows users to define a custom error and pass it while reverting a transaction.
Read more >
Remix VM error when deploying - Ethereum Stack Exchange
After a bit of scratching my head, I believe I found the issue. The problem is in registering the contract interfaces.
Read more >
Creation of CustomToken errored: VM error: revert
I tried to deploy the contract will ETH Value but always got the error "The transaction has been reverted to the initial state....
Read more >
Custom Errors in Solidity
The compiler includes all errors that a contract can emit in the contract's ABI-JSON. Note that this will not include errors forwarded through ......
Read more >
Remix Documentation - Read the Docs
called JavaScript VM) is its own “blockchain” and on each reload the ... deployed, accessing a contract with AtAddress does not cost gas....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found