Skip to content

Latest commit

 

History

History
2035 lines (1323 loc) · 72.6 KB

api-network.rst

File metadata and controls

2035 lines (1323 loc) · 72.6 KB

Network API

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.

brownie.network.main

The main module contains methods for conncting to or disconnecting from the network. All of these methods are available directly from brownie.network.

brownie.network.account

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.

Accounts

Accounts Methods

Accounts Internal Methods

Account

Account Attributes

Account Methods

LocalAccount

LocalAccount Attributes

LocalAccount Methods

PublicKeyAccount

brownie.network.alert

The alert module is used to set up notifications and callbacks based on state changes in the blockchain.

Alert

Alerts and callbacks are handled by creating instances of the Alert class.

Module Methods

brownie.network.contract

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.

ContractContainer

ContractContainer Attributes

ContractContainer Methods

ContractContainer Internal Methods

Contract and ProjectContract

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 to ContractContainer.deploy. Because they are compiled and deployed directly by Brownie, they provide much greater debugging capability.

These classes have identical APIs.

Contract Attributes

Contract Methods

Contract Internal Attributes

ContractCall

ContractCall Attributes

ContractCall Methods

ContractTx

ContractTx Attributes

ContractTx Methods

OverloadedMethod

brownie.network.event

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.

EventDict

Internal Classes and Methods

_EventItem

Internal Methods

brownie.network.state

The state module contains classes to record transactions and contracts as they occur on the blockchain.

TxHistory

TxHistory Attributes

TxHistory Methods

TxHistory Internal Methods

Internal Methods

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.

brownie.network.rpc

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.

Rpc

Rpc Methods

Rpc Internal Methods

Internal Methods

brownie.network.transaction

The transaction module contains the TransactionReceipt class and related internal methods.

TransactionReceipt

TransactionReceipt Attributes

TransactionReceipt Methods

brownie.network.web3

The web3 module contains a slightly modified version of the web3.py Web3 class that is used throughout various Brownie modules for RPC communication.

Web3

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.

Web3 Methods

Web3 Attributes

Web3 Internals

Internal Methods