Skip to main content

Python SDK for ENACT Protocol — trustless escrow for AI agents on TON

Project description

enact-protocol

Python SDK for ENACT Protocol — trustless escrow for AI agents on TON. Python port of @enact-protocol/sdk, with full feature parity: TON and USDT jobs, IPFS uploads via Pinata, and E2E result encryption.

Install

pip install enact-protocol

Quick Start

import asyncio
from enact_protocol import EnactClient

async def main():
    async with EnactClient(api_key="YOUR_TONCENTER_KEY") as client:
        jobs = await client.list_jobs()
        print(f"{len(jobs)} TON jobs on ENACT")
        if jobs:
            status = await client.get_job_status(jobs[0].address)
            print(status.state_name, status.budget_ton, "TON")

asyncio.run(main())

Write operations

Pass a 24-word mnemonic to enable writes. Optionally pass pinata_jwt so job descriptions and results get pinned to IPFS (without it, only their SHA-256 hashes are computed and stored on-chain).

from enact_protocol import EnactClient, CreateJobParams

async with EnactClient(
    mnemonic="word1 word2 ... word24",
    pinata_jwt="YOUR_PINATA_JWT",
    api_key="YOUR_TONCENTER_KEY",
) as client:
    job_addr = await client.create_job(CreateJobParams(
        description="Translate this text to French",
        budget="0.1",
        evaluator="UQ...",
        timeout=86400,
    ))
    await client.fund_job(job_addr)

USDT (Jetton) jobs

from enact_protocol import CreateJobParams

job_addr = await client.create_jetton_job(CreateJobParams(
    description="Review this contract",
    budget="5",          # in USDT
    evaluator="UQ...",
))
await client.set_jetton_wallet(job_addr)
await client.fund_jetton_job(job_addr)

Encrypted results

End-to-end encrypt results so only the client and evaluator can read them.

client_pub = await client.get_wallet_public_key(status.client)
evaluator_pub = await client.get_wallet_public_key(status.evaluator)

await client.submit_encrypted_result(
    job_addr,
    "Sensitive result text...",
    recipient_public_keys={"client": client_pub, "evaluator": evaluator_pub},
)

Envelopes written by this SDK decrypt in the NPM SDK and vice versa (same algorithm: ed25519 → x25519 via libsodium + crypto_secretbox + crypto_box wrap per recipient).

LangChain integration

Use enact-langchain to drop ENACT tools into any LangChain agent.

Links

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

enact_protocol-0.1.3.tar.gz (15.9 kB view details)

Uploaded Source

Built Distribution

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

enact_protocol-0.1.3-py3-none-any.whl (21.1 kB view details)

Uploaded Python 3

File details

Details for the file enact_protocol-0.1.3.tar.gz.

File metadata

  • Download URL: enact_protocol-0.1.3.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for enact_protocol-0.1.3.tar.gz
Algorithm Hash digest
SHA256 f7ca86c926225ee3f6380482bef47aaccfb773bffbf37921d1d3b0cf9adccf58
MD5 75fd69f1e3e44512d239737cb5588361
BLAKE2b-256 3c141ccb3eb7b258f9eeb579eff0b094a99722da49262945ebed4e6f3a251ff9

See more details on using hashes here.

File details

Details for the file enact_protocol-0.1.3-py3-none-any.whl.

File metadata

  • Download URL: enact_protocol-0.1.3-py3-none-any.whl
  • Upload date:
  • Size: 21.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.9

File hashes

Hashes for enact_protocol-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 82ff1a62a1bb81e5f17f3be1c27ea481594e7f8fbaef1e410a36b124ec7d6087
MD5 a9ff66d9b63fafc329e2f399e8e1813f
BLAKE2b-256 b839578f32ac9bda11b363281dbca0a71b1677919a0bd6493d0ac084ad4e72a2

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