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 }>;
}>;

Returns: Object containing:

  • balance: Current balance in satoshis
  • tokenBalances: Map of token balances by token public key with token information 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({
  tokenPublicKey: string,
  tokenAmount: bigint,
  receiverSparkAddress: string,
  selectedOutputs?: OutputWithPreviousTransactionData[]
}): Promise<string>;

Parameters:

  • tokenPublicKey: Public key 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

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 }>;

getIssuerTokenInfo()

Gets the details about the token.

Tip: As an issuer, to get your token public key, you can call getIssuerTokenInfo() or getIdentityPublicKey()
For frequent retrieval of the token public key, we recommend using getIdentityPublicKey() since it does not involve a network call.
interface IssuerTokenInfo {
  tokenPublicKey: string;
  tokenName: string;
  tokenSymbol: string;
  tokenDecimals: number;
  maxSupply: bigint;
  isFreezable: boolean;
};

async function getIssuerTokenInfo(): Promise<IssuerTokenInfo>;

Token Activity Methods

getIssuerTokenActivity()

Gets the activity for the token associated with this issuer wallet.

interface ListAllTokenTransactionsResponse {
  transactions: Transaction[];
  nextCursor?: ListAllTokenTransactionsCursor;
}

async function getIssuerTokenActivity(
  pageSize?: number = 100,
  cursor?: ListAllTokenTransactionsCursor,
  operationTypes?: OperationType[],
  beforeTimestamp?: Date,
  afterTimestamp?: Date
): Promise<ListAllTokenTransactionsResponse>;

Parameters:

  • pageSize: (Optional, default: 100) Number of transactions per page
  • cursor: (Optional) Pagination cursor to pass in
  • operationTypes: (Optional) Which operation types to return (ISSUER_ANNOUNCE, ISSUER_MINT, USER_TRANSFER, ISSUER_BURN, ISSUER_FREEZE, ISSUER_UNFREEZE)
  • beforeTimestamp: (Optional) Return transactions before this date
  • afterTimestamp: (Optional) Return transactions after this date

Returns: List of token transactions with pagination info

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