# 1. Install and Initialize

## Overview

We provide the Golang and Javascript versions of Zecrey Marketplace SDK so that developers can easily access Zecrey's NFT marketplace service. It is an API wrapper for Zecrey that provides most of the functionality for the Zecrey platform. Before starting to use the SDK, developers must initialize the client.

## Get Marketplace SDK package

{% tabs %}
{% tab title="Golang" %}
{% code overflow="wrap" %}

```go
go get github.com/zecrey-Labs/zecrey-marketplace-go-sdk
```

{% endcode %}
{% endtab %}

{% tab title="Javascript" %}
{% code overflow="wrap" %}

```javascript
npm i @zecrey/zecrey-legend-js-sdk
```

{% endcode %}
{% endtab %}
{% endtabs %}

* Most forms of the data available are read-only, so user authentication is not required when querying to update the status of Zecrey NFT Marketplace. Therefore, we designed two ways for calling of the client and SDK for Zecrey NFT Marketplace.
  * When signing data to change the status of Zecrey NFT marketplace, you need to initialize the client to call.
  * When you only need to query data or generate a new signer, you can directly call the method in the SDK package.
* In the following, we list the circumstances under which the client should be initialized and when the SDK should be called directly.

| <p><br></p>                     | Client | SDK |
| ------------------------------- | ------ | --- |
| Register Account                | ✅      | ❌   |
| Apply Register-Host             | ✅      | ❌   |
| Create Collection               | ✅      | ❌   |
| Mint NFT                        | ✅      | ❌   |
| Create Sell Offer               | ✅      | ❌   |
| Create Buy Offer                | ✅      | ❌   |
| Cancel Offer                    | ✅      | ❌   |
| Match Offer                     | ✅      | ❌   |
| Transfer NFT                    | ✅      | ❌   |
| Withdraw NFT                    | ✅      | ❌   |
| Get Account Information         | ❌      | ✅   |
| Get Categories Information      | ❌      | ✅   |
| Get Collections Information     | ❌      | ✅   |
| Get NFT Information             | ❌      | ✅   |
| Get Offer Information           | ❌      | ✅   |
| Create L1 Account               | ❌      | ✅   |
| Generate Seed And L2 Public Key | ❌      | ✅   |
| Upload Media                    | ❌      | ✅   |

## **Initialize the client in the correct environment**

{% hint style="success" %}

#### 📚SDK REFERENCE

* [NewClient](https://pkg.go.dev/github.com/Zecrey-Labs/zecrey-marketplace-go-sdk@v1.0.5/sdk#NewClient)
  {% endhint %}

{% tabs %}
{% tab title="Golang" %}

#### Example

{% code overflow="wrap" %}

```go
package main

import (
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)

var (
   accountName = "Alice"
   seed = "0x7ea589236ac7e6034a40ad31f27a6ea1bbaeb7746ba5e8d3408a3abb480a8688"
)

func main() {
   //Initializing the client needs to access accountName and seed
   //Refer to the module of Register users to get parameters of accountName and seed
   client, err := sdk.NewClient(accountName, seed) 	 
   if err != nil { panic(err) }
 }
```

{% endcode %}
{% endtab %}

{% tab title="Javascript" %}

#### Example

{% code overflow="wrap" %}

```javascript
import { Client } from "@zecrey/zecrey-legend-js-sdk";

const accountName = "Alice.zec";
const seed = "0x7ea589236ac7e6034a40ad31f27a6ea1bbaeb7746ba5e8d3408a3abb480a8688";
//Using accountName and seed is required to initialize the client
//Please refer to the Register users module for the accountName and seed parameters.
const client = new Client(accountName, seed);
```

{% endcode %}
{% endtab %}
{% endtabs %}

## **Call the SDK in the correct environment:**

{% hint style="success" %}

#### 📚SDK REFERENCE

* [IfAccountRegistered](https://pkg.go.dev/github.com/Zecrey-Labs/zecrey-marketplace-go-sdk@v1.0.5/sdk#IfAccountRegistered)
  {% endhint %}

{% tabs %}
{% tab title="Golang" %}

#### Example

{% code overflow="wrap" %}

```go
package main

import (
   "fmt"
   "github.com/Zecrey-Labs/zecrey-marketplace-go-sdk/sdk"
)


func main() {
   accountName := "Alice"
   result, err := sdk.IfAccountRegistered(accountName)
   if err != nil { panic(err) }
   
   data,err:= json.Marshal(result)
   if err != nil { panic(err) }
    
   fmt.Println("GetAccountIsRegistered:",string(data))
}
```

{% endcode %}

#### Example result:&#x20;

{% code overflow="wrap" %}

```json
GetAccountIsRegistered: true
```

{% endcode %}
{% endtab %}

{% tab title="Javascript" %}

#### Example&#x20;

{% code overflow="wrap" %}

```javascript
import { SDK } from "@zecrey/zecrey-legend-js-sdk";

const sdk = new SDK();
await sdk.initial();

const accountName = "Alice.zec";
const res = await sdk.ifAccountRegistered(accountName);

console.log("GetAccountIsRegistered:", res)
```

{% endcode %}

#### Example result:&#x20;

{% code overflow="wrap" %}

```json
GetAccountIsRegistered: true
```

{% endcode %}
{% endtab %}
{% endtabs %}


---

# 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.zecrey.com/go-and-js-sdk-basic-guides/1.-install-and-initialize.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.
