# setting up the SDK

[What is Linked List?](https://www.youtube.com/watch?v=F8AbOfQwl1c)

[What is PDA?](https://solana.com/docs/core/pda)

1. Type npm install "<https://github.com/IQCoreTeam/code_in_sdk.git>" to install IQ sdk.

### Features

* **Inscribe data** (`codeIn`, `codeInAfterErr`)
* **Fetch data** (`readCode`, `fetchLargeFileAndDoCache`)
* **Validate local data against on-chain state** (`dataValidation`)
* **Account initialization helper** (`userInit`)

### Step1. Make .env file&#x20;

```
SIGNER_PRIVATE_KEY="your_base58_encoded_private_key"
RPC="https://your.solana.rpc.endpoint"
```

### Step2. Account initialization (required on first use per wallet)

Before writing data for a wallet, you **must initialize the user account** on-chain:

[Why we need to make PDA?](https://app.gitbook.com/o/V0P8Hrpy6nw037kPupYK/s/1PRdz0H8Z8O6nP9PTXfE/~/changes/32/developers-info/setting-up-the-sdk/detail-how-code-in-works-with-2-pdas)

```
import iqsdk from 'iq-sdk';

await iqsdk.userInit();
```

### Write data to chain

```
import iqsdk from 'iq-sdk';

await iqsdk.codeIn("your data here", "manual_datatype", "your_handle");
```

Write Data From Middle:&#x20;

```
import iqsdk from 'iq-sdk';

const result = await iqsdk.codeInAfterErr(brokeNum, beforeHash, data, type, handle);

```

***

### Fetch data from chain

```
import iqsdk from 'iq-sdk';

const result = await iqsdk.readCode("your_transaction_id");
```

Or fetch and cache large files:

```
import iqsdk from 'iq-sdk';

const content = await iqsdk.fetchLargeFileAndDoCache("your_transaction_id");
```

***

#### Validate local data

```
import iqsdk from 'iq-sdk';

await iqsdk.dataValidation("transaction_id", "localDataString")
```

&#x20;


---

# 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://iqlabs.gitbook.io/iqlabs/developers-info/setting-up-the-sdk.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.
