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 deploy function returns `brownie.exceptions.VirtualMachineError: revert`

See original GitHub issue

Environment information

  • brownie Version: 1.14.6
  • ganache-cli Version: 6.12.2
  • vyper Version: 0.2.12+commit.2c6842c
  • Python Version: 3.9.4
  • OS: osx

What was wrong?

in my file i have:

import pytest
import brownie
from brownie import accounts, contract_name

# deploy contract
def deploy(contract_name, accounts):
    return contract_name.deploy({'from':accounts[0]}) # yes, the contract constructor takes no args

# clean chain for each function, ensures clean working environment
def shared_setup(fn_isolation):

and then in my tests/ i have:

import pytest
import brownie
from brownie import accounts
from brownie.test import given, strategy

@given(amount_sent = strategy('uint256', max_value=10**18, min_value=2))
def test_tax_amount_deducted_from_party_balances(amount_sent, deploy):
    # do stuff

running brownie test tests/ or any test for that matter returns this error:

Brownie v1.14.6 - Python development framework for Ethereum

======================================================== test session starts ========================================================
platform darwin -- Python 3.9.4, pytest-6.2.3, py-1.10.0, pluggy-0.13.1
rootdir: /Users/REDACTED/Desktop/file/another_file
plugins: eth-brownie-1.14.6, hypothesis-6.10.0, xdist-1.34.0, forked-1.3.0, web3-5.18.0
collected 1 item                                                                                                                    

Launching 'ganache-cli --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie'...

tests/ E                                                                                                           [100%]

============================================================== ERRORS ===============================================================
__________________________________ ERROR at setup of test_tax_amount_deducted_from_party_balances ___________________________________

contract_name = < object at 0x7ffbcdc44c10>
accounts = < object at 0x7ffbcb881880>

    def deploy(contract_name, accounts):
>       return contract_name.deploy({'from':accounts[0]})
E       brownie.exceptions.VirtualMachineError: revert

tests/ VirtualMachineError
====================================================== short test summary info ======================================================
ERROR tests/ - brownie.exceptions.VirtualMachineError: revert
========================================================= 1 error in 10.91s =========================================================
Terminating local RPC client...

odd because it was working before i put it into the conftest, but moving it back to the individual test file makes no difference so not the cause

thanks in advance for the help, brownie is awesome i much prefer it to truffle

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5 (1 by maintainers)

github_iconTop GitHub Comments

liam-otcommented, Jul 10, 2021

@skellet0r actually, you made a good point that there was an assumption in the constructor, I was attempting to set a variable in the contract with an interface call, commenting out lead to a different issue, but the issue described here is fixed, thanks

liam-otcommented, Jul 10, 2021

output from deploying with contract_name.deploy({'from':accounts[0]})

Transaction sent: 0xd6c0358295c9d9adbc8855c01c06922ef009f0979b59b9d47d22d3dbe10fb5c0
  Gas price: 0.0 gwei   Gas limit: 12000000   Nonce: 0
  new_metawhale.constructor confirmed (reverted) - Block: 1   Gas used: 261099 (2.18%)

<Transaction '0xd6c0358295c9d9adbc8855c01c06922ef009f0979b59b9d47d22d3dbe10fb5c0'>
Read more comments on GitHub >

github_iconTop Results From Across the Web

ERROR Brownie Mainnet Fork Testing `brownie.exceptions ...
I am following 16 hours Solidity course of 'freecodecamp` which is presented by Patrick Collins. SOLIDITY CODE: //SPDX-License-Identifier: MIT ...
Read more >
VirtualMachineError: revert - Ethereum Stack Exchange
it will deploy a mock version of that contract, and return that mock contract. #Args: contract_name (string). #REturns:
Read more >
brownie.exceptions - Read the Docs
Raised when attempting to access a Contract object that no longer exists because the local network was reverted. exception brownie.exceptions.
Read more >
eth-brownie/community - Gitter
Hi ! I got this error when i try to compile my contract. Its compiling fine on remix... been trying various things over...
Read more >
Error: VM Exception while processing transaction: revert.
In the run tab there is a drop down under the value field, where you can select your contract and then either enter...
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 Post

No results found

github_iconTop Related Hashnode Post

No results found