# Query Permits

### Secret Network Client Setup

```javascript
import { SecretNetworkClient, Wallet } from "secretjs";

const wallet = new Wallet("Your mnemonic words go here");

const secretjs = new SecretNetworkClient({
  chainId: "pulsar-3",
  url: "https://pulsar.lcd.secretnodes.com",
  wallet: wallet,
  walletAddress: wallet.address,
});
```

### Sign a Permit and use in a query

```typescript
let permit = await secretjs.utils.accessControl.permit.sign(
      accounts[0].address,
      "secret-2",
      "test",
      [contractAddress],
      ["owner", "balance"],
        false
    );

    let query = await secretjs.query.snip20.getBalance({
      contract: { address: contractAddress, codeHash },
      address: accounts[0].address,
      auth: { permit },
    });
```

### Verify a Permit

```typescript
let permit = await secretjs.utils.accessControl.permit.sign(
  accounts[0].address,
  "secret-2",
  "test",
  ["abcdef"],
  ["owner", "balance"],
    false
);

// can also use the variant "verifyNoExcept"
let result = secretjs.utils.accessControl.permit.verify(
  permit,
  accounts[0].address,
  "abcdef",
  ["owner"],
);
```

{% hint style="info" %}
Learn more about Query Permits [here](https://docs.scrt.network/secret-network-documentation/development/development-concepts/permissioned-viewing/certs-viewing-permits).&#x20;
{% endhint %}


---

# 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://docs.scrt.network/secret-network-documentation/development/frontend/templates/usage-examples/query-permits.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.
