BlockchainSdkService

@ObjCName(swiftName = "BlockchainSdkService")
class BlockchainSdkService

Main blockchain service exposed to Flutter.

This service provides a unified API for blockchain operations across different chain families (EVM, UTXO in the future). It automatically routes operations to the appropriate chain-specific service based on the network type.

This service is intended to be accessed via BlockchainKitSdk.blockchainService.

Usage from Flutter:

// Create asset and transaction
final ethAsset = NativeCoin(network: ethereumNetwork);
final tx = Transfer(asset: ethAsset, amount: BigInt.from(100000000), to: '0x...');

// Calculate fees
final fees = await BlockchainSdkService.calculateFees(tx, fromAddress);

// Get balance
final balance = await BlockchainSdkService.getBalance(ethAsset, address);

// Get transaction status
final status = await BlockchainSdkService.getTransactionStatus(network, txHash);

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Shared transaction status update stream for Flutter.

Functions

Link copied to clipboard
suspend fun calculateFees(tx: Transaction, from: String): Result<Fee>

Calculate the fee for a transaction.

Link copied to clipboard
fun getAddress(asset: Asset, groupId: String): Result<String>

Get the wallet address for a given asset and MPC group.

Link copied to clipboard
suspend fun getBalance(asset: Asset, address: String): Result<Balance>

Get the balance of an asset for a given address.

Link copied to clipboard
suspend fun getBalances(assets: List<Asset>, address: String): List<Result<Balance>>

Get balances for multiple assets for a given address.

Link copied to clipboard
suspend fun getNonce(network: Network, address: String): Result<BigInteger>

Get the nonce (transaction count) for an address on a network.

Link copied to clipboard

Get the status of a transaction by its hash.

Link copied to clipboard
suspend fun preImageHash(tx: Transaction, from: String, fee: Fee): Result<PreImageTx>

Build a PreImageTx for a transaction.

Link copied to clipboard
suspend fun sendTransaction(network: Network, signedTxHex: String): Result<Broadcast>

Broadcast a signed transaction to the network.

Link copied to clipboard
suspend fun sign(preImageTx: PreImageTx, groupId: String): Result<String>

Sign a transaction using MPC.

Link copied to clipboard
suspend fun signWithHw(preImageTx: PreImageTx, groupId: String): Result<String>

Sign a transaction using threshold MPC with a hardware device via Bluetooth.

Link copied to clipboard
suspend fun startTrackingTransaction(network: Network, hash: String, pollIntervalMs: Long? = null, notFoundTimeoutMs: Long? = null): Result<Boolean>

Start polling and streaming transaction status updates for a given hash.

Link copied to clipboard

Stop polling all transactions.

Link copied to clipboard
suspend fun stopTrackingTransaction(network: Network, hash: String): Result<Boolean>

Stop polling a specific transaction.