0

I am trying to run the below script from python but it does not find the ADAI contract that I just compiled. It works fine when I do brownie run scripts/interact.py from the command line.

Looks like by default all brownie classes are not available when I run from a python script. How Can I make those classes available so that I can run it from python script as well instead of running it from CLI.

I want to call the contract function from the frontend and that's the reason I am trying to use it in python script.

from brownie import ADAI, accounts, config

def main():
    account = accounts.add(config["wallet"]["from_account"])
    print(ADAI[-1].balanceOf(account))

I ran the below script to check the available classes and I don't see my compiled solidity contracts there.

from brownie import *
print(dir())
['Contract', 'ETH_ADDRESS', 'Fixed', 'Wei', 'ZERO_ADDRESS', '__annotations__', '__builtins__', '__cached__', '__doc__', '__file__', '__loader__', '__name__', '__package__', '__spec__', 'accounts', 'alert', 'chain', 'compile_source', 'config', 'history', 'multicall', 'network', 'project', 'rpc', 'run', 'web3']
2
  • what is the name of the contract?
    – Yilmaz
    Jan 13 at 8:26
  • Contract Name is ADAI
    – Anni
    Jan 14 at 4:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.