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

# Builder Functions

> Utility functions for constructing signers, context rule types, and policy parameters.

## Signer Builders

```typescript theme={null}
import {
  createDelegatedSigner,
  createExternalSigner,
  createWebAuthnSigner,
  createEd25519Signer,
} from 'smart-account-kit';
```

### `createWebAuthnSigner()`

Create a passkey (secp256r1) signer.

```typescript theme={null}
const signer = createWebAuthnSigner(
  verifierAddress: string,
  publicKey: Uint8Array,
  credentialId: string
);
```

### `createDelegatedSigner()`

Create a delegated Stellar G-address signer.

```typescript theme={null}
const signer = createDelegatedSigner(
  address: string,           // G-address
  ed25519VerifierAddress: string
);
```

### `createEd25519Signer()`

Create an Ed25519 key signer.

```typescript theme={null}
const signer = createEd25519Signer(
  verifierAddress: string,
  publicKey: Uint8Array
);
```

### `createExternalSigner()`

Create a signer for a custom on-chain verifier contract.

```typescript theme={null}
const signer = createExternalSigner(
  verifierAddress: string,
  publicKey: Uint8Array
);
```

***

## Context Rule Type Builders

```typescript theme={null}
import {
  createDefaultContext,
  createCallContractContext,
  createCreateContractContext,
} from 'smart-account-kit';
```

### `createDefaultContext()`

A rule that matches any operation. Use as a catch-all fallback rule.

```typescript theme={null}
const context = createDefaultContext();
```

### `createCallContractContext()`

A rule that only matches invocations of a specific contract.

```typescript theme={null}
const context = createCallContractContext(contractAddress: string);
```

### `createCreateContractContext()`

A rule that only matches contract deployments.

```typescript theme={null}
const context = createCreateContractContext();
```

***

## Policy Parameter Builders

```typescript theme={null}
import {
  createThresholdParams,
  createWeightedThresholdParams,
  createSpendingLimitParams,
  LEDGERS_PER_HOUR,
  LEDGERS_PER_DAY,
  LEDGERS_PER_WEEK,
} from 'smart-account-kit';
```

### `createThresholdParams()`

M-of-N multisig: require `m` signatures from any of the rule's signers.

```typescript theme={null}
const params = createThresholdParams(m: number);
```

```typescript theme={null}
const twoOfThree = createThresholdParams(2);
```

### `createWeightedThresholdParams()`

Weighted voting: each signer has a weight, and the transaction must accumulate enough weight to reach the threshold.

```typescript theme={null}
const params = createWeightedThresholdParams(
  threshold: number,
  weights: Array<{ signerIndex: number; weight: number }>
);
```

```typescript theme={null}
const params = createWeightedThresholdParams(100, [
  { signerIndex: 0, weight: 70 },
  { signerIndex: 1, weight: 50 },
]);
```

### `createSpendingLimitParams()`

Cap token spending over a rolling ledger window.

```typescript theme={null}
const params = createSpendingLimitParams(
  tokenContract: string,
  limit: bigint,         // in stroops (1 XLM = 10_000_000 stroops)
  resetPeriod: number    // in ledgers
);
```

```typescript theme={null}
const params = createSpendingLimitParams(
  'CDLZFC3...',
  BigInt(100 * 10_000_000), // 100 XLM
  LEDGERS_PER_DAY           // resets daily
);
```

### Ledger Constants

```typescript theme={null}
LEDGERS_PER_HOUR  // 720
LEDGERS_PER_DAY   // 17_280
LEDGERS_PER_WEEK  // 120_960
```

***

## Signer Helper Functions

```typescript theme={null}
import {
  getCredentialIdFromSigner,
  signersEqual,
  truncateAddress,
  formatSignerForDisplay,
} from 'smart-account-kit';
```

| Function                            | Description                                            |
| ----------------------------------- | ------------------------------------------------------ |
| `getCredentialIdFromSigner(signer)` | Extract the credential ID from a WebAuthn signer       |
| `signersEqual(a, b)`                | Deep-compare two signers                               |
| `truncateAddress(address)`          | Shorten a G/C-address for display (e.g. `GABC...WXYZ`) |
| `formatSignerForDisplay(signer)`    | Format a signer as a human-readable string             |
