NFTs on Hathor Network

Straight to the code!

Instantiate the Cryptum SDK first:

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).

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

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.

// 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.

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

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 or arweave, and not on the token itself.

​Creating NFTs Programmatically with Cryptum SDK

Step 1

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

Step 2

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

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

Step 3

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

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

Make sure the wallet has sufficient funds to pay for the transactions.

Step 4

Create the new NFT by calling the function below:

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

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.

Mint NFTs

Mint an existing NFTs in Hathor blockchain.

Keep in mind that you need enough HTR tokens to pay for this transaction depending on the minting amount, as already explained above.

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.

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

Burn tokens

Burn (melt) existing tokens in Hathor blockchain.

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.

// 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:

Last updated