Methods for transferring Bitcoin and tokens between Spark wallets.
transfer(params)
Transfers Bitcoin to another Spark wallet.
async transfer({
receiverSparkAddress,
amountSats,
}: {
receiverSparkAddress: string;
amountSats: number;
}): Promise<WalletTransfer>
Parameters:
params: Object containing:
receiverSparkAddress: The recipient’s Spark Address
amountSats: The amount in satoshis to transfer
Returns:
Promise<WalletTransfer>: The completed transfer details
transferTokens(params)
Transfers tokens to another user.
async transferTokens({
tokenIdentifier,
tokenAmount,
receiverSparkAddress,
selectedOutputs,
}: {
tokenIdentifier: string;
tokenAmount: bigint;
receiverSparkAddress: string;
selectedOutputs?: OutputWithPreviousTransactionData[];
}): Promise<string>
Parameters:
params: Object containing:
tokenIdentifier: The Bech32m token identifier (eg: btkn1…) of the token to transfer
tokenAmount: The amount of tokens to transfer
receiverSparkAddress: The recipient’s Spark Address
selectedOutputs: (Optional) Specific outputs to use for the transfer
Returns:
Promise<string>: The transaction ID of the token transfer
getTokenInfo()
Gets information about tokens owned by the wallet.
async getTokenInfo(): Promise<TokenInfo[]>
Returns:
Promise<TokenInfo[]>: Array of token information objects
queryTokenTransactions()
Retrieves token transaction from the network. Can optionally filter by ownerPublicKeys, issuerPublicKeys, tokenTransactionHashes, tokenIdentifiers, or outputIds.
Note: This is archived documentation. In current versions, you can only use one filter type per query - the parameters are mutually exclusive.
async 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:
Promise<TokenTransactionWithStatus[]>: Array of token transactions with status