Skip to main content

Overview

The autoSign object provides methods and properties for managing autosign functionality. It’s available through the useInterwovenKit() hook.

Accessing the API

import { useInterwovenKit } from "@initia/interwovenkit-react"

function MyComponent() {
  const { autoSign } = useInterwovenKit()
  
  // Use autoSign methods and properties
}

Type Definitions

AutoSign Object

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.
isLoading
boolean
Returns true when autosign status is being initialized or checked, false otherwise. Use this to show loading indicators in your UI.
Example:
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.
expiration
Date | null
Returns a Date object representing when autosign expires on the default chain, or null if autosign is not enabled or has expired. Use this to display expiration information and check if autosign is currently active.
Example:
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.
expirations
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.
Example:
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.
enable
(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 enabledThrows: Error if user rejects, permissions are not configured, or autosign is already enabled
Example:
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 cancelled 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

disable()

Disables autosign for a specific chain or the default chain.
disable
(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 disabledThrows: Error if permissions are not configured or autosign is not enabled
Example:
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)
  }
}