Skip to content

Latest commit

 

History

History
656 lines (404 loc) · 24.2 KB

api-project.rst

File metadata and controls

656 lines (404 loc) · 24.2 KB

Project API

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.

brownie.project.main

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.

Project

The Project class is the top level container that holds all objects related to a Brownie project.

Project Methods

TempProject

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.

Module Methods

brownie.project.build

The build module contains classes and methods used internally by Brownie to interact with files in a project's build/contracts folder.

Build

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>

Build Methods

Build Internal Methods

Internal Methods

The following methods exist outside the scope of individually loaded projects.

brownie.project.compiler

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.

Module Methods

brownie.project.ethpm

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.

Module Methods

brownie.project.scripts

The scripts module contains methods for comparing, importing and executing python scripts related to a project.

Internal Methods

brownie.project.sources

The sources module contains classes and methods to access project source code files and information about them.

Sources

The Sources object provides access to the contracts/ and interfaces/ files for a specific project. It is instantiated automatically when a project is loaded, 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>

Module Methods