1. Configure your application

After getting your application set up in your creator portal, grab the needed:

  • auth token
  • application id
  • contract id that the NFT will be minted from
  • token template id to use as a base for your NFTs metadata
# Get an auth token using your Developer Portal credentials.
AUTH_TOKEN = ""
# Your application id is also in the Developer Portal.
APP_ID = ""
# Get your contract id from a previously created contract, or create a new one.
CONTRACT_ID = ""
# Get your template id from a template associated with your contract, or create
# a new one.
TOKEN_TEMPLATE_ID = ""

2. Set the wallet to receive the NFT

This wallet address will receive the minted token.

# Set the address to mint the NFT to
WALLET = ""

3. Configure the NFT metadata

Set the metadata for the NFT. You can modify this after its minted.

# Configure the NFT's metadata
TOKEN = {
    "image": "",
    "name": "Recipe NFT",
    "description": "Creating an example NFT using Bitski.",
    "tokenTemplateId": TOKEN_TEMPLATE_ID,
    "contractId": CONTRACT_ID,
}

4. Mint a NFT!

Send a POST request to the API with the wallet and token metadata in the request body. You should receive a 201 status code if it worked.

def mint_nft(auth_token, app_id, wallet, metadata):
    """Mint a NFT to a wallet of your choice."""

    response = requests.post(
        f"https://api.bitski.com/v1/apps/{app_id}/tokens",
        json={"initialOwner": wallet, "token": metadata},
        headers={
            "Authorization": f"Bearer {auth_token}",
            "Content-Type": "application/json",
        },
    )
    print("NFT minted successfully", response.status_code == 201)
    return response