npm package: @mintology/mintology-client
Description: Mintology SDK for JavaScript Client.
Latest version: 0.0.8

# Mintology Client SDK

Mintology SDK for JavaScript Client.

## Install

NPM

```
$ npm install @mintology/mintology-client --save
```

Yarn

```
$ yarn add @mintology/mintology-client
```

## How to use

```js
import Mintology from '@mintology/mintology-client';

const mintology = new Mintology({
  projectId: 'project-id-from-mintology-dashboard',
});
```

## How to configure

You can pass configuration along with [projectId](https://docs.mintology.app/reference/projects-list), Please check the source to check supported options.

- `env` is an environment specification, The default environment is production (`prod`).
- `signUpApiEndpoint` is an endpoint where Mintology backend signup configured.
- `plugins` is an array of Mintology Client Plugins. Checkout the [Plugins](#plugins).

```js
const mintology = new Mintology({
  env: 'dev',
  projectId: 'project-id-from-mintology-dashboard',
  signUpApiEndpoint: 'https://example.com/api/signup',
  plugins: [new MintologyPluginUi()],
});
```

## Available methods

These are the methods currently supported.

- [Authorize](#authorize)
- [Claim](#claim)

## Plugins

Here are some plugins to enhance the client experience.

- [@mintology/mintology-client-plugin-ui](https://www.npmjs.com/package/@mintology/mintology-client-plugin-ui)
- [@mintology/mintology-client-plugin-walletconnect](https://www.npmjs.com/package/@mintology/mintology-client-plugin-walletconnect)

### Authorize

This method is used to check if a user owns a particular token (or any token of a particular collection). If you do not specify a contract_address, we will use the contract associated with your project. If you do not specify a token_id, we will check if the wallet contain any token from the contract.

```js
await mintology.authorize({
  email: 'example@yourorganization.com',
});
```

These are the following attributes accepted by this method.

- `contract_address` The Contract address to check. This is the address of the NFT contract that minted the token and it is optional; if this parameter is absent, the project contract address will be used instead.
- `token_id` Token Id to check. This is the token id of the specific NFT token within the contract and it is optional; if absent, any token from the contract will authorize the wallet.
- **`email`** The email address of the user whose wallet you want to verify

```js
await mintology.authorize({
  token_id: 'example-token-id',
  email: 'example@yourorganization.com',
  contract_address: '0xb44753fb732b70201a80f34857236bd84963825a',
});
```

These are the following response attributes.

1. `authorized` is a boolean indicating whether the claim was authorized

```typescript
{
  authorized: boolean;
}
```

### Claim

This method will mint a free NFT to your user's wallet (which can be a Mintable Wallet, or their existing crypto wallet). This is the endpoint you should use for discount coupons, proof of attendance, and in general NFTs which you do not intend to sell.

_Note: Separating the mint and claim methods will allow you to clearly identify the purpose of each call in your analytics._

```js
await mintology.claim({
  email: 'example@yourorganization.com',
});
```

These are the following attributes accepted by this method.

- `metadata` Optional metadata to associate with minted token, if you don't have a pre-minted NFT in the dashboard, you need to pass in your own metadata to use.
- **`email`** The email address of the recipient (we'll look up the wallet address for you, or create one if required)

```js
await mintology.claim({
  email: 'example@yourorganization.com',
  metadata: {
    image: 'https://www.example.com/yournft.png',
    name: 'Example',
  },
});
```

These are the following response attributes.

1. `token_id` is a string indicating token id of the claimed token

```typescript
{
  token_id: string;
}
```

## See Also

- [Mintology Docs](https://docs.mintology.app/reference)
- [Mintology Node.js SDK](https://www.npmjs.com/package/@mintology/mintology)
- [Mintology Client Plugin UI](https://www.npmjs.com/package/@mintology/mintology-client-plugin-ui)
- [Mintology Client Plugin Walletconnect](https://www.npmjs.com/package/@mintology/mintology-client-plugin-walletconnect)

## License

MIT © [Mintable PTE LTD](https://mintable.com/)