Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GasStrategy - ValueError: invalid literal for int() with base 10: '30 gwei' #1088

Closed
welshm opened this issue May 22, 2021 · 0 comments · Fixed by #1113
Closed

GasStrategy - ValueError: invalid literal for int() with base 10: '30 gwei' #1088

welshm opened this issue May 22, 2021 · 0 comments · Fixed by #1113

Comments

@welshm
Copy link

welshm commented May 22, 2021

Environment information

  • brownie Version: 1.14.6
  • ganache-cli Version: 6.12.2
  • solc Version: x.x.x
  • Python Version: 3.8.2
  • OS: osx

What was wrong?

Running 'scripts/deployment_v2.py::main'...
Transaction sent: 0x56c5e5dd7826e1460f0ff79aa81f0fa30d3bd07e39c7a5c704faedc456bac0f1
  Gas price: 30.0 gwei   Gas limit: 1245447   Nonce: 6
Waiting for confirmation... Exception in thread Gas strategy 0x56c5e5dd7826e1460f0ff79aa81f0fa30d3bd07e39c7a5c704faedc456bac0f1:
Traceback (most recent call last):
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/threading.py", line 932, in _bootstrap_inner
    self.run()
  File "/Applications/Xcode.app/Contents/Developer/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/threading.py", line 870, in run
    self._target(*self._args, **self._kwargs)
  File "/Users/mikewelsh/.local/pipx/venvs/eth-brownie/lib/python3.8/site-packages/brownie/network/gas/bases.py", line 65, in _loop
    gas_price = next(gas_iter)
  File "/Users/mikewelsh/.local/pipx/venvs/eth-brownie/lib/python3.8/site-packages/brownie/network/gas/strategies.py", line 77, in get_gas_price
    last_gas_price = min(int(last_gas_price * self.increment), self.max_gas_price)
ValueError: invalid literal for int() with base 10: '30 gwei'

I tried to deploy a contract to mainnet with with the following...

brownie run scripts/deployment_v2.py --network mainnet

deployment_v2.py

from brownie import MyContract, accounts, config, network
from brownie.network.gas.strategies import GasNowStrategy
from brownie.network.gas.strategies import GasNowScalingStrategy
from brownie.network.gas.strategies import LinearScalingStrategy
from brownie.network import gas_price

def main():
    gas_strategy = LinearScalingStrategy("30 gwei", "30 gwei", 1)
    gas_price(gas_strategy)
    acct = accounts.add(
        config["wallets"]["from_key"]
    )
    contract = MyContract.deploy(
        {"from": acct},
        )
    return contract

How can it be fixed?

I don't know how Brownie interprets gwei into int, but I suspect that's where it's failing. Happy to create a PR if you can point me to where the interpretation or type definition is for gwei

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant