# useDecrypt

Hook parameters:

```typescript
interface IUseDecryptArguments {
    cipherText: string // Encrypted text
    tpk?: string // Transaction public key
    programId?: string // Program ID
    functionName?: string // Function name
    index?: number // Account index м/44'/0'/<account_index>'/0'
    enabled?: boolean // auto decrypt
}
```

Return values:

```typescript
// useDecrypt hook returns next fields
decryptedText: string // Decrypted text
loading: boolean // loading state
error: any // error message if something went wrong
decrypt: () => Promise<void> // a function to force decryption
```

Example (live demo <https://aleo-react-boilerplate.vercel.app/>):

```tsx
import { FC } from 'react'
import { useDecrypt } from 'aleo-hooks'

export const UseDecrypt: FC = () => {
    const { decryptedText, loading, error } = useDecrypt({ 
        cipherText: 'ciphertext1qgqtzwpwj2r0rw0md3zxlnnj9h7azun02f6tdm27u8ywxcsuw4pssp7xsp7edm749l4pd9s47wksc475dkhmjnl7yrzzylgnfyx2kfwkpqlsynj2' 
    })

    return (
        <div>
            {loading && <p>Loading...</p>}
            {error && <p>Something went wrong {JSON.stringify(error)}</p>}
            {decryptedText && <p>Decrypted text: {decryptedText}</p>}
        </div>
    )
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://aleo-hooks.gitbook.io/aleo-hooks/usedecrypt.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
