# NFTs on Hathor Network

<details>

<summary><mark style="color:purple;">Straight to the code!</mark></summary>

Instantiate the Cryptum SDK first:

```javascript
const sdk = new CryptumSdk({
  environment: 'testnet',
  apiKey: 'YOUR-API-KEY',
})
```

### Create NFT

Create a new NFT in Hathor blockchain.

**\*Obs: In Hathor, you will always spend 1% of the amount of tokens you are minting in HTR, that is, to mint 1000 tokens you need to spend 10 HTR.**

**`sdk.nft.create(opts)`**

* `opts.protocol` (string)(**required**) - blockchain protocol must be `HATHOR`.
* `opts.wallet` (Wallet)(**required**) - wallet to sign the transaction with.
* `opts.name` (string)(**required**) - token name.
* `opts.symbol` (string)(**required**) - token symbol.
* `opts.amount` (string)(**required**) - token amount to be first minted.
* `opts.uri` (string)(**required**) - metadata URI string.
* `opts.mintAuthorityAddress` (string)(**optional**) - wallet address to be the mint authority. Required if you want to mint more tokens later.
* `opts.meltAuthorityAddress` (string)(**optional**) - wallet address to be the melt authority. Required if you want to burn tokens later.

This function returns the transaction hash which is also the token UID (token identifier).

```javascript
const { hash } = await sdk.nft.create({
  protocol: 'HATHOR',
  wallet,
  symbol: 'NFT',
  name: 'NFT',
  amount: '1000000',
  uri: 'ipfs://....',
  mintAuthorityAddress: 'address...',
  meltAuthorityAddress: 'address...',
})
```

### Transfer NFTs

