Account abstraction

From keep-starknet-strange/starknet-agentic · View interactive version

Account abstraction is an AI agent skill from the GitHub repository keep-starknet-strange/starknet-agentic. Starknet account abstraction correctness and security guidance for validate/execute paths, nonces, signatures, and session policies.

How to use this skill

Skill file

Account Abstraction

When to Use

When NOT to Use

Quick Start

  1. Confirm __validate__ enforces lightweight, bounded checks.
  2. Confirm __execute__ enforces policy and selector boundaries.
  3. Verify replay protections (nonce/domain separation) for all signature paths.
  4. Add regression tests for each fixed session-key or policy finding.
  5. Run cairo-auditor for final AA/security pass before merge.

Core Focus

Workflow

References

starknet.js Example

import { Account, CallData, RpcProvider } from "starknet";

const provider = new RpcProvider({ nodeUrl: process.env.STARKNET_RPC! });
const account = new Account({ provider, address: process.env.ACCOUNT_ADDRESS!, signer: process.env.PRIVATE_KEY! });

// Validate preview (debug-only): inspect __validate__ behavior with the current nonce.
const nonce = await account.getNonce();
const call = { contractAddress: process.env.TARGET!, entrypoint: "set_limit", calldata: CallData.compile({ value: 7 }) };
await provider.callContract({
  contractAddress: account.address,
  entrypoint: "__validate__",
  calldata: CallData.compile({ calls: [call], nonce }),
});

// Execute path: real transaction that triggers __execute__ and nonce checks.
const tx = await account.execute([call]);
await provider.waitForTransaction(tx.transaction_hash);

Error Codes and Recovery

| Code | Condition | Recovery |

| --- | --- | --- |

| AA-001 | __validate__ is too expensive or stateful | Remove heavy logic from validation; add a test that caps validation steps. |

| AA-002 | __execute__ allows blocked selectors/self-calls | Enforce selector filters and self-call checks; add authorized/unauthorized regression tests. |

| AA-003 | Nonce or domain mismatch causes replay risk | Normalize nonce source/hash domain; add replay and cross-domain tests. |

| AA-999 | Unexpected runtime panic | Capture calldata + caller context, reproduce in unit tests, then escalate to cairo-auditor. |

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.