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

# API Reference

> Complete API documentation for the autosign feature

## Overview

The `autoSign` object provides methods and properties for managing autosign
functionality. It is available via the `useInterwovenKit()` hook.

## Accessing the API

```tsx theme={null}
import { useInterwovenKit } from '@initia/interwovenkit-react'

function MyComponent() {
  const { autoSign } = useInterwovenKit()

  // Use autoSign methods and properties
}
```

## Type Definitions

### AutoSign Object

```tsx theme={null}
interface AutoSign {
  isLoading: boolean
  enable: (chainId?: string) => Promise<void>
  disable: (chainId?: string) => Promise<void>
  expiration: Date | null
  expirations: Record<string, number | null>
}
```

## Properties

### isLoading

Indicates whether autosign status is currently being checked.

<ParamField path="isLoading" type="boolean">
  Returns `true` when autosign status is being initialized or checked, `false`
  otherwise. Use this to show loading indicators in your UI.
</ParamField>

**Example:**

```tsx theme={null}
function AutosignButton() {
  const { autoSign } = useInterwovenKit()

  if (autoSign.isLoading) {
    return <button disabled>Loading...</button>
  }

  return <button>Enable Autosign</button>
}
```

### expiration

Expiration date for autosign on the default chain.

<ParamField path="expiration" type="Date | null">
  Returns a `Date` object representing when autosign expires on the default
  chain, or `null` if autosign is not enabled. Use this to display expiration
  information and check if autosign is currently active.
</ParamField>

**Example:**

```tsx theme={null}
function ExpirationDisplay() {
  const { autoSign } = useInterwovenKit()

  if (autoSign.expiration && autoSign.expiration > new Date()) {
    return <p>Autosign expires: {autoSign.expiration.toLocaleString()}</p>
  }

  return <p>Autosign is not enabled</p>
}
```

### expirations

Map of chain IDs to expiration timestamps for all configured chains.

<ParamField path="expirations" type="Record<string, number | null>">
  Returns an object mapping chain IDs to expiration timestamps (in milliseconds
  since epoch). Use this for multi-chain applications to check autosign status
  across multiple chains. Returns `null` for chains where autosign is not
  enabled.
</ParamField>

**Example:**

```tsx theme={null}
function MultiChainStatus() {
  const { autoSign } = useInterwovenKit()

  return (
    <div>
      {Object.entries(autoSign.expirations).map(([chainId, timestamp]) => {
        if (!timestamp) return null

        const expiration = new Date(timestamp)
        const isActive = expiration > new Date()

        return (
          <div key={chainId}>
            {chainId}: {isActive ? 'Active' : 'Expired'}
            {isActive && ` (until ${expiration.toLocaleString()})`}
          </div>
        )
      })}
    </div>
  )
}
```

## Methods

### enable()

Enables autosign for a specific chain or the default chain.

<ParamField path="enable" type="(chainId?: string) => Promise<void>">
  Opens a drawer for user confirmation and creates the necessary authz and
  feegrant permissions. Returns a Promise that resolves when autosign is
  successfully enabled or rejects if the user cancels or an error occurs.

  **Parameters:** - `chainId` (optional): Chain ID to enable autosign for. If not
  provided, uses the default chain ID from `InterwovenKitProvider`.

  **Returns:** Promise that resolves when autosign is enabled

  **Throws:** Error if user rejects, permissions are not configured, or autosign
  is already enabled
</ParamField>

**Example:**

```tsx theme={null}
async function enableAutosign() {
  try {
    await autoSign.enable()
    console.log('Autosign enabled for default chain')
  } catch (error) {
    console.error('Failed to enable autosign:', error)
  }
}

async function enableForChain() {
  try {
    await autoSign.enable('minievm-2')
    console.log('Autosign enabled for minievm-2')
  } catch (error) {
    console.error('Failed to enable autosign:', error)
  }
}
```

**Error Cases:**

* `"User rejected auto sign setup"`: User canceled the confirmation dialog
* `"Auto sign permissions are not configured"`: `enableAutoSign` is not
  configured in the provider
* `"Auto sign is already enabled"`: Autosign is already active for the specified
  chain ID

### disable()

Disables autosign for a specific chain or the default chain.

<ParamField path="disable" type="(chainId?: string) => Promise<void>">
  Revokes all authz and feegrant permissions for the specified chain, preventing
  further automatic signing. Returns a Promise that resolves when autosign is
  successfully disabled.

  **Parameters:** - `chainId` (optional): Chain ID to disable autosign for. If not
  provided, uses the default chain ID from `InterwovenKitProvider`.

  **Returns:** Promise that resolves when autosign is disabled

  **Throws:** Error if permissions are not configured or autosign is not enabled
</ParamField>

**Example:**

```tsx theme={null}
async function disableAutosign() {
  try {
    await autoSign.disable()
    console.log('Autosign disabled for default chain')
  } catch (error) {
    console.error('Failed to disable autosign:', error)
  }
}

async function disableForChain() {
  try {
    await autoSign.disable('minievm-2')
    console.log('Autosign disabled for minievm-2')
  } catch (error) {
    console.error('Failed to disable autosign:', error)
  }
}
```
