> ## 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.

# Configuration

## Overview

Configuring autosign requires two main steps: setting up Privy for embedded
wallet management and configuring autosign permissions in your
`InterwovenKitProvider`. This guide walks you through both processes.

## Prerequisites

Before configuring autosign, ensure you have:

* A Privy account and application ID
* InterwovenKit already integrated into your application
* An understanding of which transaction types you need to auto-sign

## Setting Up Privy

Autosign requires Privy to manage embedded wallets. Privy provides secure key
management and wallet creation for ghost wallets.

<Steps>
  <Step title="Create a Privy Account">
    1. Visit [Privy's website](https://privy.io) and create an account
    2. Create a new application in the Privy dashboard
    3. Copy your application ID from the dashboard
  </Step>

  <Step title="Install Privy Dependencies">
    Install the required Privy packages in your application. This guide assumes
    InterwovenKit is already installed:

    <CodeGroup>
      ```bash npm theme={null}
      npm install @privy-io/react-auth
      ```

      ```bash yarn theme={null}
      yarn add @privy-io/react-auth
      ```

      ```bash pnpm theme={null}
      pnpm add @privy-io/react-auth
      ```

      ```bash bun theme={null}
      bun add @privy-io/react-auth
      ```
    </CodeGroup>
  </Step>

  <Step title="Configure Allowed Domains">
    Before configuring your application, set up allowed domains in the Privy
    dashboard to ensure security and proper functionality:

    1. **Access Privy Dashboard**: Log in to your Privy account
    2. **Click Into Application**: Click into the application you would like Privy
       to work with
    3. **Navigate to Allowed Domains**: Click **App settings** on the left sidebar
       and then click on the **Domains** tab
    4. **Add Domains**: Under **Allowed Origins**, add:
       * Your production domain (e.g., `app.example.com`)
       * Your development domain (e.g., `localhost:3000`)
       * Any staging domains you use

    <Warning>
      Privy services will only work on domains you've explicitly allowed. Add all
      domains where your application will run, including localhost for development.
    </Warning>
  </Step>

  <Step title="Configure Privy and Integrate with InterwovenKit">
    The following configuration wires Privy into InterwovenKit to enable embedded
    wallets and autosign:

    1. Wrap your app with `PrivyProvider` to enable authentication and embedded
       wallet management.
    2. Use Privy hooks (`usePrivy`, `useLoginWithSiwe`, `useCreateWallet`,
       `useWallets`) to access wallet and auth state.
    3. Pass those hooks into `InterwovenKitProvider` via `privyContext`.
    4. Enable autosign for supported message types using `enableAutoSign`.

    **Required Configuration for Autosign:**

    * `appId`: Your Privy application ID
    * `embeddedWallets.ethereum.createOnLogin: "all-users"`: **Required for
      autosign**. Ensures an embedded (ghost) wallet is created at login. Privy’s
      default behavior may not create an embedded wallet automatically, which will
      prevent autosign from working.

    ```tsx providers.tsx theme={null}
    import {
      PrivyProvider,
      useCreateWallet,
      useLoginWithSiwe,
      usePrivy,
      useWallets,
    } from '@privy-io/react-auth'
    import {
      InterwovenKitProvider,
      PRIVY_APP_ID,
    } from '@initia/interwovenkit-react'

    function InterwovenKitWrapper({ children }) {
      const privy = usePrivy()
      const siwe = useLoginWithSiwe()
      const { createWallet } = useCreateWallet()
      const { wallets } = useWallets()

      return (
        <InterwovenKitProvider
          privyContext={{ privy, siwe, createWallet, wallets }}
          // Enables autosign only for default contract execution messages
          enableAutoSign
        >
          {children}
        </InterwovenKitProvider>
      )
    }

    export default function Providers() {
      return (
        <PrivyProvider
          appId="YOUR_PRIVY_APP_ID"
          config={{
            appearance: {
              theme: 'dark',
            },
            embeddedWallets: {
              ethereum: { createOnLogin: 'all-users' },
              showWalletUIs: false,
            },
            loginMethodsAndOrder: {
              primary: [`privy:${PRIVY_APP_ID}`, 'detected_ethereum_wallets'],
            },
          }}
        >
          <InterwovenKitWrapper>{/* Your app */}</InterwovenKitWrapper>
        </PrivyProvider>
      )
    }
    ```
  </Step>
</Steps>

## Configuring Autosign Permissions

### Choose Your Autosign Mode

Before enabling autosign, decide which mode fits your application:

* **Boolean (`enableAutoSign`)**
  * Best for simple, single-chain apps
  * Automatically allows default contract execution messages for the chain
  * Does **not** allow token transfers, staking, or other non-default messages

* **Per-Chain Configuration
  (`enableAutoSign: { "chain-id": ["msg.type.Url", ...] }`)**
  * Required if your app sends tokens, delegates, or uses multiple chains
  * You must explicitly list every allowed message type

If your app does more than basic contract execution calls, you should skip the
boolean option and use the per-chain permissions in the
[Advanced Configuration](#advanced-configuration-explicit-permissions) section.

Most production applications will eventually require the per-chain
configuration.

### Simple Configuration (Limited)

This option only enables autosign for default contract execution messages and is
intentionally restrictive.

```tsx theme={null}
<InterwovenKitProvider
  privyContext={{ privy, siwe, createWallet, wallets }}
  enableAutoSign
  // ... other config
>
  {children}
</InterwovenKitProvider>
```

<Info>
  If you later need to support token transfers, staking, or multiple chains, you
  must switch from the boolean configuration to the per-chain configuration in
  the [Advanced Configuration](#advanced-configuration-explicit-permissions)
  section.
</Info>

When using boolean configuration, InterwovenKit automatically:

* Detects your chain's VM type
* Grants permission for the appropriate message type:
  * **MiniEVM**: `/minievm.evm.v1.MsgCall`
  * **MiniWasm**: `/cosmwasm.wasm.v1.MsgExecuteContract`
  * **MiniMove**: `/initia.move.v1.MsgExecute`

### Advanced Configuration (Explicit Permissions)

For multi-chain applications or when you need custom message types, specify
autosign permissions per chain:

```tsx theme={null}
<InterwovenKitProvider
  enableAutoSign={{
    'interwoven-1': [
      '/cosmos.bank.v1beta1.MsgSend', // native token transfers
      '/cosmos.staking.v1beta1.MsgDelegate', // staking
    ],
    'evm-1': ['/minievm.evm.v1.MsgCall'],
    'wasm-1': ['/cosmwasm.wasm.v1.MsgExecuteContract'],
    'move-1': ['/initia.move.v1.MsgExecute', '/cosmos.bank.v1beta1.MsgSend'],
  }}
  // ... other config
>
  {children}
</InterwovenKitProvider>
```

**Configuration Format:**

The `enableAutoSign` prop accepts an object where:

* **Keys**: Chain IDs (strings)
* **Values**: Arrays of message type URLs (strings)

**Common Message Types:**

* **EVM Chains**: `/minievm.evm.v1.MsgCall`
* **Wasm Chains**: `/cosmwasm.wasm.v1.MsgExecuteContract`
* **Move Chains**: `/initia.move.v1.MsgExecute`
* **Bank Module**: `/cosmos.bank.v1beta1.MsgSend`
* **Staking**: `/cosmos.staking.v1beta1.MsgDelegate`

<Warning>
  Only grant permissions for message types that your application actually needs.
  Granting overly broad permissions increases security risk.
</Warning>
