The project
package contains methods for initializing, loading and compiling Brownie projects, and container classes to hold the data.
When Brownie is loaded from within a project folder, that project is automatically loaded and the ContractContainer
objects are added to the __main__
namespace. Unless you are working with more than one project at the same time, there is likely no need to directly interact with the top-level Project
object or any of the methods within this package.
Only the project.main
module contains methods that directly interact with the filesystem.
The main
module contains the high-level methods and classes used to create, load, and close projects. All of these methods are available directly from brownie.project
.
The Project
class is the top level container that holds all objects related to a Brownie project.
TempProject
is a simplified version of Project
, used to hold contracts that are compiled via main.compile_sources
. Instances of this class are not included in the list of active projects or automatically placed anywhere within the namespace.
The build
module contains classes and methods used internally by Brownie to interact with files in a project's build/contracts
folder.
The Build
object is a container that stores and manipulates build data loaded from the build/contracts/
files of a specific project. It is instantiated automatically when a project is opened, and available within the api-project-project
object as Project._build
.
>>> from brownie.project import TokenProject
>>> TokenProject._build
<brownie.project.build.Build object at 0x7fb74cb1b2b0>
The following methods exist outside the scope of individually loaded projects.
The compiler
module contains methods for compiling contracts, and formatting the compiled data. This module is used internally whenever a Brownie project is loaded.
In most cases you will not need to call methods in this module directly. Instead you should use project.load
to compile your project initially and project.compile_source
for adding individual, temporary contracts. Along with compiling, these methods also add the returned data to project.build
and return ContractContainer
objects.
The ethpm
module contains methods for interacting with ethPM manifests and registries. See eth-pm
for more detailed information on how to access this functionality.
The scripts
module contains methods for comparing, importing and executing python scripts related to a project.
The sources
module contains classes and methods to access project source code files and information about them.
The Sources
object provides access to the contracts/
files for a specific project. It is instantiated automatically when a project is opened, and available within the api-project-project
object as Project._sources
.
>>> from brownie.project import TokenProject
>>> TokenProject._sources
<brownie.project.sources.Sources object at 0x7fb74cb1bb70>