Skip to main content

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

Metadata

Release files for open-balpy 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for open-balpy 0.1.6
File Size Uploaded Provenance Actions
open_balpy-0.1.6.tar.gz 3.8 MB Without provenance Details for open_balpy-0.1.6.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for open-balpy 0.1.6
File Interpreter ABI Platform Actions
open_balpy-0.1.6-py3-none-any.whl Python 3 none any Details for open_balpy-0.1.6-py3-none-any.whl

Total release size: 8.3 MB

Release files / open_balpy-0.1.6.tar.gz

Download URL open_balpy-0.1.6.tar.gz
Size 3.8 MB
Tags Source
SHA-256 checksum
How to use checksums
27be178129507d65ce1d523a8e3fab61aaede03184ebfa27c449f733d313997c
BLAKE2b-256 checksum
How to use checksums
7140f5daf6495e5128f74b6357b84ed95eda44c22c0d933cb640aceecdb8575b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Release files / open_balpy-0.1.6-py3-none-any.whl

Download URL open_balpy-0.1.6-py3-none-any.whl
Size 4.4 MB
Tags Python 3
SHA-256 checksum
How to use checksums
eaf97945fc46a6a6f8aa92b169d542a591924427ca63f4f5fd27497d9322092c
BLAKE2b-256 checksum
How to use checksums
13399b9923aefce03d3b143635c506ffa74d7fb107550d394239b1b81ea64687
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.7

Security for open-balpy 0.1.6

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page