# SNIP721 (Secret NFTs)

### 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,
});
```

### Add Minter

```
const addMinterMsg = await secretjs.tx.snip721.addMinter(
  {
    contract_address: contractAddress,
    msg: { add_minters: { minters: [accounts[0].address] } },
    sender: accounts[0].address,
  },
  {
    gasLimit: 100_000,
  },
);
```

### Mint SNIP721 Token

<pre class="language-typescript"><code class="lang-typescript"><strong>const mintMsg = await secretjs.tx.snip721.mint(
</strong>  {
    contract_address :contractAddress,
    sender: accounts[0].address,
    msg: {
      mint_nft: {
        token_id: "1",
      },
    },
  },
  {
    gasLimit: 200_000,
  },
);
</code></pre>

### Send SNIP721 Token

```typescript
const txExec = await secretjs.tx.snip721.send(
  {
    sender: secretjs.address,
    contract_address: contractAddress,
    msg: {
      send_nft: {
        contract: accounts[1].address,
        token_id: "1",
      },
    },
  },
  {
    gasLimit: 50_000,
  },
);
```

### Add Minter and Mint in a Single Transaction

```typescript
const addMinterMsg = new MsgExecuteContract({
  sender: accounts[0].address,
  contract_address: contractAddress,
  // codeHash, // Test MsgExecuteContract without codeHash
  msg: { add_minters: { minters: [accounts[0].address] } },
  sentFunds: [],
});

const mintMsg = new MsgExecuteContract({
  sender: accounts[0].address,
  contract_address: contractAddress,
  code_hash: codeHash,
  msg: {
    mint_nft: {
      token_id: "1",
      owner: accounts[0].address,
      public_metadata: {
        extension: {
          image:
            "https://scrt.network/secretnetwork-logo-secondary-black.png",
          name: "secretnetwork-logo-secondary-black",
        },
      },
      private_metadata: {
        extension: {
          image:
            "https://scrt.network/secretnetwork-logo-primary-white.png",
          name: "secretnetwork-logo-primary-white",
        },
      },
    },
  },
  sentFunds: [],
});

const tx = await secretjs.tx.broadcast([addMinterMsg, mintMsg], {
  gasLimit: 5_000_000,
});

```

### Query Tokens with Permit

```typescript
let permit = await secretjs.utils.accessControl.permit.sign(accounts[0].address, "secretdev-1", "Test", [contractAddress], ["owner"], false)

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

### Query Tokens with Viewing Key

```typescript
await secretjs.tx.snip721.setViewingKey(
  {
    contract_address: contractAddress,
    sender: accounts[0].address,
    msg: {
      set_viewing_key: {
        key: "hello",
      },
    },
  },
  {
    gasLimit: 100_000,
  },
);

    let tokens = await secretjs.query.snip721.GetOwnedTokens({
  contract: { address: contractAddress, codeHash },
  owner: accounts[0].address,
  auth: { viewer: { viewing_key: "hello", address: accounts[0].address } },
});
```


---

# 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/snip721-secret-nfts.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.
