Not using brownie console

Hi,

I’m trying to write a python app that will interact via brownie with BSC and use the LINK Random Number as in Decentralized RPG Game on BSC.

However, I think I’m missing a core concept of brownie that I can’t seem to find any guidance on online. I would like to package the app in a web UI and use brownie to call and interact with the contracts on an adhoc basis, but I can’t seem to figure out how to import the compile contract into Python?

In other words, in the brownie console you get access to the FantasyCharacter object of type Contract, but how would you import that into a normal Python script?

I’ve done

brownie compile

which makes the build directory, but doing from brownie import FantasyCharacter obviously doesn’t work as this isn’t a class within the brownie package. However, in the brownie docs they do from brownie import Token where Token is a compiled smart contract.

Any assistance would be appreciated.

Either there is a way, or I’m missing the fundamentals of how brownie works and contracts can only be deployed using brownie run <script>

1 Like

Hi @louwjlab

Please share the deployment code and the way you trying to deploy it (console command, main deployment code) and I will quickly help you solve this problem.

Hey @louwjlab

I’m having the same issue, did you find a solution?

Thanks

Moved to truffle… :sweat_smile:

haha thanks. truffle it is then

Please don’t hahaha.

It is quite easy, to import your contract in a Python script you just do

from brownie import <name of your contract, not the file, your contract>

This is the full playlist of brownie development.

The video that tackles your specific question.

1 Like