Skip to content

Commit

Permalink
even moar docs
Browse files Browse the repository at this point in the history
  • Loading branch information
iamdefinitelyahuman committed Jan 29, 2020
1 parent 0ce5c5a commit 9ad1246
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 24 deletions.
6 changes: 3 additions & 3 deletions docs/accounts.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Managing Local Accounts
=======================

When connecting to a remote network via a hosted node such as `Infura <https://infura.io/>`_, the :ref:`Accounts<api-network-accounts>` container will be empty. Before you can perform any transactions you must add a local account to Brownie.
When connecting to a remote network via a hosted node such as `Infura <https://infura.io/>`_, the :func:`Accounts <brownie.network.account.Accounts>` container will be empty. Before you can perform any transactions you must add a local account to Brownie.

When we use the term `local` it implies that the account exists locally on your system, as opposed to being available directly in the node. Local accounts are stored in encrypted JSON files known as `keystores`. If you want to learn more about keystore files, you can read If you want to understand the contents of your json file you can read `"What is an Ethereum keystore file?" <https://medium.com/@julien.maffre/what-is-an-ethereum-keystore-file-86c8c5917b97>`_ by Julien Maffre.

Expand Down Expand Up @@ -60,7 +60,7 @@ The exported account will be saved at ``<path>``.
Unlocking Accounts
==================

In order to access a local account from a script or console, you must first unlock it. This is done via the ``Accounts.load`` method:
In order to access a local account from a script or console, you must first unlock it. This is done via the :func:`Accounts.load <Accounts.load>` method:

.. code-block::
Expand All @@ -73,4 +73,4 @@ In order to access a local account from a script or console, you must first unlo
>>> accounts
[<LocalAccount object '0xa9c2DD830DfFE8934fEb0A93BAbcb6e823e1FF05'>]
Once the account is unlocked it will be available for use within the ``Accounts`` container.
Once the account is unlocked it will be available for use within the :func:`Accounts <brownie.network.account.Accounts>` container.
8 changes: 6 additions & 2 deletions docs/api.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,15 @@
Brownie API
===========

The following classes and methods are available when writing brownie scripts or using the console.
This section provides a complete overview of the Brownie API. It includes all public classes and methods as well as limited internal documentation.

If you have not yet viewed the documentation under "Core Functionality" within the table of contents, you may wish to start there before exploring the API docs.

.. hint::

From the console you can call ``dir`` to see available methods and attributes for any class. By default, callables are highlighed in cyan and attributes in blue. You can also call ``help`` on any class or method to view information on it's functionality.
From the console you can call the builtin ``dir`` method to see available methods and attributes for any class. Classes, methods and attributes are highlighted in different colors.

You can also call ``help`` on any class or method to view information on it's functionality.

.. toctree::
:maxdepth: 2
Expand Down
12 changes: 7 additions & 5 deletions docs/core-types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@
Brownie Data Types
==================

Ether Values
============
Brownie provides several custom data types to simplify working with Ether values.

Brownie uses the :func:`wei <brownie.convert.datatypes.Wei>` class when a value is meant to represent an amount of ether. :func:`wei <brownie.convert.datatypes.Wei>` is a subclass of ``int`` that converts strings, scientific notation and hex strings into wei denominated integers:
Wei
===

Brownie uses the :func:`Wei <brownie.convert.datatypes.Wei>` class when a value is meant to represent an amount of ether. :func:`Wei <brownie.convert.datatypes.Wei>` is a subclass of ``int`` that converts strings, scientific notation and hex strings into wei denominated integers:

.. code-block:: python
Expand All @@ -20,7 +22,7 @@ Brownie uses the :func:`wei <brownie.convert.datatypes.Wei>` class when a value
>>> Wei(8.38e32)
838000000000000000000000000000000
It also converts other values to :func:`wei <brownie.convert.datatypes.Wei>` before performing comparisons, addition or subtraction:
It also converts other values to :func:`Wei <brownie.convert.datatypes.Wei>` before performing comparisons, addition or subtraction:

>>> Wei(1e18) == "1 ether"
True
Expand All @@ -29,7 +31,7 @@ It also converts other values to :func:`wei <brownie.convert.datatypes.Wei>` bef
>>> Wei("1 ether") - "0.75 ether"
250000000000000000

