IssuerSparkWallet

The IssuerSparkWallet class extends SparkWallet (all the functions of SparkWallet are available) and provides functions for token issuance and management on the Spark network.

Token Management Methods

createToken()

Creates a new token directly on Spark using Spark Native Tokens (recommended).
async function createToken({
  tokenName: string,
  tokenTicker: string,
  decimals: number,
  maxSupply: bigint,
  isFreezable: boolean
}): Promise<string>;
Parameters:
  • tokenName: Name of the token (eg: SparkCoin)
  • tokenTicker: Token ticker (eg: SPARKC)
  • decimals: The precision the token supports (eg: 8 for BTC)
  • maxSupply: The maximum supply for this token (use 0n for unlimited supply)
  • isFreezable: Whether or not the Issuer can freeze this token
Returns: Spark Transaction ID as string

announceTokenL1() (Deprecated)

Deprecated Method: announceTokenL1() is being phased out in favor of createToken() for Spark Native Tokens. While this method still works and existing L1-announced tokens continue to function normally, we recommend using createToken() for all new token launches. This method will be removed in a future SDK release.
Potential loss of L1 funds
Announcing multiple times on L1 from the same wallet will cause a loss of L1 funds.
Only the first announcement by a wallet confirmed on chain will be recognized as valid.
Check the OP_RETURN for the LRC20 prefix in the returned L1 txid to verify announcement on chain.
reference transaction: link
Announces a new token on Bitcoin L1 (legacy method).
async function announceTokenL1(
  tokenName: string,
  tokenTicker: string,
  decimals: number,
  maxSupply: number,
  isFreezable: boolean,
  feeRateSatsPerVb?: number
): Promise<string>;
Parameters:
  • tokenName: Name of the token (eg: SparkCoin)
  • tokenTicker: Token ticker (eg: SPARKC)
  • decimals: The precision the token supports (eg: 8 for BTC)
  • maxSupply: The maximum supply for this token
  • isFreezable: Whether or not the Issuer can freeze this token
  • feeRateSatsPerVb: (Default: 2) Transaction fee per virtual byte
Returns: Bitcoin L1 Transaction ID as string

getBalance()

Gets the current balance of tokens.
interface TokenInfo {
  tokenPublicKey: string,
  tokenName: string,
  tokenSymbol: string,
  tokenDecimals: number,
  maxSupply: bigint,
};

async function getBalance(): Promise<{
  balance: bigint;
  tokenBalances: Map<string, { balance: bigint, tokenInfo: TokenInfo, bech32mTokenIdentifier: string }>;
}>;
Returns: Object containing:
  • balance: Current balance in satoshis
  • tokenBalances: Map of token balances by token public key with token information and Bech32m token identifier to display

mintTokens()

Mints new tokens.
async function mintTokens(tokenAmount: bigint): Promise<string>;
Parameters:
  • tokenAmount: The amount to mint (eg: 1000n)
Returns: Transaction ID as string

transferTokens()

Transfers tokens to another Spark Address.
async function transferTokens({
  tokenIdentifier: string,
  tokenAmount: bigint,
  receiverSparkAddress: string,
  selectedOutputs?: OutputWithPreviousTransactionData[]
}): Promise<string>;
Parameters:
  • tokenIdentifier: Bech32m token identifier (eg: btkn1…) of the token to transfer
  • tokenAmount: Amount of tokens to transfer
  • receiverSparkAddress: Recipient’s Spark Address
  • selectedOutputs: (Optional) Specific outputs to use for transfer
Returns: Transaction ID as string

batchTransferTokens()

Transfers tokens to multiple recipients in a single transaction.
async function batchTransferTokens({
  tokenIdentifier: string,
  transfers: { tokenAmount: bigint, receiverSparkAddress: string }[],
  selectedOutputs?: OutputWithPreviousTransactionData[]
}): Promise<string>;
Parameters:
  • tokenIdentifier: Bech32m token identifier (eg: btkn1…) of the token to transfer
  • transfers: Array of transfer objects containing recipient addresses and amounts
  • selectedOutputs: (Optional) Specific outputs to use for transfer
Returns: Transaction ID as string

burnTokens()

