Skip to content

Commit

Permalink
deploy: efb8a1e
Browse files Browse the repository at this point in the history
  • Loading branch information
PatrickAlphaC committed Sep 15, 2024
0 parents commit 0c406fb
Show file tree
Hide file tree
Showing 57 changed files with 8,136 additions and 0 deletions.
4 changes: 4 additions & 0 deletions .buildinfo
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 44002d3c86e6c237a7943c4af682f5c2
tags: 645f666f9bcd5a90fca523b33c5a78b7
Empty file added .nojekyll
Empty file.
Binary file added _images/docs-logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 39 additions & 0 deletions _sources/all_moccasin_toml_parameters.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
All moccasin toml parameters
===========================

.. code-block:: toml
# Changes the names and locations of specific directories in your project
[project]
src = "contracts"
out = "build"
script = "scripts"
lib = "dependencies"
# You can have pip-style dependencies and also github-style dependencies
# These are going to be dependencies for your vyper contracts
dependencies = ["snekmate==0.1.0", "pcaversaccio/[email protected]"]
installer = "uv"
# Add network settings to easily interact with networks
[networks.sepolia]
url = "https://ethereum-sepolia-rpc.publicnode.com"
chain_id = 11155111
is_fork = false
is_zksync = false
# This is the name of the account that will be unlocked when running on this network
default_account_name = "anvil"
# If you don't provide a password or private key, moccasin will prompt you to unlock it
# If you do, it will unlock it automatically
# But be careful about storing passwords and private keys! NEVER store them in plain text
unsafe_password_file = "/home/user/.moccasin/password" # Replace with actual path
[networks.sepolia.extra_data]
my_key = "{$ETHERSCAN_API_KEY}"
# It might be a good idea to place addresses in here!
[networks.mainnet.extra_data]
usdc = "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
# Put whatever else you want in here
[extra_data]
hi = "hello"
8 changes: 8 additions & 0 deletions _sources/cli_commands.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
mox
###

.. argparse::
:module: moccasin_wrapper_for_docs
:func: get_main_parser
:prog: mox

7 changes: 7 additions & 0 deletions _sources/common-errors.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Common Errors
=============

ValueError: <boa.network.NetworkEnv object at 0xXXXXXXXXX>.eoa not defined!
----------------------------------------------------------------------------

This is the most common error you'll run into, and it means you'll need to add an account to your `moccasin.toml`. You can do this by following the :doc:`wallet <wallet>` guide.
10 changes: 10 additions & 0 deletions _sources/console.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
Console
#######

You can enter a python shell with the `console` command. This will start a python shell with the `moccasin` module loaded, so you can interact with your contracts directly.

.. code-block:: bash
mox console
Press `q` and hit `ENTER` to exit the console.
103 changes: 103 additions & 0 deletions _sources/dependencies.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
Dependencies
############


Moccasin allows for working with either:

- :ref:`Installing from GitHub repositories <installing_github_dependencies>`

- :ref:`Installing Python PyPI packages <installing_pip_dependencies>` (these are your "normal" pip packages)


.. _installing_github_dependencies:

Installing GitHub Dependencies
==============================

To install a package from GitHub, you can run the following:

.. code-block:: bash
mox install ORG/REPO[@VERSION]
For example:

.. code-block:: bash
# Without a version
mox install pcaversaccio/snekmate
# With a version
mox install pcaversaccio/[email protected]
This will create an entry in your `moccasin.toml` file that looks like this:

.. code-block:: toml
[project]
dependencies = [
"pcaversaccio/[email protected]",
]
Which follows the same syntax that `pip` and `uv` to do installs from GitHub repositories. This will also download the GitHub repository into your `lib` folder.

You can then use these packages in your vyper contracts, for example in an miniaml ERC20 vyper contract:

.. code-block:: python
from lib.snekmate.auth import ownable as ow
initializes: ow
from lib.snekmate.tokens import erc20
initializes: erc20[ownable := ow]
exports: erc20.__interface__
@deploy
@payable
def __init__():
erc20.__init__("my_token", "MT", 18, "my_token_dapp", "0x02")
ow.__init__()
.. _installing_pip_dependencies:


Installing pip/PyPI Dependencies
================================

Moccasin let's you directly install and work with PyPI packages as you would any other python package. PyPi dependencies in moccasin are by default powered by the `uv <https://docs.astral.sh/uv/>`_ tool. In order to use this, you need to have the `uv` tool installed. However, you can change this setting to `pip` in your `moccasin.tom`.

.. code-block:: toml
[project]
installer = "pip" # change/add this setting
As of today, `moccasin` supports:

- `pip`

- `uv`

You can also directly install and work with PyPI packages as you would any other python package. To install a package from PyPI, you can run the following:

.. code-block:: bash
mox install PACKAGE
For example:

.. code-block:: bash
mox install snekmate
.. note::

Snekmate is both a `pypi <https://pypi.org/project/snekmate/>`_ and a GitHub package.

This will create an entry in your `moccasin.toml` file that looks like this:

.. code-block:: toml
[project]
dependencies = [
"snekmate==0.1.0",
]
36 changes: 36 additions & 0 deletions _sources/index.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
.. image:: _static/docs-logo.png
:width: 140px
:alt: Moccasin logo
:align: center


Moccasin
######

Moccasin is a fast, pythonic smart contract development framework heavily powered by `titanoboa <https://github.com/vyperlang/titanoboa>`_.


