1

Im trying to run

brownie run ./scripts/create_myToken.py --name "Myname" --network rinkeby

I have args = sys.argv[1:] to catch --name etc like normal python

But brownie doesnt seem to like this command line format and returns error "Usage: brownie run [] [options]"

Is there a solution ?

2 Answers 2

4

brownie run is designed to be run without any extra arguments besides the ones listed in brownie run -h.

All arguments are passed into the docopt function which parses the options based on the docstring. Any extra arguments that are not listed causes the parser to throw the error you are seeing.


You can still use brownie to deploy your contract. But you will need to perform the brownie setup and argument parsing inside your python script. Then just call python create_myToken.py with your arguments.

The main things to setup for brownie are connecting to a network and loading your project.

import brownie
brownie.network.connect('rinkeby')
myproject = brownie.project.load('path/to/project')

Then you can either call your python project contracts on your myproject object, or you could go the next step of importing everything, similar to having an active project in the directory. Just be aware that to import, you'll need to either use the resolved name of the project or pass a name in while loading the project.

from brownie.project.<ResolvedNameProject> import *
# or
myproject = brownie.project.load('path/to/project', 'my_project')
from brownie.project.my_project import *
2
1

With the release of brownie 1.17.0, they actually introduced the possibility to pass args and kwargs into the brownie run cli-command using the syntax as in the example below:

brownie run scripts/create_myToken.py yourFunctionName args kwargs --network rinkeby

For further details see https://github.com/eth-brownie/brownie/issues/398

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.