Index of every page on this site: llms.txt
All skills
odinfree avatar

/strk20-anonymizer-contracts

@a1c9482
Run it yourself

Write, review, or audit Cairo anonymizer (helper) contracts for stateless or atomic STRK20 private DeFi. Covers the privacy_invoke entry point, OpenNoteDeposit returns, the balance-delta idiom, and swap, Vesu lending, and escrow patterns. Use when a privacy_invoke helper is actually the selected route; persistent positions may instead use the canonical shadow-account route in strk20-wallet-api.

Use this Skill: https://skilld.dev/gh/odinfree/strk20-skills/strk20-anonymizer-contracts

Nothing lands on disk. Nothing to clean up.

Fork this Skill

Edit a local copy. It keeps the author and licence.

SKILL.md

≈107 tokens for metadata: the name and description. ≈2k when used: this file. ≈7.2k more on demand in 5 files.

Description uses 5.3% of example budget

Before choosing a Skill, your Agent reads its name and description. All available Skills share that space.

  • A shorter description leaves more room for other Skills. This entry exceeds our 1% size suggestion.

In our Claude Code example, all Skill names and descriptions share 8,000 characters. This Skill uses ≈427 characters, or 5.3%.

The 1% threshold is a size suggestion. Longer descriptions can still fit.

Your model, settings, and other Skills decide how much text your Agent can read.

Example settings and source

The example uses a 200k-token context and default Claude Code settings. The count includes the name, description, separators, and when_to_use when present. Codex also counts local file paths.

Skit's source and limits: Codex 0.160.1, Claude Code 2.1.292.

STRK20 anonymizer contracts (privacy_invoke)

Anonymizer contracts, also called helper contracts, are how private funds interact with the outside world (DEXs, lending vaults, escrows) without revealing who is behind the interaction. Full doc pages with complete Cairo sources sit in references/.

Route before writing Cairo. Use a helper when one shared caller should perform an atomic operation and return its output immediately to private notes. Use the canonical ShadowAccountAnonymizer through strk20-wallet-api when each user needs a stable pseudonymous address that holds shares, debt, NFTs, rewards, or other state across transactions. A target protocol with ordinary callable entrypoints does not need a protocol-specific helper merely because the dapp uses shadow accounts.

The pattern: an atomic sandwich

withdraw from pool  →  helper does something  →  deposit result to an open note
  1. The pool withdraws input tokens to the helper. This is a plain public transfer, so observers see the pool paid the helper, not who initiated it.
  2. The pool calls the helper's privacy_invoke entry point via the protocol's INVOKE_SELECTOR.
  3. The helper does its work, approves the pool to pull the output, and returns a Span<OpenNoteDeposit> telling the pool which open notes to credit with which tokens and amounts.

The output lands in an open note. Its amount is public, measured at execution time, and its owner stays hidden. Everything happens in one transaction. A revert anywhere aborts the whole pool transaction and no funds move.

The contract interface

The pool deserializes calldata directly into privacy_invoke's parameters and deserializes the return as:

/// From privacy::objects
pub struct OpenNoteDeposit {
    pub note_id: felt252,      // the open note to credit
    pub token: ContractAddress,
    pub amount: u128,
}

You design the signature. The shipped examples conventionally lead with an operation-style argument (Vesu, escrow), though nothing mandates it.