Burns existing tokens.
async function burnTokens(tokenAmount: bigint): Promise<string>;
Parameters:
  • tokenAmount: The amount to burn (eg: 1000n)
Returns: Transaction ID as string

freezeTokens()

Freezes issuer’s tokens for a specific wallet.
async function freezeTokens(sparkAddress: string): Promise<{
  impactedOutputIds: string[];
  impactedTokenAmount: bigint;
}>;
Parameters:
  • sparkAddress: The Spark Address to freeze.

unfreezeTokens()

Unfreezes issuer’s tokens for a specific wallet.
async function unfreezeTokens(sparkAddress: string): Promise<{
  impactedOutputIds: string[];
  impactedTokenAmount: bigint;
}>;
Parameters:
  • sparkAddress: The Spark Address to unfreeze.

Token Information Methods

getIssuerTokenBalance()

Gets the token balance of the wallet.
async function getIssuerTokenBalance(sparkAddress?: string): Promise<{ balance: bigint, bech32mTokenIdentifier: string }>;
Parameters:
  • sparkAddress: (Optional) Spark Address of the wallet to get the balance of. If no address is provided, the function will return the token balance of the issuer wallet.
Returns: Object containing balance and Bech32m token identifier

getIssuerTokenMetadata()

Gets the metadata about the token.
Breaking Change in v0.2.0: This method replaces the deprecated getIssuerTokenInfo() method.
Tip: As an issuer, to get your token public key, you can call getIssuerTokenMetadata() or getIdentityPublicKey()

For frequent retrieval of the token public key, we recommend using getIdentityPublicKey() since it does not involve a network call.
interface IssuerTokenMetadata {
  tokenPublicKey: string;
  tokenName: string;
  tokenSymbol: string;
  tokenDecimals: number;
  maxSupply: bigint;
  isFreezable: boolean;
  bech32mTokenIdentifier: string;
};

async function getIssuerTokenMetadata(): Promise<IssuerTokenMetadata>;

getIssuerTokenIdentifier()

Gets the Bech32m token identifier for the issuer’s token.
New in v0.2.0: This method provides a convenient way to get your token identifier for use in transfer operations.
async function getIssuerTokenIdentifier(): Promise<string>;
Returns: Bech32m token identifier (eg: btkn1…)

queryTokenTransactions()

Retrieves token transaction from the network with flexible filtering options.
Breaking Change in v0.2.0: The parameter structure for this method has been updated to be more flexible. Arguments are now passed as an object with optional filtering criteria.
async function queryTokenTransactions({
  ownerPublicKeys,
  issuerPublicKeys,
  tokenTransactionHashes,
  tokenIdentifiers,
  outputIds,
}: {
  ownerPublicKeys?: string[];
  issuerPublicKeys?: string[];
  tokenTransactionHashes?: string[];
  tokenIdentifiers?: string[];
  outputIds?: string[];
}): Promise<TokenTransactionWithStatus[]>;
Parameters: All parameters are optional and can be used individually or in combination:
  • ownerPublicKeys: (Optional) Array of owner public keys to filter by
  • issuerPublicKeys: (Optional) Array of issuer public keys to filter by
  • tokenTransactionHashes: (Optional) Array of token transaction hashes to filter by
  • tokenIdentifiers: (Optional) Array of Bech32m token identifiers to filter by
  • outputIds: (Optional) Array of output IDs to filter by
Returns: Array of token transactions with status

Token Activity Methods

getIssuerTokenDistribution()

Gets the token distribution information for the token associated with this issuer wallet.
This feature is currently under development and will be available in a future release of Spark.
async function getIssuerTokenDistribution(): Promise<TokenDistribution>;
Returns:
  • totalCirculatingSupply: Total circulating supply of the token
  • totalIssued: Total issued tokens
  • totalBurned: Total tokens burned
  • numHoldingAddress: Number of addresses holding the token
  • numConfirmedTransactions: Number of confirmed transactions

SparkWallet

The SparkWallet class provides core wallet functionality for interacting with the Spark network.

Core Methods

All SparkWallet methods are also available in IssuerSparkWallet. For complete documentation, see the Wallet API Reference.