> ## Documentation Index
> Fetch the complete documentation index at: https://docs.ana.fi/llms.txt
> Use this file to discover all available pages before exploring further.

# Quickstart

> Install the SDK, connect a wallet, and commit your first rule in about ten minutes.

This guide commits a rule for an ERC-20 wallet on Polygon Amoy. The rule sends 5 EURe to a friend on the 1st of each month.

## 1. Install the SDK

```sh theme={null}
npm install @anafi-cc/sdk viem
```

## 2. Create a client

```ts theme={null}
import { createAnafiClient } from "@anafi-cc/sdk";
import { createPublicClient, createWalletClient, custom, http } from "viem";
import { polygonAmoy } from "viem/chains";

const anafi = createAnafiClient({
  chainId: 80002,
  network: "polygon-amoy",
  backendUrl: "https://api.polygon-amoy.ana.fi",
  addresses: { anafiRegistry: "0x…", dslRegistry: "0x…" },
  delegationAdapters: { erc20_allow: "0x…" },
  native: "POL",
  erc20s: [{ symbol: "EURe", address: "0x…" }],
  publicClient: createPublicClient({ chain: polygonAmoy, transport: http() }),
  walletClient: createWalletClient({ chain: polygonAmoy, transport: custom(window.ethereum) }),
});
```

## 3. Write the rule

A rule is a short YAML document. The SDK has builders for common rules, and you can also write the document by hand.

```yaml theme={null}
rules:
  rent:
    trigger: { type: calendar, day_of_month: [1], time_of_day: "09:00", timezone: Europe/Berlin }
    actions:
      - { type: send_one, to: "0xFriend…", value: "5 EURe" }
```

## 4. Stage and commit

Staging checks the document and returns warnings that you can show to the user. Committing asks the wallet to sign.

```ts theme={null}
const staged = await anafi.stageErc20AllowDsl({ account, adapter, yaml, salt, parent: null });
console.log(staged.warnings);

await anafi.commitStagedErc20AllowDsl({
  staged,
  onStep: (step) => console.log("wallet prompt:", step.kind),
});
```

> [!NOTE]
>
> The wallet shows one approval for each token the rule spends, then one transaction for the commit.

## 5. Watch it run

```ts theme={null}
const activity = await anafi.getActivity(account);
```

> [!TIP]
>
> To stop every rule at once, call `setErc20AllowBlocked({ blocked: true })`, or revoke the token approval from any wallet app.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.