The network
package holds classes for interacting with the Ethereum blockchain. This is the most extensive package within Brownie and contains the majority of the user-facing functionality.
The main
module contains methods for conncting to or disconnecting from the network. All of these methods are available directly from brownie.network
.
The account
module holds classes for interacting with Ethereum accounts for which you control the private key.
Classes in this module are not meant to be instantiated directly. The Accounts
container is available as accounts
(or just a
) and will create each Account
automatically during initialization. Add more accounts using Accounts.add
.
The alert
module is used to set up notifications and callbacks based on state changes in the blockchain.
Alerts and callbacks are handled by creating instances of the Alert
class.
The contract
module contains classes for deploying and interacting with smart contracts.
When a project is loaded, Brownie automatically creates ContractContainer
instances from on the files in the contracts/
folder. New ProjectContract
instances are created via methods in the container.
If you wish to interact with a contract outside of a project where only the ABI is available, use the Contract
class.
Arguments supplied to calls or transaction methods are converted using the methods outlined in the convert<api-brownie-convert>
module.
Contract
and ProjectContract
are both used to call or send transactions to smart contracts.
Contract
objects are instantiated directly and only require an ABI. They are used for calls to existing contracts that exist outside of a project.ProjectContract
objects are created by calls toContractContainer.deploy
. Because they are compiled and deployed directly by Brownie, they provide much greater debugging capability.
These classes have identical APIs.
The event
module contains classes and methods related to decoding transaction event logs. It is largely a wrapper around eth-event.
Brownie stores encrypted event topics in brownie/data/topics.json
. The JSON file is loaded when this module is imported.
The state
module contains classes to record transactions and contracts as they occur on the blockchain.
The internal methods in the state
module are primarily used for tracking and adjusting Contract
instances whenever the local RPC network is reverted or reset.
The rpc
module contains the Rpc
class, which is used to interact with ganache-cli
when running a local RPC environment.
Note
Account balances, contract containers and transaction history are automatically modified when the local RPC is terminated, reset or reverted.
The transaction
module contains the TransactionReceipt
class and related internal methods.
The web3
module contains a slightly modified version of the web3.py Web3
class that is used throughout various Brownie modules for RPC communication.
See the Web3 API documentation for detailed information on all the methods and attributes available here. This document only outlines methods that differ from the normal Web3
public interface.