Create New Carbon Token

circle-info

For a non-technical overview of Carbon and SmartNFTs, see Carbon: Native Assets on Phantasma Phoenix.

This page focuses on the technical steps to create a Carbon token.

Creating a New Carbon Token

The following code snippet demonstrates how to create a new Carbon token.

Imports

These are the imports typically required for creating a Carbon token:

import {
  Bytes32,
  CreateTokenFeeOptions,
  CreateTokenTxHelper,
  IntX,
  PhantasmaAPI,
  PhantasmaKeys,
  TokenInfoBuilder,
  TokenMetadataBuilder,
  TokenSchemasBuilder,
} from "phantasma-sdk-ts";

Initialize Deployer Keys

In the following examples, we will use the deployer’s PhantasmaKeys keypair and its Bytes32 public key.

Build Token Info

TokenInfoBuilder helps construct the class describing the token being deployed.

Set Token Creation Fees

CreateTokenFeeOptions is used to specify the fees for token creation. You can call the constructor without arguments to use default values.

Build and Sign the Transaction

CreateTokenTxHelper simplifies the process of building and signing the token creation transaction.

Broadcast the Transaction

Broadcast the transaction to the network.

Parse the Result

After the transaction is mined and its result is available, parse it to obtain the new Carbon token ID. This ID can later be used to create token series and mint new NFTs.

circle-info

For frontend signing, build a TxMsg via CreateTokenTxHelper.buildTx(...) and use PhantasmaLink.signCarbonTxAndBroadcast or EasyConnect.signCarbonTransaction.

Last updated