Skip to main content

Proof of Human SDK — scan wallets, poll async jobs, access signal methods

Project description

poh-sdk

Python SDK for the Proof of Human network.

Install

pip install poh-sdk

# For transaction signing:
pip install poh-sdk cryptography

Quick start

import asyncio
from poh_sdk import PohClient

async def main():
    async with PohClient("https://bootnode.proofofhuman.ge") as poh:
        result = await poh.scan("0xabc...")
        print(result.result)   # True = human, False = bot, None = inconclusive

asyncio.run(main())

Sync usage

Use PohClient.sync(...) to get a synchronous wrapper exposing the same methods (no _sync suffix) without await:

from poh_sdk import PohClient

poh = PohClient.sync("https://proofofhuman.ge")
result = poh.scan("0xabc...")
balance = poh.get_balance("poh...")

Natural language jobs

Skill jobs always require a fee — pass budget (POH), wallet_address, and private_key_pem in AskOptions so the SDK can sign the payment. The node verifies the signature and debits the fee before it will run the job at all; it rejects the request outright (no job ever runs) without a valid signed payment.

from poh_sdk import AskOptions

async with PohClient("https://proofofhuman.ge") as poh:
    options = AskOptions(budget=0.5, wallet_address="poh...", private_key_pem=my_private_key)

    # Submit a question
    ref = await poh.submit_job(
        "What does vitalik.eth write about on Paragraph?",
        options,
    )

    # Wait for the answer
    result = await poh.poll_job_result(ref.job_id)
    print(result.output)       # skill-specific structured data
    print(result.nl_response)  # LLM natural-language answer

    # One-liner convenience
    result = await poh.ask_and_wait("What NFTs does gmoney.eth hold?", options)

Compute jobs (your own model + dataset)

Run inference with a model of your choice, optionally grounded in a Hugging Face dataset already installed on the node. Like skill jobs, compute jobs are never free — run_compute always signs a fee payment.

from poh_sdk import ComputeOptions

async with PohClient("https://proofofhuman.ge") as poh:
    ref = await poh.run_compute("Summarize the top 5 rows", ComputeOptions(
        model="llama3.1:8b",
        dataset="some-org/some-dataset",  # optional
        budget=0.5,                       # POH
        wallet_address="poh...",
        private_key_pem=my_private_key,
    ))
    result = await poh.poll_job_result(ref.job_id)
    print(result.output)

Before either of these will work, the wallet's signing key must be registered with the node once via register_signing_key() — the node has no way to verify a signature for a key it has never seen.

Wallet / blockchain

async with PohClient("https://proofofhuman.ge") as poh:
    # Balance (μPOH — divide by 1e9 for POH)
    bal = await poh.get_balance("poh...")
    print(bal.balance / 1e9, "POH")

    # Nonce
    nonce = await poh.get_nonce("poh...")

    # Transaction history
    history = await poh.get_transaction_history("poh...", limit=50)
    for entry in history.entries:
        print(entry.tx_hash, entry.delta)

    # Miner info
    info = await poh.get_miner_info()
    print(info.model, info.reputation)

Signing & transactions

from poh_sdk import (
    generate_key_pair,
    build_transfer,
    sign_transaction,
    create_signing_proof,
)

# 1. Generate a keypair — address is derived from the signing public key
private_key_pem, public_key_pem, my_address = generate_key_pair()

# 2. Register the public key with your local node (one-time)
async with PohClient(
    "https://bootnode.proofofhuman.ge",
    local_base_url="http://127.0.0.1:3456",
) as poh:
    await poh.register_signing_key(
        my_address, public_key_pem, create_signing_proof(my_address, private_key_pem)
    )

    # 3. Build, sign, and submit a transfer
    nonce_resp = await poh.get_nonce(my_address)
    tx     = build_transfer(my_address, recipient, amount_poh=5.0, nonce=nonce_resp.nonce + 1)
    signed = sign_transaction(tx, private_key_pem)
    result = await poh.submit_transaction(signed)
    print(result.tx_hash)

    # One-liner convenience (fetches nonce automatically)
    result = await poh.transfer(my_address, recipient, 5.0, private_key_pem)

