Skip to main content

Python SDK for interacting with the Open Labels Initiative; A framework for address labels in the blockchain space. Read & write labels into the OLI Label Pool, check your labels for OLI compliance.

Project description

OLI Python Package

Python SDK for interacting with the Open Labels Initiative; A framework for address labels in the blockchain space. Read & write labels into the OLI Label Pool, check your labels for OLI compliance.

Installation

pip install oli-python

Submitting New Labels

from oli import OLI
import os

# Initialize the client
# Make sure to pull in your private key from an .env file
oli = OLI(private_key=os.environ['OLI_PRIVATE_KEY'], is_production=True)

# Create a label
address = "0x9438b8B447179740cD97869997a2FCc9b4AA63a2"
chain_id = "eip155:1" # Ethereum Mainnet
tags = {
    "contract_name": "growthepie donation address",
    "is_eoa": True,
    "owner_project": "growthepie"
}

# Validate if your label is OLI compliant
possible_to_attest = oli.validate_label_correctness(address, chain_id, tags)
print(f"You can attest your label: {possible_to_attest}")

# Submit a label as an offchain attestation
response = oli.submit_offchain_label(address, chain_id, tags)
print(f"Label submitted offchain with response: {response.text}")

# Submit a label as an onchain attestation
tx_hash, uid = oli.submit_onchain_label(address, chain_id, tags)
print(f"Label submitted onchain with hash: {tx_hash} and uid: {uid}")

# Batch submit multiple labels as one onchain attestation
labels = [
    {'address': address, 'chain_id': chain_id, 'tags': tags},
    {'address': address, 'chain_id': chain_id, 'tags': tags}
]
tx_hash, uids = oli.submit_multi_onchain_labels(labels)
print(f"Labels batch submitted onchain with transaction hash: {tx_hash} and uids: {uids}")

# Revoke an attestation (revoking onchain attestations here)
trx_hash = oli.revoke_attestation(uid, onchain=True)
print(f"Label {uid} revoked with hash: {trx_hash}")

# Revoke multiple attestations (revoking onchain attestations here)
trx_hash, count = oli.multi_revoke_attestations(uids, onchain=True)
print(f"Labels batch revoked with hash: {trx_hash}")

Querying Existing Labels

from oli import OLI
import os

# Initialize the client (read mode only doesn't require a private key)
oli = OLI()

# Query attestations for a specific address
result = oli.graphql_query_attestations(address=address)
print(result)

# Download parquet export of raw attestations
oli.get_full_raw_export_parquet()

# Download parquet export of decoded attestations
oli.get_full_decoded_export_parquet()

Wallet Requirements

The OLI Label Pool lives on Base as an Ethereum Attestation schema.

Make sure your wallet contains ETH on Base Mainnet to pay for onchain transaction (including offchain revocations). Offchain attestations are free.

For testing purposes, you can use Base Sepolia Testnet by setting is_production=False when initializing the client.

Features

  • Submit onchain (single or batch) and offchain (single) labels into the OLI Label Pool
  • Revoke your own labels (single or batch)
  • Validate if your label is OLI compliant
  • Query attestations using GraphQL
  • Download full dataset exports in Parquet format

Documentation

For more details, see the OLI Documentation.

License

MIT

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

oli_python-1.0.2.tar.gz (15.5 kB view details)

Uploaded Source

Built Distribution

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

oli_python-1.0.2-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file oli_python-1.0.2.tar.gz.

File metadata

  • Download URL: oli_python-1.0.2.tar.gz
  • Upload date:
  • Size: 15.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for oli_python-1.0.2.tar.gz
Algorithm Hash digest
SHA256 57e95cd28f8c59756962c132ddf2aa78f90aef7983384150f4271335f1f02629
MD5 ff855c67ad8395259f3b124b976344c3
BLAKE2b-256 e2d9bfffd34b33d65e694580438361a493ae036c21f1bc35e8de6e22cabbb9c7

See more details on using hashes here.

File details

Details for the file oli_python-1.0.2-py3-none-any.whl.

File metadata

  • Download URL: oli_python-1.0.2-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for oli_python-1.0.2-py3-none-any.whl
Algorithm Hash digest
SHA256 825cd58c31e35cca01a45aecb85a5bb3c0b63696eb5c147c3fbb11a7dce7f8e5
MD5 097c1d292b1b75869227cdfb7f38c3ce
BLAKE2b-256 efc7e1f4f725fd559f000e145888c448dc74c22d4e8637ae3e8638c13f1ff524

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