.. note::

This project is under active development.

How to read the documentation
=============================

The moccasin documentation is written in a way that assumes you are on a MacOS or Linux-like system. If you are using windows, we recommend you watch the first `10 minutes of this WSL tutorial <https://www.youtube.com/watch?v=xqUZ4JqHI_8>`_ and work with WSL. WSL stands for "Windows Subsystem for Linux" and it allows you to run a Linux commands on Windows machine.

Why Moccasin?
===========

We think web3 needs the following:

1. A python smart contract development framework.
a. We need this because python is the 2nd most popular language on earth, and is the number one choice for artificial intelligence and new computer engineers!
2. An easy way to run devops on contracts.
a. Running scripts to interact with contracts needs to be easy in a language that humans can understand.
3. And finally... it needs to be fast!

Then, we have some fun plans for AI, formal verification, fuzzing, and more in the future of moccasin, so stay tuned!


Head over to :doc:`installing moccasin <installing-moccasin>` to get started.
118 changes: 118 additions & 0 deletions _sources/installing-moccasin.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
.. _install:

Installing Moccasin
#################

There are a few things you'll need on your machine before you can install Moccasin. Please install the appropriate tools from the `Prerequisites`_ section. Once you have those, the recommended way to :ref:`install Moccasin is via uv <installation-with-uv>`.

Prerequisites
=============

1. Python 3.11 or later

.. _installation-with-uv:

Installation with uv
--------------------

For those unfamiliar, `uv <https://docs.astral.sh/uv/>`_ is a fast python package manager, and that helps us install moccasin into it's own isolated virtual environment, so we don't get any weird dependency conflicts with other python packages. It's similar to `pip` and `pipx` if you've used them before. It even comes with some `pip` compatibility, will tools like `uv pip install`.

It's highly recommended you understand how `virtual environments <https://docs.python.org/3/library/venv.html>`_ work as well.

The easiest way to install `uv` is:

.. code-block:: bash
curl -LsSf https://astral.sh/uv/install.sh | sh
But you can head over to the `uv installation instructions <https://docs.astral.sh/uv/getting-started/installation/>`_ for more options. If you don't have at least Python 3.11 installed, you'll need to install that first.

.. code-block:: bash
uv python install 3.11
Then, to install moccasin with `uv`, run:

.. code-block:: bash
uv tool install moccasin
Once installed, to verify that Moccasin is installed, you can run:

.. code-block:: bash
mox --version
And see an output like:

.. code-block:: bash
Moccasin CLI v0.1.0
.. _installation-with-pipx:

Installation with pipx
----------------------

Pipx is a tool to help you install and run end-user applications written in Python. It's roughly similar to macOS's ``brew``, JavaScript's ``npx``, and Linux's ``apt``.

``pipx`` installs Moccasin into a virtual environment and makes it available directly from the commandline. Once installed, you will never have to activate a virtual environment prior to using Moccasin.

``pipx`` does not ship with Python. If you have not used it before you will probably need to install it.

You can either head over to the `pipx installation instructions <https://github.com/pipxproject/pipx>`_ or follow along below.

To install ``pipx``:

.. code-block:: bash
python -m pip install --user pipx
python -m pipx ensurepath
.. note::

You may need to restart your terminal after installing `pipx`.

To install moccasin then with `pipx`:

.. code-block:: bash
pipx install moccasin
Once installed, you can run the following command to verify that Moccasin is installed:

.. code-block:: bash
mox --version
And see an output like:

.. code-block:: bash
Moccasin CLI v0.1.0
Installation with pip
---------------------

You can install with `pip`, and if you do so, it's highly recommended you understand how `virtual environments <https://docs.python.org/3/library/venv.html>`_ work.

To install with `pip`:

.. code-block:: bash
pip install moccasin
From source
-----------

To install from source, you'll need the `uv tool installed <https://docs.astral.sh/uv/>`_. Once installed, you can run:

.. code-block:: bash
git clone https://github.com/cyfrin/moccasin
cd moccasin
uv sync
source .venv/bin/activate
uv pip install -e .
And you will have `mox` in your virtual environment created from the `uv` tool. It's highly recommended you understand how `virtual environments <https://docs.python.org/3/library/venv.html>`_ work.
45 changes: 45 additions & 0 deletions _sources/moccasin_toml.rst.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
moccasin.toml
##############

The `moccasin.toml` file created is our configuration file. In this file we can have:

- project and layout settings

- network settings

- dependencies settings

- extra data

A `moccasin.toml` file can look like this:

.. code-block:: toml
[project]
src = "contracts"
[networks.sepolia]
url = "https://ethereum-sepolia-rpc.publicnode.com"
chain_id = 11155111
[extra_data]
my_key = "{$ETHERSCAN_API_KEY}"
You can learn more about each of the sections of the `moccasin.toml` file in their respective documentation.

- `Project <project>`_
- `Network <network>`_
- `Dependencies <dependencies>`_

You can also see a full example of a `moccasin.toml` in the :doc:`all moccasin toml parameters <all_moccasin_toml_parameters>` documentation.

Extra Data
==========

Extra data is a dictionary of data where you can put whatever you'd like. You can access it from your scripts with:

.. code-block:: python
from moccasin import config
print(config.get_config().extra_data["my_key"])
Loading

0 comments on commit 0c406fb

Please sign in to comment.