Bulk scans

async with PohClient("https://proofofhuman.ge") as poh:
    job = await poh.scan_bulk(["0xaaa", "0xbbb", "0xccc"])

    # Stream progress
    async for snap in poh.watch_job(job.job_id):
        print(f"{snap.percent:.0f}% done")

    # Or wait in one call
    final = await poh.scan_and_wait(["0xaaa", "0xbbb"])

Multi-node

poh = PohClient(nodes=[
    "https://bootnode.proofofhuman.ge",
    "https://proofofhuman.ge",
    "https://poh.assetux.com",
])
# Automatically picks the fastest responding node

API reference

Scanning

Method Description
scan(input, opts?) Single-address scan
scan_bulk(inputs, opts?) Submit bulk scan job
poll_job(job_id, opts?) Poll until job completes
watch_job(job_id) Async generator of job snapshots
scan_and_wait(inputs, opts?) Bulk + poll in one call
get_brain_verdict(brain_key) AI verdict
poll_brain_verdict(brain_key) Poll until verdict resolves

Natural language jobs

Method Description
submit_job(question, options?) Submit NL question (AskOptions). Skill jobs always require a fee — pass budget, wallet_address, private_key_pem.
run_compute(prompt, options) Submit a job that runs a specific model (and optional dataset); ComputeOptions. Always requires a fee.
get_job_status(job_id) Poll status
get_job_result(job_id) Fetch result
poll_job_result(job_id, opts?) Poll until result ready
ask_and_wait(question, ask_options?, poll_options?) Submit + wait

Wallet / blockchain

Method Description
get_balance(address) Balance in μPOH
get_nonce(address) Account nonce
get_transaction_history(address, limit) Tx history
get_pending_transactions() Mempool pending txs
submit_transaction(tx) Submit signed tx
register_signing_key(addr, pub_key_pem, proof) Register key
transfer(from, to, amount_poh, private_key_pem, fee?, memo?) Full transfer

Signing utilities

Function Description
generate_key_pair() Fresh Ed25519 keypair (PKCS8 PEM)
sign_data(message, private_key_pem) Sign arbitrary data → base64
create_signing_proof(address, private_key_pem) Proof for key registration
build_transfer(from, to, amount_poh, nonce, fee?, memo?) Build unsigned tx
sign_transaction(tx, private_key_pem) Sign a PohTxData
compute_tx_hash(...) SHA-256 tx hash hex
compute_job_payment_hash(...) Canonical hash for a job fee payment (used internally by submit_job/run_compute)
sign_job_payment(...) Sign a job fee payment proof (used internally by submit_job/run_compute)

Node info

Method Description
get_node_info() Node metadata
get_miner_info() Miner details
list_skills() Available skills

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

poh_sdk-0.4.0.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

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

poh_sdk-0.4.0-py3-none-any.whl (18.1 kB view details)

Uploaded Python 3

File details

Details for the file poh_sdk-0.4.0.tar.gz.

File metadata

  • Download URL: poh_sdk-0.4.0.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for poh_sdk-0.4.0.tar.gz
Algorithm Hash digest
SHA256 a819e7995c499f5a7750ef77fa17e4131afa4325e076aaa53361089a792365d6
MD5 cdafa538d14a13c820fa5433e8d9af07
BLAKE2b-256 89613420ea6ce87913f6acbf69b02c82baf3d4ce80d2dea1a4477d8c3a689945

See more details on using hashes here.

File details

Details for the file poh_sdk-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: poh_sdk-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 18.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for poh_sdk-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 bb7972d28ebcc560cf0f67d943ac0acd6a996c18b2c6089e48ac1ae7e02a9f5f
MD5 bb25797dbc38bc89f9b3033cc7126602
BLAKE2b-256 bbc0ddb7f2255c4849e114e2efb4c52fc9dbfa339c4061a08874a6b0b22220ef

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