🔗mint

Description

The mint function is an asynchronous function that mints a new token for a specific contract on a specified blockchain.

It supports different contract types and performs the minting operation accordingly. The function utilizes contract-specific minting functions to handle the minting

Parameters

ParameterData TypeDescription

contract

string

The type of contract for which the token will be minted.

blockchain

string

The target blockchain on which the contract is deployed.

contractAddress

string

The address of the contract on the specified blockchain.

privateKey

string

The private key associated with the account performing the minting.

params

mintParams

Additional parameters required for the minting operation.

env

string

The environment for the minting operation.

Response

FieldData TypeDescription

code

Number

A numeric value indicating the execution status (1 for success, 0 for error).

error

any

The error object containing details about the encountered error, if applicable.

receipt

any

The receipt object containing information about the minting transaction, such as transaction hash and addresses.

tokenId

any

The ID of the minted token.

Example Request and Response

Prerequisites

Before making requests with NEST® SDK, you must have it installed.

You can install NEST® SDK using either npm or yarn. Use the following commands to install NEST® SDK:

npm install @nest25/evm-chains-lib
OR
yarn add @nest25/evm-chains-lib

Request

Here is an example of how to make a mint request using the NEST® SDK:

const { Nft } = require('@nest25/evm-chains-lib');

const nft = new Nft('testnet');
const privateKey = '0xYOUR_PRIVATE_KEY';

async function main() {
    const params = {
        receiver: '0xE668C72D4C67236A712Ce69A91C74358586f31ed',
        uri: ['1234'],
    };
    const result = await nft.mint('erc721', 'klay', '0x7a0f416cae7bd4d4f9112a6bb609423290d2945e', privateKey, params);
    console.log(result.transactionHash);
}

main();

Response

0x617e90b96033b6fbe439f0e89ea54e2a76dc902489b2c602f2f2e8d0698a57d4

Use Cases

  • Minting an ERC721 token: This function mints a new ERC721 token on the specified blockchain and contract. It requires the receiver address and the URI of the token.

  • Minting an ERC1155 token: For the ERC1155 contract type, this function mints a new ERC1155 token with the specified receiver, amount, URI, and other required parameters.

  • Minting a SoulBound token: If the contract type is SoulBound, this function mints a new SoulBound token with the specified receiver, URI, and other parameters.

  • Handling unsupported contract types: If the provided contract type is not supported, the function returns an error indicating that the contract type is not found.

Last updated