Skip to main content

Python implementation of the OnchFS (On-Chain File System) protocol for Tezos blockchain

Project description

OnchFS Python Client

Python client for the OnchFS (On-Chain File System) protocol on Tezos blockchain.

Installation

pip install pyonchfs

Quick Start

Download Files

from onchfs import OnchfsClient, Network

client = OnchfsClient(network=Network.MAINNET)

# Download directory
directory_hash = "f8020273fba472a3e87baf6eb0f3929915edabace0fa409a261c4c4fa6684b21"
files = client.download_directory(directory_hash, "downloaded/")

# Get specific file
content = client.get_file(directory_hash, "index.html")

Prepare Files for Upload

from onchfs import OnchfsClient, IFile, OnchfsPrepareOptions

client = OnchfsClient()

# Prepare files
files = [
    IFile(path="hello.txt", content=b"Hello, OnchFS!"),
    IFile(path="data.json", content=b'{"message": "test"}')
]

directory_inode = client.prepare_files(files)
directory_hash = client.get_directory_hash(directory_inode)

API

OnchfsClient

client = OnchfsClient(
    network=Network.MAINNET,  # MAINNET, GHOSTNET, LOCALNET
    contract_address=None,    # Optional custom contract
    pytezos_client=None      # Optional PyTezos client
)

Download Methods:

  • download_directory(hash, target_dir) - Download all files
  • get_file(hash, filename) - Get file content
  • get_file_metadata(hash, filename) - Get file metadata
  • list_directory(hash) - List directory contents

Preparation Methods:

  • prepare_files(files, options=None) - Prepare files for upload
  • prepare_directory(path, options=None) - Prepare directory
  • estimate_upload_cost(directory_inode) - Estimate costs
  • get_directory_hash(directory_inode) - Get hash

Types

from onchfs import IFile, OnchfsPrepareOptions

file = IFile(path="example.txt", content=b"content")
options = OnchfsPrepareOptions(chunk_size=16384, compress=True)

Examples

Run the included examples:

python examples/download_example.py
python examples/prepare_example.py

Contract Addresses

  • Mainnet: KT1Ae7dT1gsLw2tRnUMXSCmEyF74KVkM6LUo
  • Ghostnet: KT1FA8AGGcJha6S6MqfBUiibwTaYhK8u7s9Q

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

pyonchfs-0.1.2.tar.gz (17.0 kB view details)

Uploaded Source

Built Distribution

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

pyonchfs-0.1.2-py3-none-any.whl (16.5 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: pyonchfs-0.1.2.tar.gz
  • Upload date:
  • Size: 17.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyonchfs-0.1.2.tar.gz
Algorithm Hash digest
SHA256 a6669ff4ff85d9781d35b1a404523b02e4fd493d2cec5f7021afc130e96516d3
MD5 071fa74f212d91391f5dd9e2e8388636
BLAKE2b-256 cebd19c387d3f14e5244f59eb7015fafed851a137e00732771bddd2a53574c4d

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyonchfs-0.1.2.tar.gz:

Publisher: workflow.yml on objkt-com/pyonchfs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: pyonchfs-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 16.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for pyonchfs-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1604aad52bc3f746de20412cad0089a94eb8cca5e0fb9653b80a6ac56669fe74
MD5 1435e06c4ac9b749ffc247a6db7f05cc
BLAKE2b-256 46ff2e2a4fcf3c709103100da9e9e20db318ebaa12b9d7051e64f111ffc7e846

See more details on using hashes here.

Provenance

The following attestation bundles were made for pyonchfs-0.1.2-py3-none-any.whl:

Publisher: workflow.yml on objkt-com/pyonchfs

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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