> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spark.money/llms.txt
> Use this file to discover all available pages before exploring further.

# createToken

> Create a new token with name, ticker, decimals, and supply settings.

Creates a new token on Spark using Spark Native Tokens for the `IssuerSparkWallet`.

## Method Signature

```typescript theme={null}
// Returns transaction hash only
async createToken({
  tokenName,
  tokenTicker,
  decimals,
  maxSupply,
  isFreezable,
  extraMetadata,
  returnIdentifierForCreate,
}: {
  tokenName: string;
  tokenTicker: string;
  decimals: number;
  maxSupply?: bigint;        // defaults to 0n (unlimited)
  isFreezable: boolean;
  extraMetadata?: Uint8Array;
  returnIdentifierForCreate?: false;
}): Promise<string>

// Returns both transaction hash and token identifier
async createToken({
  tokenName,
  tokenTicker,
  decimals,
  maxSupply,
  isFreezable,
  extraMetadata,
  returnIdentifierForCreate,
}: {
  tokenName: string;
  tokenTicker: string;
  decimals: number;
  maxSupply?: bigint;        // defaults to 0n (unlimited)
  isFreezable: boolean;
  extraMetadata?: Uint8Array;
  returnIdentifierForCreate: true;
}): Promise<TokenCreationDetails>
```

## Parameters

<ResponseField name="tokenName" type="string" required>
  Name of the token (eg: SparkCoin)
</ResponseField>

<ResponseField name="tokenTicker" type="string" required>
  Token ticker (eg: SPARKC)
</ResponseField>

<ResponseField name="decimals" type="number" required>
  The precision the token supports (eg: 8 for BTC)
</ResponseField>

<ResponseField name="maxSupply" type="bigint">
  The maximum supply for this token (defaults to `0n` for unlimited supply)
</ResponseField>

<ResponseField name="isFreezable" type="boolean" required>
  Whether or not the Issuer can freeze this token
</ResponseField>

<ResponseField name="extraMetadata" type="Uint8Array">
  Optional extra metadata bytes to associate with the token (e.g., image data, JSON metadata)
</ResponseField>

<ResponseField name="returnIdentifierForCreate" type="boolean">
  When `true`, returns both the transaction hash and token identifier as `TokenCreationDetails`. When `false` or omitted, returns only the transaction hash as a string (default: `false`)
</ResponseField>

## Returns

When `returnIdentifierForCreate` is `false` or omitted:

<ResponseField name="txId" type="string" required>
  Spark Transaction ID
</ResponseField>

When `returnIdentifierForCreate` is `true`:

<ResponseField name="result" type="TokenCreationDetails" required>
  Object containing:

  * `tokenIdentifier`: Bech32m token identifier (e.g., `btkn1...`)
  * `transactionHash`: Spark Transaction ID
</ResponseField>

## Example

```typescript theme={null}
// Basic usage - returns only transaction hash
const txId = await issuerWallet.createToken({
  tokenName: "SparkCoin",
  tokenTicker: "SPARKC",
  decimals: 8,
  maxSupply: 1000000n,
  isFreezable: true,
  // Optional: add extra metadata
  extraMetadata: new TextEncoder().encode(JSON.stringify({ icon: "..." }))
});

console.log("Token created:", txId);

// Get both transaction hash and token identifier
const result = await issuerWallet.createToken({
  tokenName: "SparkCoin",
  tokenTicker: "SPARKC",
  decimals: 8,
  maxSupply: 1000000n,
  isFreezable: true,
  returnIdentifierForCreate: true
});

console.log("Token created:", result.transactionHash);
console.log("Token identifier:", result.tokenIdentifier);
```
