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).
Agentic Wallet (no mnemonic in the agent)
Sign every write through a TON Tech Agentic Wallet — owner-revocable, deposit-capped, no mnemonic in the agent process. The owner mints the wallet on agents.ton.org with the operator public key; the operator (this SDK) signs every outgoing transaction.
import asyncio
import os
from enact_protocol import (
EnactClient,
AgenticWalletProvider,
generate_agent_keypair,
)
from tonutils.client import ToncenterV2Client
async def main():
# 1. (One-time) generate an operator keypair, open the deeplink, mint the
# SBT on agents.ton.org, then fund the wallet. Store the secret key in
# your secrets manager — never log it, never commit it.
if "AGENTIC_OPERATOR_SECRET" not in os.environ:
kp = generate_agent_keypair("my-agent")
print("Mint here:", kp["create_deeplink"])
print("Save secret_key_hex to AGENTIC_OPERATOR_SECRET, then re-run.")
return
# 2. Wire the agentic wallet into the EnactClient constructor.
api_key = os.environ["TONCENTER_API_KEY"]
rpc = ToncenterV2Client(api_key=api_key, is_testnet=False)
agentic = AgenticWalletProvider(
operator_secret_key=bytes.fromhex(os.environ["AGENTIC_OPERATOR_SECRET"]),
agentic_wallet_address=os.environ["AGENTIC_WALLET_ADDRESS"],
client=rpc,
)
async with EnactClient(api_key=api_key, agentic_wallet=agentic) as client:
# 3. Use the SDK normally — every write signs through the operator key.
job = await client.create_job(...)
await client.fund_job(job)
asyncio.run(main())
You can also probe an arbitrary address to verify it is an agentic wallet:
from enact_protocol import detect_agentic_wallet
info = await detect_agentic_wallet(client._client, "EQ...")
if info.is_agentic_wallet:
print("operator pubkey:", info.operator_public_key.hex())
print("revoked?", info.is_revoked)
LangChain integration
Use enact-langchain to drop
ENACT tools into any LangChain agent.
Links
- Docs: https://enact.info/docs/python-sdk
- Source: https://github.com/ENACT-protocol/enact-protocol/tree/master/python/enact-protocol
- NPM SDK (reference): https://www.npmjs.com/package/@enact-protocol/sdk
License
MIT
Metadata
Release files for enact-protocol 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| enact_protocol-0.3.0.tar.gz | 23.4 kB | Without provenance | Details for enact_protocol-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| enact_protocol-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for enact_protocol-0.3.0-py3-none-any.whl |
Total release size: 52.4 kB
Release files / enact_protocol-0.3.0.tar.gz
| Download URL | enact_protocol-0.3.0.tar.gz |
|---|---|
| Size | 23.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
7d8c7d4db5c987a14deb91805e83f712f241cc4d32beae9d07daa45fcbd44f3f
|
|
BLAKE2b-256 checksum How to use checksums |
73d869c2a924418098471077c1322dc541005c43be2b366573335424019f73ca
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Release files / enact_protocol-0.3.0-py3-none-any.whl
| Download URL | enact_protocol-0.3.0-py3-none-any.whl |
|---|---|
| Size | 29.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
291275db91481cd5b3168618f7792ff48ea9bb2679cc7fa29a768c929499ec1d
|
|
BLAKE2b-256 checksum How to use checksums |
f6bdefe3590f04df6b17760b4fbfd9be9db747561446c724fcd47d445e8090e0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.11.9
|
Security for enact-protocol 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.