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

announceTokenL1()

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.
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. 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.
async function getIssuerTokenBalance(sparkAddress?: String): Promise<{ balance: bigint, bech32mTokenIdentifier: string }>;

getIssuerTokenMetadata()

Gets the metadata about the token.
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.
async function getIssuerTokenIdentifier(): Promise<string>;
Returns: Bech32m token identifier (eg: btkn1…)

queryTokenTransactions()

Retrieves token transaction from the network with flexible filtering options.
async function queryTokenTransactions({
  ownerPublicKeys,
  issuerPublicKeys,
  tokenTransactionHashes,
  tokenIdentifiers,
  outputIds,
}: {
  ownerPublicKeys?: string[];
  issuerPublicKeys?: string[];
  tokenTransactionHashes?: string[];
  tokenIdentifiers?: string[];
  outputIds?: string[];
}): Promise<TokenTransactionWithStatus[]>;
Parameters:
  • 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.