I have a Flask project and a brownie project with a small smartcontract. Now I want to integrate my smartcontract functionality into my Flask app. But, I used to run brownie by:
brownie run scripts/get_information.py --network goerli
How to do it in python code?
In brownie project I used to import my deployed smartcontract by:
from brownie import SmartContract
and then I was able to call its methods, for example:
smart_contract = SmartContract[-1] #last smartcontract that was deployed
print(smart_contract.getNumber())
I found some information about using a brownie project as a package here: https://eth-brownie.readthedocs.io/en/stable/python-package.html but what to do next?
I was able to load my project by p = project.load('./brownie_project', name='brownieProject')
but when I want to import my deployed contract from buid/deployments/
i get an error:
Traceback (most recent call last):
File "c:\project\app\brownie_logic.py", line 1, in <module>
from brownie import project, network, SmartContract
ImportError: cannot import name 'SmartContract' from 'brownie' (C:\project\env\lib\site-packages\brownie\__init__.py)
I found that my first option is to run os.system('<brownie run...>')
, but it doesnt seem to be a proper solution, and my second option is to give up brownie and use pure web3.py library. However, is there a way to make it work with Brownie as a package in Flask project?