Animica Python Cloud

Write Python. Deploy to Animica. Get paid when people use it. A deployed function gets a public HTTPS endpoint, metered execution billed in ANM, and an exact revenue split — the platform takes 20%, you keep the rest as an immediately spendable balance.

How it actually works: deployments are anchored on-chain (source hash + artifact hash + DA blob id inside a signed DEPLOY tx) and executed off-chain in a hardened container. Animica consensus does not execute arbitrary Python — vm_py CALL transactions revert on mainnet by design (raw exec is fail-closed; enabling it would be node RCE). Anyone can fetch the DA blob, re-hash it, and verify exactly what code serves your endpoint.

1. Write a function

One file, one module-level entrypoint. request is the parsed JSON body (POST) or the query parameters (GET); the return value must be JSON-serializable.

handler.py
def main(request):
    name = "world"
    if isinstance(request, dict) and request.get("name"):
        name = str(request["name"])[:80]
    return {"greeting": f"Hello, {name}!", "echo": request}

2. Create it

You need an API key (create one in the Developer Center; keys are prefixed anm_mkt_) or a signed-in browser session. Create the function shell:

create the function
curl -s https://animica.dev/api/cloud/v1/functions \
  -H "authorization: Bearer $ANM_KEY" \
  -H 'content-type: application/json' \
  -d '{"slug": "hello", "name": "Hello", "timeoutMs": 10000, "memoryMb": 128}'
# -> { "function": { "id": "…", "slug": "hello", "status": "DRAFT", … } }

3. Deploy it

Pushing source creates version 1 — an immutable snapshot — and drives the full pipeline: static validation (AST-only, never executes your code) → canonical artifact hashes → DA blob → on-chain anchor DEPLOY tx → ACTIVE.

deploy version 1
curl -s https://animica.dev/api/cloud/v1/functions/$FUNCTION_ID/versions \
  -H "authorization: Bearer $ANM_KEY" \
  -H 'content-type: application/json' \
  -d "$(python3 - <<'PY'
import json
print(json.dumps({"source": open("handler.py").read(), "entrypoint": "main"}))
PY
)"
# -> validates, snapshots version 1, stores the DA blob, broadcasts the
#    on-chain anchor DEPLOY tx, and activates the endpoint

4. Call it — and share the link

Every deployed function is served at /api/cloud/v1/fn/{owner}/{slug}. Public functions with no surcharge can be called by anyone inside the free tier (50/day per caller); priced or private functions require a key. Every response carries the execution's request id and exact cost.

invoke
curl -s https://animica.dev/api/cloud/v1/fn/<you>/hello \
  -H 'content-type: application/json' -d '{"name": "Ada"}'
# -> {"greeting": "Hello, Ada!", "echo": {"name": "Ada"}}
#    response headers: x-animica-request-id, x-animica-cost-nanm, x-animica-status

What you get per call

  • Metered billing: base fee + CPU-ms + memory + AI tokens + egress, integer nANM — Pricing & economics.
  • Your split, settled instantly: the caller's payment is divided exactly (price = platform fee + your share) in one ledger transaction — Wallets & earnings.
  • A receipt with request id, usage and the full money breakdown.

Limits that apply to every function

  • Source ≤ 256 KB · timeout 1s–300s (default 30s) · memory 641024 MB (default 256 MB)
  • Request body ≤ 512 KB · response ≤ 1024 KB · 500 log lines/run
  • Nested calls: depth ≤ 4, ≤ 16 calls/run · AI: ≤ 8 calls and ≤ 8192 tokens/run

Next: the runtime ABI, the capability system, and six working examples you can copy.