Skip to main content

Balancer V2 Python API

Project description

balpy

balpy

Python tools for interacting with Balancer Protocol V2 in Python.

DISCLAIMER: While balpy is intended to be a useful tool to simplify interacting with Balancer V2 Smart Contracts, this package is an ALPHA-build and should be considered as such. Use at your own risk! This package is capable of sending Ethereum (or EVM compatible) tokens controlled by whatever private key you provide. User assumes all liability for using this software; contributors to this package are not liable for any undesirable results. Users are STRONGLY encouraged to experiment with this package on testnets before using it on mainnet with valuable assets.

Usage

balpy has been tested on:

  • MacOS using Python 3.9.0
  • Linux using Python 3.9-dev
  • Windows using Python 3.9.5

Install

Install from PiP

Local installation of the latest balpy release can be done simply using:

pip install balpy

However, for reliability and isolation, we recommend creating a package through poetry

# If you do not have poetry installed, install it using the following commands:
# pip install poetry
poetry new package-name
cd package-name
poetry add balpy

See release on PyPI: https://pypi.org/project/balpy/

Install from source

# Install in virtual environment using poetry
git clone https://github.com/balancer-labs/balpy.git
# checkout submodules
git submodule update --init --recursive

cd balpy
poetry install # Install dependencies and package
# You can enter the virtual environment using
poetry shell
# You can run a file using the environment
poetry run ./samples/misc/vaultWethRead.py

Locally building wheels

You can also create a wheel (.whl) file to build the library for platform-specific distribution

git clone https://github.com/balancer-labs/balpy.git
cd balpy
poetry build
# You can find the wheels here
cd dist/
# Wheel name will depend on version
pip install ./balpy-X.X.X.whl

Environment Variables

You must set these two environment variables in order to use the balpy module

  • KEY_API_ETHERSCAN: API key for Etherscan for gas prices
  • KEY_PRIVATE: Plain text private key for signing transactions

You also must set AT LEAST one of these environment variables to connect to the network

  • KEY_API_INFURA: API key for Infura for sending transactions
  • BALPY_CUSTOM_RPC: Custom RPC URL (like localhost or Polygon RPC)

Samples

See README.md in samples/ for more information.

DEV

Formatting

make fmt

Linting

make lint

Check all linters and formaters and tests.

Tests

A small number of tests are included for functionaly demonstration.

make test
make all

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

open_balpy-0.1.2.tar.gz (3.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

open_balpy-0.1.2-py3-none-any.whl (4.4 MB view details)

Uploaded Python 3

File details

Details for the file open_balpy-0.1.2.tar.gz.

File metadata

  • Download URL: open_balpy-0.1.2.tar.gz
  • Upload date:
  • Size: 3.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for open_balpy-0.1.2.tar.gz
Algorithm Hash digest
SHA256 cd23637ea63c9c9dab75d0bbd21608213d9d9a4c31b185b44fe5a51e9267c8e0
MD5 b054649b48a5bf21dacaf0c06f4aa8db
BLAKE2b-256 a5e66e7178cff6120f5f653cde3bb523b7c11d14a4023ad0ffb8d7aeb1edce7b

See more details on using hashes here.

File details

Details for the file open_balpy-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: open_balpy-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 4.4 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for open_balpy-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 a1a9c3e529757c9ac7cb005868245303f8fa94ba12a3a7a1a10db4a2aac25f73
MD5 5b128059e1e6dd61a65f6a46ba7f478c
BLAKE2b-256 37e448c7d9402030b92fefbfad302758de3b6c303af5892a34034f8a7eedb382

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page