# Persistant Circuit Architecture

<figure><img src="/files/rBPeHRz7pIrEAaDZpwSN" alt=""><figcaption></figcaption></figure>

1. MintGrantAndBurn a PKP on Chronicle using the [Lit Explorer](https://lit-protocol.calderaexplorer.xyz/address/0x8F75a53F65e31DD0D2e40d0827becAaE2299D111/write-contract#address-tabs).
   * Invoke `mintGrantAndBurnNext` using a keyType `2`, the **bytes hash** of the `IPFS CID` found [**here**](https://chromadin.infura-ipfs.io/ipfs/QmSrk1TqfTPSiqEPyfbReZPAwfnQQw7Ai9jfPqbQQ8sndR) which generates the unsigned transaction data for logging all instantiated circuits and circuit responses to the ListenerDB Contract and a value of `0.000000000000000001` LIT.
2. Deploy your ListenerDB and ListenerAccessControl from the [**ListenerFactory**](https://polygonscan.com/address/0x13091758Cf341818C14b070bf237d42913fDCEbc) on Polygon by invoking `deployFromFactory` with your minted PKP address, public key and tokenId.
3. Set up an Node.js VM or similar and deploy your server architecture. For a full code example of the server <> sdk integration and set up see [**here**](https://github.com/DIGITALAX/nocode_listener_server).&#x20;
   * If you use the same architecture and endpoints, make sure to call `/connect` once at the start when the server is live to correctly instantiate the Lit client that is used to save logs on-chain.
4. Create and connect your frontend using NextJS or similar to the server. See a full code example [**here**](https://github.com/DIGITALAX/LitListenerSDK).
   * Queries can be made to the deployed [**Lit Listener Graph**](https://api.thegraph.com/subgraphs/name/digitalax/lit-listener) subgraph to retrieve the logs recorded on-chain.&#x20;
   * All DB contracts deployed through the Factory can easily retrieve their associated logs through this subgraph, with optionality to sort each query via your deployed DB address.
5. Make sure to fund your **PKP address** with enough MATIC to pay for the gas costs associated with broadcasting signed transactions to the deployed LitDB contract on Polygon network.


---

# 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.irrevocable.dev/database-and-server-interactions/persistant-circuit-architecture.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.
