npm package: @rootfor/lightsaber-js
Description: Used as SDK for all root contract related operations
Latest version: 1.0.0

# Introduction

Used as SDK for all root contract related operations. The SDK allows you to perform operations like mint, approve, list & buy

# Usage

Everything is available in a simple interface named LightSaber

## Initialization

Needs to done before doing anything esle

```javascript
const lightSaber = await LightSaber.init({
    serverBaseUrl: <Server Uri>,
    authHeader: {
    }
} as SaberSettings)
```

## Mint

Mint to an existing collection

```javascript
lightSaber.mintToCollection({
    tokenAddress: string;
    userAddress: string;
    chainId: string;
    editions: number;
    tokenUri: string;
    tokenType: TokenType;
    onSignatureRequest: (method: any, params: any) => Promise<string>;
}) => Promise<void>
```

Create a new collection & mint

```javascript
lightSaber.createCollectionAndMint({
    collectionName: string;
    userAddress: string;
    chainId: string;
    editions: number;
    tokenUri: string;
    royalty: number | null;
    tokenType: TokenType;
    onSignatureRequest: (method: any, params: any) => Promise<string>;
}) => Promise<void>
```

Create a new collection, mint & approve the collection

```javascript
lightSaber.createCollectionMintAndApprove({
    collectionName: string;
    userAddress: string;
    chainId: string;
    editions: number;
    tokenUri: string;
    tokenType: TokenType;
    royalty: number | null;
    approvalType: ApprovalTypes;
    onSignatureRequest: (method: any, params: any) => Promise<string>;
}) => Promise<void>
```

## Approve

Approve for a contract type

```javascript
lightSaber.approve({
    userAddress: string;
    tokenAddress: string;
    chainId: string;
    approvalType: ApprovalTypes;
    onSignatureRequest: (method: any, params: any) => Promise<string>;
}) => Promise<void>
```

## List

List the contract to be listed for referral (Returns ref codes)

```javascript
lightSaber.listApprovedReferral({
    userAddress: string;
    tokenAddress: string;
    tokenId: string;
    nftId: number;
    count: number;
    chainId: string;
    onSignatureRequest: (method: any, params: any) => Promise<any>;
    skipApproval: boolean;
}) => Promise<any>
```

List the contract to be listed for seaport

```javascript
lightSaber.listApprovedSeaport({
    offerer: string;
    tokenAddress: string;
    nftId: number;
    tokenType: TokenType;
    tokenId: string;
    qty: number;
    pricePerItem: number;
    startTime: number;
    chainId: string;
    onApprovalSignatureRequest: (method: any, params: any) => Promise<any>;
    onSeaportSignatureRequest: (parameters: any) => Promise<string>;
    skipApproval: boolean;
}) => Promise<void>
```

List the contract to be listed for free claim

```javascript
lightSaber.listApprovedClaim: ({
    userAddress: string;
    tokenAddress: string;
    nftId: number;
    chainId: string;
    onSignatureRequest: (method: any, params: any) => Promise<any>;
    skipApproval: boolean;
}) => Promise<void>
```

## Claim or Buy

Claim the token using refcode

```javascript
lightSaber.claimWithReferenceCode: ({
    userAddress: string;
    tokenAddress: string;
    tokenOwner: string;
    tokenId: string;
    leaves: string;
    refCode: string;
    chainId: string;
    onSignatureRequest: (method: any, params: any) => Promise<string>;
}) => Promise<void>
```

Claim the token for free

```javascript
lightSaber.claimForFree: ({
    userAddress: string;
    tokenAddress: string;
    tokenOwner: string;
    qty: number;
    chainId: string;
    onSignatureRequest: (method: any, params: any) => Promise<string>;
};) => Promise<void>
```

Buy the token from seaport

```javascript
lightSaber.buyFromSeaport: ({
    order: any;
    onSeaportSignatureRequest: (order: any) => Promise<any>;
}) => Promise<void>
```