Three primary ways of interacting with a smart contract using Brownie
- Scripts
- Console
- Tests
$ brownie bake token
Requires only the script name (i.e. filename excluding .py) if the script contains a “main” function
$ brownie run <script_name>
Relevant brownie libraries must always be imported when writing scripts
from brownie import *
Token.deploy(<name>, <symbol>, <decimals>, <amount>, {‘from’: <owner>})
Also include the function name if you are not calling the “main” function
$ brownie run <script_name> <function_name>
Execute a script from the brownie console
>>> run(<script_name>)
tests/conftest.py contains testing fixtures used in other tests. This will be covered in future tutorials.
Include test_ as prefix in filename and function name i.e. tests/test_mint.py
def test_<testname>(<fixtures>):
assert <condition>
$ brownie test <filepath>