Skip to main content

⚠ Note: as of Feb 2023, this library is not being maintained. If you encounter a bug, feel free to report it, but do not expect it to be fixed. If you do a PR where tests pass, we're happy to merge it. And feel free to fork this repo and change it as you wish (including bug fixes).

pybundlr

Simple py driver for bundlr.

Installation

Ensure prerequisites:

  • Linux/MacOS
  • Python 3.8.5+
  • Bundlr CLI: npm install -g @bundlr-network/client

Open a new terminal and:

#Create & activate venv
python -m venv venv
source venv/bin/activate

#main install
pip3 install pybundlr

Using Pybundlr Library

First, a quick example that reads information from a bundlr node. In this case, a balance.

In terminal, go into Python console: python

In Python console:

from pybundlr import pybundlr
eth_address = "0x7BA3d8551A6f2C70a5d47bb448BcF7EF69661822"
bal = pybundlr.balance(eth_address, "matic")
print(f"{eth_address[:4]}'s MATIC balance in bundlr node: {bal} wei")

Exit the Python console for the next step.

Now, for more thorough example. We'll create a file, publish it online, then read it back.

The bundlr node will need funds to pay for storage. So, please ensure that you have a Polygon account that holds some MATIC. Just a few cents' worth should be enough.

In terminal, export the private key of your Polygon account:

export TEST_PRIVATE_KEY1=<your private key>

In terminal, go into Python console: python

In Python console:

import os
import requests
from pybundlr import pybundlr

eth_private_key = os.getenv('REMOTE_TEST_PRIVATE_KEY1')

#create test file
file_name = "/tmp/testfile.txt"
content_in = "test content" + "\n"
with open(file_name, 'a') as f:
    f.write(content_in)

#fund the node, and upload the file
url = pybundlr.fund_and_upload(file_name, "matic", eth_private_key)
print(f"Uploaded file. It's online at: {url}")

#retrieve the result
result = requests.get(url)
content_out = result.text
assert content_out == content_in

This example was on Polygon mainnet, with currency = "matic". Pybundlr also works on Ethereum mainnet ("ethereum"), Arweave ("arweave"), and more.

Development

Metadata

Release files for pybundlr 0.1.12

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

Source distribution (sdist)

Source distribution for pybundlr 0.1.12
File Size Uploaded
pybundlr-0.1.12.tar.gz 7.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pybundlr 0.1.12
File Interpreter ABI Platform
pybundlr-0.1.12-py3-none-any.whl Python 3 none any Details

Total release size: 13.1 kB

Release files / pybundlr-0.1.12.tar.gz

Download URL pybundlr-0.1.12.tar.gz
Size 7.5 kB
Tags Source
SHA-256 checksum
How to use checksums
b7e0feb91996c32ffef9add0290027e6b3bafbac5942c41a48f6749b1cfc562f
BLAKE2b-256 checksum
How to use checksums
7678cfc7b7d4376b337c88677e0b9f8673a3ca07fa5be90b3e8ac1cf9db74eb8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release files / pybundlr-0.1.12-py3-none-any.whl

Download URL pybundlr-0.1.12-py3-none-any.whl
Size 5.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
c8588d91e348acf4c865b2bf7b0210ab5e25672fa36f9ac3878d2e8680aed7f9
BLAKE2b-256 checksum
How to use checksums
e78cb6a2e2a0c01a022f567f35d7168f94e78903f0ac4c962f956dc887002852
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.5

Release history Release notifications | RSS feed

This release

0.1.12 This release

2 release files

0.1.11

2 release files

0.1.10

2 release files

0.1.9

2 release files

0.1.8

2 release files

0.1.7

2 release files

0.1.6

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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