Transfer NFTs in Hathor is the same as any other tokens. See how to transfer here in [token transfers](https://github.com/blockforce-official/cryptum-sdk/blob/master/docs/tokens/hathor.md#transfer-tokens)

### Mint NFTs

Mint more NFTs.

**\*Obs: In Hathor, you will always spend 1% of the amount of tokens you are minting in HTR, that is, to mint 1000 tokens you need to spend 10 HTR.**

#### `sdk.nft.mint(opts)`

* `opts.protocol` (string)(**required**) - blockchain must be `HATHOR`.
* `opts.wallet` (Wallet)(**required**) - wallet minting tokens.
* `opts.tokenUid` (string)(**required**) - token identifier to be minted.
* `opts.amount` (string)(**required**) - token amount to be minted.
* `opts.destination` (string)(**required**) - destination wallet address to receive the minted tokens.
* `opts.mintAuthorityAddress` (string)(**optional**) - wallet address to be the mint authority. Required if you want to mint more tokens later.

This function returns the hash of this minting transaction from the blockchain.

```javascript
// Mint 100 NFTs
const { hash } = await sdk.nft.mint({
  protocol: 'HATHOR',
  wallet,
  token: '00000...',
  destination: 'WmpvgigZ4pNVLRPW2...sbK8pyV45WtP',
  amount: '100',
  mintAuthorityAddress: 'address...',
})
```

### Melt NFTs

Melt (burn) NFTs in Hathor blockchain.

#### `sdk.nft.burn(opts)`

* `opts.protocol` (string)(**required**) - blockchain must be `HATHOR`.
* `opts.wallet` (Wallet)(**required**) - wallet to sign the transaction with.
* `opts.tokenUid` (string)(**required**) - token identifier to be burnt.
* `opts.amount` (string)(**required**) - token amount to be burnt.
* `opts.meltAuthorityAddress` (string)(**optional**) - wallet address to be the melt authority. Required if you want to melt more tokens later.

This function returns hash of the burning transaction from the blockchain.

```javascript
// burn 5 NFTs
const { hash } = await sdk.nft.burn({
  protocol: 'HATHOR',
  wallet,
  token: '000000...',
  amount: '5',
  meltAuthorityAddress: 'address...',
})
```

</details>

### **What do I need in order to mint an NFT?**

A Cryptum API key is the only requirement to create your brand new NFT for Hathor. However, you probably want to add images, titles, symbols, attributes, etc. to your token. This information should be hosted in a service like [Pinata](https://www.pinata.cloud/) or [arweave](https://www.arweave.org/), and not on the token itself.

### ​Creating NFTs **Programmatically with Cryptum SDK** <a href="#jump" id="jump"></a>

<mark style="color:purple;">**Step 1**</mark>

The first prerequisite you will need is the creation of an **account** and a **Project (API Key**) on Cryptum Dashboard.

**PS**: Our dashboard is almost ready! To generate an API Key, contact <hello@blockforce.in>

<mark style="color:purple;">**Step 2**</mark>

With a valid Cryptum API Key, you can then instantiate the SDK as follows:

```javascript
const sdk = new CryptumSdk({
  environment: 'development',
  apiKey: "YOUR-API-KEY-HERE",
})
```

<mark style="color:purple;">**Step 3**</mark>

Then you must instantiate the wallet that will be used to create the NFTs:

```javascript
const wallet = await sdk.getWalletController().generateWallet({
    protocol: 'HATHOR',
    mnemonic: 'lorem ipsum dolor sit amet consectetur adipiscing ....',
    derivation: { account: 0, address: 0 }
  })
```

{% hint style="info" %}
*Make sure the wallet has sufficient funds to pay for the transactions.*
{% endhint %}

<mark style="color:purple;">**Step 4**</mark>

Create the new NFT by calling the function below:

```javascript
const { hash } = await sdk.nft.create({
  protocol: 'HATHOR',
  wallet,
  symbol: 'NFT',
  name: 'NFT',
  amount: '1000000',
  uri: 'ipfs://....',
  mintAuthorityAddress: 'address...', // optional
  meltAuthorityAddress: 'address...', // optional
})
```

{% hint style="info" %}
`wallet` will receive the newly minted tokens;\
`name` is the token name;\
`symbol` is the token symbol;\
`amount` is the amount to be first minted;\
`uri` is the metadata URI;\
`mintAuthorityAddress` is a wallet address that has the power to mint more NFTs. If it's `null` then this NFT can no longer be minted;\
`meltAuthorityAddress` is a wallet address that has the power to burn NFTs. If it's `null` then this NFT can no longer be minted;

The `hash` is the transaction hash which is also the NFT address.
{% endhint %}

### Mint NFTs <a href="#mint-hathor-tokens" id="mint-hathor-tokens"></a>

Mint an existing NFTs in Hathor blockchain.

{% hint style="info" %}
Keep in mind that you need enough HTR tokens to pay for this transaction depending on the minting amount, as already explained above.
{% endhint %}

{% hint style="info" %}
Only the minting authority can mint more tokens. It is required to pass the minting authority every time this function is called to keep on minting more tokens.
{% endhint %}

```javascript
const { hash } = await sdk.nft.mint({
    protocol: 'HATHOR',
    wallet,
    token: 'TOKEN_ADDRESS',
    destination: 'WmpvgigZ4p.....pyV45WtP',
    amount: '100',
    mintAuthorityAddress: 'ADDRESS'
})
```

### Burn tokens <a href="#melt-hathor-tokens" id="melt-hathor-tokens"></a>

Burn (melt) existing tokens in Hathor blockchain.

{% hint style="info" %}
Only the melt authority can burn more tokens. It is required to pass the melt authority every time this function is called to keep on burning more tokens.
{% endhint %}

```javascript
// burn 5 NFTs
const { hash } = await sdk.nft.burn({
  protocol: 'HATHOR',
  wallet,
  token: '000000...',
  amount: '5',
  meltAuthorityAddress: 'address...',
})
```

If you want to check the full Hathor Network NFTs doc, go to:

{% embed url="<https://github.com/blockforce-official/cryptum-sdk/blob/maste/docs/nfts/hathor.md#create-nft>" %}