Whenever a Brownie method takes an input referring to an amount of ether, the given value is converted to :func:`wei <brownie.convert.datatypes.Wei>`. Balances and ``uint``/``int`` values returned in contract calls and events are given in :func:`wei <brownie.convert.datatypes.Wei>`.
Whenever a Brownie method takes an input referring to an amount of ether, the given value is converted to :func:`Wei <brownie.convert.datatypes.Wei>`. Balances and ``uint``/``int`` values returned in contract calls and events are given in :func:`Wei <brownie.convert.datatypes.Wei>`.

.. code-block:: python
Expand Down
8 changes: 4 additions & 4 deletions docs/interaction.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
Interacting with your Contracts
===============================

Brownie provides various objects and methods to simplify interacting with your project. These objects are accessed via three methods:
Brownie has three main components that you can use while developing your project:

1. The :ref:`console<console>` is useful for quick testing and debugging as you develop.
2. :ref:`Scripts<scripts>` are useful for automating common interactions and handling deployments.
1. The :ref:`console<console>` is useful for quick testing and debugging.
2. :ref:`Scripts<scripts>` allow you to automate common tasks and handle deployments.
3. :ref:`Tests<tests-intro>` help to ensure that your contracts are executing as intended and do not contain any bugs.

.. _console:
Expand All @@ -29,7 +29,7 @@ Brownie will compile the contracts, launch or attach to the :ref:`local test env

You can call the builtin ``dir`` method to see available methods and attributes for any class. Classes, methods and attributes are highlighted in different colors.

You can also call ``help`` on most classes and methods to get detailed information on how they work.
You can also call ``help`` on any class or method to view information on it's functionality.

.. _scripts:

Expand Down
34 changes: 24 additions & 10 deletions docs/nonlocal-networks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,36 @@ In addition to using `ganache-cli <https://github.com/trufflesuite/ganache-cli>`
* When interacting with the mainnet, make sure you verify all of the details of any transactions before signing or sending. Brownie cannot protect you from sending ETH to the wrong address, sending too much, etc.
* Always protect your private keys. Don't leave them lying around unencrypted!

Local and Hosted Nodes
======================
Personal Node vs Hosted Node
============================

TODO
In order to interact with a non-local network you must connect to a node. You can either run your own node, or connect to a hosted node.

Limitations of Hosted Nodes
---------------------------
Running your Own Node
---------------------

Clients such as `Geth <https://geth.ethereum.org/>`_ or `Parity <https://www.parity.io/ethereum/>`_ can be used to run your own Ethereum node, that Brownie can then connect to. Having your node gives you complete control over which RPC endpoints are available and ensures you have a private and dedicated connection to the network. Unfortunately, keeping a node operating and synced can be a challenging task.

If you wish to learn more about running a node, ethereum.org provides a `list of resources <https://ethereum.org/developers/#testnets-and-faucets>`_ that you can use to get started.

Using a Hosted Node
-------------------

When using a hosted node some RPC endpoints may be unavailable. In particular, Infura does not provide access to the `debug_traceTransaction <https://github.com/ethereum/go-ethereum/wiki/Management-APIs#user-content-debug_tracetransaction>`_ method. For this reason, Brownie's :ref:`debugging tools<debug>` will not work when connected via Infura.
Services such as `Infura <https://infura.io>`_ provide public access to Ethereum nodes. This is a much simpler option than running your own, but it is not without limitations:

TODO no unlocked accounts
1. Some RPC endpoints may be unavailable. In particular, Infura does not provide access to the `debug_traceTransaction <https://github.com/ethereum/go-ethereum/wiki/Management-APIs#user-content-debug_tracetransaction>`_ method. For this reason, Brownie's :ref:`debugging tools<debug>` will not work when connected via Infura.
2. Hosted nodes do not provide access to accounts - this would be a major security hazard! You will have to manually unlock your own :ref:`local account<local-accounts>` before you can make a transaction.

Registering with Infura
=======================
Using Infura
************

Before you can connect to a non-local network, you need access to an Ethereum node (whether your own local one or hosted) that supports JSON RPC (either HTTP, IPC, or web-sockets). `Infura <https://infura.io>`_ is a good option for accessing a hosted node. Once you register and create a project, Infura will provide you with a project ID as well as API URLs that can be leveraged to access the given network.
Before you can onnect to Infura you need to `register for an account <https://infura.io/register>`_. After you have signed up, login and create a new project. You will be provided with a project ID, as well as API URLs that can be leveraged to access the network.

To connect to Infura using Brownie, store your project ID as an environment variable named ``WEB3_INFURA_PROJECT_ID``. You can do so with the following command:

::

$ export WEB3_INFURA_PROJECT_ID=YourProjectID

Network Configuration
=====================
Expand Down

0 comments on commit 9ad1246

Please sign in to comment.