eth-brownie / brownie

A Python-based development and testing framework for smart contracts targeting the Ethereum Virtual Machine.
https://eth-brownie.readthedocs.io
MIT License
2.65k stars 552 forks source link

Cannot access transaction's "return_value" with Anvil #1754

Open no-fee-swap opened 9 months ago

no-fee-swap commented 9 months ago

Environment information

What was wrong?

Brownie v1.20.2 works great! Thank you. But I have the following issue with it:

When I use Anvil, features such as "tx.return_value" or "tx.call_trace" do not work. They return none type. It works great with Hardhat. But Anvil is faster and it would be great if we can access "return_value" with Anvil as well.

Please include information like:

I first run anvil with the following command in terminal: anvil --hardfork cancun

I then open another terminal and run brownie: brownie console --network anvil

I then run the following script:

from brownie.network.gas.strategies import LinearScalingStrategy
from brownie.network import gas_price
gas_strategy = LinearScalingStrategy("60 gwei", "70 gwei", 1.1)
gas_price(gas_strategy)
token = ERC20FixedSupply.deploy("ERC20_0", "ERC20_0", 1, accounts[0], {'from': accounts[0]})
tx = token.transfer(accounts[1], 1, {'from': accounts[0]})

I am supposed to get a bool as return value, but the following command returns nothing: tx.return_value

VersoriumX commented 7 months ago

In this place we have to create or describe "_Value". In essence we are setting the digital parameters. The "_strategy" is to be defined based on concurrent data as well as the accounts from which you wish to send. I hope this Helps Cheers.

iamdefinitelyahuman commented 6 months ago

Does anvil expose the debug_traceTransaction endpoint?

LanceUp commented 5 months ago

i found a workaround adding "--steps-tracing" anvil's flag in network-config.yaml (typically located in ~/.brownie/) for anvil's fork: cmd: anvil --steps-tracing no need to run anvil in another terminal, but, if you need to do it for some reason, in your case, run it with: anvil --hardfork cancun --steps-tracing