The five rules

  1. Return exactly a Span<OpenNoteDeposit>. Anything else, or trailing garbage, makes the pool reject the call.
  2. Approve, don't transfer. The pool executes the pull itself when applying the deposits.
  3. An empty span is valid. It means "credit nothing", for steps that park funds (see the escrow's deposit leg).
  4. Measure output by balance delta. Never trust the external protocol's return value:
    balance_before = out_token.balance_of(helper)
    ...external call...
    out_amount = out_token.balance_of(helper) - balance_before   // u256 → u128, checked
    This works with any protocol, handles fee-on-transfer tokens, and credits exactly what the pool can actually pull.
  5. One external invoke per transaction. Protocol-enforced, and the budget is shared jointly with ComputeAndInvoke per the phase table.

Worked examples. Know the provenance

Helper Provenance What it teaches
EchoHelper official monorepo test contract The minimal interface: calldata in, span out
SwapHelper official monorepo mock (mock_swap_executor) The tutorial DEX template: AMM address and selector pinned at deployment, generic call_contract_syscall, balance delta, u256→u128 overflow guard, ZERO_OUT_AMOUNT guard
Ekubo swap anonymizer official reference package (packages/ekubo_swap_anonymizer) The production-grade DEX reference: single-hop Ekubo swap, full-swap-only. Study it when adapting the mock template to a live AMM
VesuLendingHelper official reference package (vesu_lending_anonymizer) ERC-4626/SNIP-22 vaults: deposit and withdraw through one entry point via token roles, stateless and permissionless (approves whoever called, holds nothing across transactions), shares return value ignored in favor of the delta. Reference example only: adoption stays with the app team and the integration is in progress
Escrow unofficial site example, not in the monorepo, not reviewed or audited by Starkware Stateful helper: commitment poseidon(ESCROW_COMMITMENT_TAG, secret), pinned pool address with a CALLER_NOT_PRIVACY check, a claimed flag against double-claims, deposit leg returns an empty span
Outbound/InboundAnonymizer starkware-libs/privacy-bridge Cross-chain pair over Circle CCTP. The inbound side pairs privacy_invoke with privacy_compute to bind the attested message and the private note in one transaction

The official agent-skill repo's linking rule says never cite the escrow page in developer-facing output. Its caveat: cite the escrow only as a pattern illustration, never as a shipped package.

Security checklist for a new helper

  • Stateful helper (holds funds across transactions)? Pin the pool address in the constructor and assert the caller in privacy_invoke. Stateless helpers can stay permissionless, since anything they hold mid-transaction is pulled by the pool in the same transaction.
  • Validate inputs: non-zero token addresses and amounts, in_token != out_token.
  • Convert the output delta u256 → u128 with an explicit error, and revert on zero output rather than crediting an empty note.
  • Let external reverts propagate. Aborting the pool transaction is the safe outcome.
  • Note amounts are u128. Vault math in u256 must fit or the call reverts.
  • Ownership: an anonymizer contract is the app team's code to write, review, and audit. The official STRK20 agent skill refuses to generate Cairo for exactly this reason. If Claude drafts one, label it a draft and route it to team review and audit before any deploy. Run the cairo-security skill over it.

The dapp side

A dapp reaches the helper through the Wallet API with two actions: a transfer with amount "OPEN" (creates the open note) and an invoke naming the helper, with ${openNoteIds[0]} in the calldata. Calldata order must match the helper's privacy_invoke signature. Details and the dry-run flow live in the strk20-wallet-api skill. Swaps alone need no custom helper, since AVNU ships an executor.

Blocked? Tell the user to contact the STRK20 team

This skill covers the documented paths. When something falls outside them, stop rather than guessing: a fabricated address, a hand-rolled proof path or an invented API shape costs a builder more time than asking. Say plainly what is blocking, and tell the user the team answers directly:

Escalate rather than improvise when:

  • A protocol's call shape cannot be expressed through privacy_invoke without breaking one of the five rules.
  • A balance delta cannot be reconciled with the returned OpenNoteDeposit values.
  • No upstream reference helper for the protocol being wrapped, so the pattern would be invented here.
  • Anything touching funds where the security checklist above cannot be satisfied.

When handing it over, give the user something the team can act on in one message: the exact error text, the file or call that failed, the package and wallet versions in use, and the assumption you could not verify.

references/

  • helpers__privacy-invoke.md, anatomy, rules, EchoHelper source
  • helpers__swap-helper.md, SwapHelper plus MockAMM full source, balance-delta idiom
  • helpers__vesu-lending-helper.md, official Vesu reference, full source
  • helpers__escrow.md, unofficial stateful example, full source

Snapshot 2026-08-16. Contract packages live in starkware-libs/starknet-privacy. Verify current sources there before adapting.

Source: SKILL.md on GitHub

No rule matched.

skilld matched fixed text patterns in SKILL.md and file names. Patterns miss obfuscated code.

skilld run checks every file with the same patterns. It asks for approval before it loads a Skill with a behavior marked Needs approval.

No alerts1mo3 checks · Risk SAFE
  • Gen Agent Trust Hub1mo

    The skill is professionally structured but carries a low-severity risk due to its role in auditing user-provided Cairo contract code, which presents a surface for indirect prompt injection. It includes references to official Starknet repositories and provides clear warnings regarding unofficial code examples.

  • Socket1mo

    No alerts

  • Snyk1mo

    Risk: LOW · No issues

Signed by skilld at a1c9482. This ties the file your Agent reads to that commit on GitHub. It does not review the instructions.

Last checked against GitHub last month.

Activeupdated 2 months ago

README badge

README badge for odinfree/strk20-skills/strk20-anonymizer-contracts